Platform SDK: Active Directory, ADSI, and Directory Services

ldap_simple_bind

The ldap_simple_bind function authenticates a client to a server, using a clear text password.

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

Parameters

ld
[in] The session handle.
dn
[in] The distinguished name of the entry to bind as.
passwd
[in] The password to compare to the entry's userPassword attribute.

Return Values

If the function succeeds, it returns the message ID of the operation initiated.

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

Remarks

The ldap_simple_bind function initiates a simple asynchronous bind operation to authenticate a client to an LDAP server. Subsequent bind calls can be used to re-authenticate over the same connection.

To authenticate as a specific user, provide both the distinguished name of the entry (user) and the password for that entry. To authenticate an anonymous user (when no access permissions are required), pass NULL to both the dn and passwd parameters.

As an asynchronous function, ldap_simple_bind returns a message ID for the operation. Call ldap_result with the message ID to get the result of the operation. To cancel an asynchronous bind operation before it has completed, call ldap_abandon. Note that if an LDAP 2 server is contacted, no other operations over the connection should be attempted before the bind call has successfully completed.

If you prefer to have the function return the results directly, use the synchronous routine ldap_simple_bind_s.

Multithreading: Bind calls are not safe because they apply to the connection as a whole. Use caution if threads share connections and try to thread binds 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_abandon, ldap_bind, ldap_bind_s, ldap_result, ldap_simple_bind_s