Platform SDK: Active Directory, ADSI, and Directory Services

ldap_bind

The ldap_bind is an asynchronous function that authenticates a client to the LDAP server. The bind operation identifies a client to the directory server by providing a distinguished name and some type of authentication credential, such as a password. The authentication method being used determines the particular type of credential.

ULONG ldap_bind(
  LDAP* ld,
  PCHAR dn,
  PCHAR cred,
  ULONG method 
);

Parameters

ld
[in] The session handle.
dn
[in] The distinguished name of the entry used to bind.
cred
[in] The credentials to use for authentication. Arbitrary credentials can be passed using this parameter. The format and content of the credentials depend on the setting of the method parameter. See Remarks for more information.
method
[in] Indicates the authentication method to use.

Return Values

If the function succeeds, the return value is the message ID of the operation initiated.

If the function fails, it returns –1 and sets the session error parameters in the LDAP structure.

Remarks

This implementation of ldap_bind supports the following authentication method:

Authentication Method Description Credential
LDAP_AUTH_SIMPLE Authentication with a simple clear-text password. A string containing the user's password.

LDAP_AUTH_SIMPLE is the only authentication method compatible with the asychronous version of binding; ldap_bind. Using any other authentication method with ldap_bind will result in failure and will return LDAP_PARAM_ERROR. All other authentication methods require synchronous binding as provided by ldap_bind_s.

If your application does not require the level of security provided by these authentication services, consider using ldap_simple_bind, which requires only a clear-text password to bind. If you prefer a synchronous bind operation, use ldap_bind_s or ldap_simple_bind_s.

Note that LDAP 2 servers require an application to bind before attempting any other operations that require authentication.

Multithreading: Bind calls are not safe because they apply to the connection as a whole. Use caution if threads share connections and, whenever possible, thread the bind operations with other operations.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 SP4 or later.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in Winldap.h.
  Library: Use Wldap32.lib.
  Unicode: Declared as Unicode and ANSI prototypes.

See Also

Functions, ldap_bind_s, ldap_simple_bind, ldap_simple_bind_s, SEC_WINNT_AUTH_IDENTITY