Directory Services

ldap_simple_bind_s

The ldap_simple_bind_s function authenticates a client to a server, using a plaintext password.

Caution   This function sends the name and password without encrypting them, and an unauthorized user, on the network, could read the password. Unless a TLS (SSL) encrypted session has been established, do not this function. For more information about how to set up an encrypted session, see Initializing a Session.

ULONG ldap_simple_bind_s(
  LDAP* ld,
  PCHAR dn,
  PCHAR passwd
);

Parameters

ld
[in] The session handle.
dn
[in] The name of the user to bind as. The bind operation uses the dn and passwd parameters to authenticate the user.
passwd
[in] The password of the user specified in the dn parameter.

Return Values

If the function succeeds, the return value is LDAP_SUCCESS.

If the function fails, it returns an error code. For more information, see Return Values.

Remarks

The ldap_simple_bind_s function initiates a simple synchronous bind operation to authenticate a client to an LDAP server. Subsequent bind calls can be used to reauthenticate using the same connection.

Upon completion of the bind operation, ldap_simple_bind_s returns to the caller. Use ldap_simple_bind if you prefer to have the operation carried out asynchronously. Be aware that if an LDAP 2 server is contacted, do not attempt other operations over the connection until the bind call has completed successfully.

Multithreading: Bind calls are unsafe because they apply to the connection as a whole. Use caution if threads share connections, and try to thread binds with other operations.

Note  The Microsoft LDAP client uses a default timeout value of 120 seconds (2 minutes) for each bind-response roundtrip. This timeout value can be changed using the LDAP_OPT_TIMELIMIT session option. Other operations do not have a timeout unless specified using ldap_set_option.

When all of the operations on the session handle are completed, terminate the session by passing the LDAP session handle to the ldap_unbind function. Also, if the ldap_simple_bind_s call fails, the session handle should be freed with a call to ldap_unbind when no longer required for error recovery.

Requirements

Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Unicode: Implemented as Unicode and ANSI versions on all platforms.
Header: Declared in Winldap.h.
Library: Use Wldap32.lib.

See Also

Functions, ldap_bind, ldap_bind_s, ldap_simple_bind, ldap_unbind, Return Values, Establishing an LDAP Session