Platform SDK: Active Directory, ADSI, and Directory Services |
The ldap_open function creates and initializes a connection block, then opens the connection to an LDAP server.
LDAP* ldap_open( PCHAR HostName, ULONG PortNumber );
If the function succeeds, it returns a session handle, in the form of a pointer to an LDAP data structure.
If the function fails, it returns NULL. Use the LdapGetLastError function to retrieve the error code.
Call ldap_open to create a connection block to an LDAP server. The HostName parameter can be NULL in which case the run time attempts to find the default LDAP server. The host names are tried in the order listed, stopping with the first successful connection.
The default LDAP server is a Microsoft specific option when you use LDAP_OPT_HOST_NAME. This option specifies the host name of the default LDAP server and returns the host name of the server in Unicode or ANSI, contingent on the use of ldap_get_optionW or ldap_get_optionA, respectively.
The ldap_open function allocates an LDAP data structure to maintain state information for the session and returns a handle to this structure. You can pass this handle to subsequent LDAP function calls during the course of the session.
Multithreading: Calls to ldap_open are thread-safe.
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.