Platform SDK: Active Directory, ADSI, and Directory Services

ldap_sslinit

The ldap_sslinit function initializes a secure sockets layer (SSL) session with an LDAP server.

LDAP* ldap_sslinit(
  PCHAR HostName,
  ULONG PortNumber,
  int secure 
);

Parameters

HostName
[in] A space-separated list of host names or dotted strings representing the IP address of hosts running an LDAP server to which to connect. Each host name in the list can include an optional port number which is separated from the host itself with a colon (:) character.
PortNumber
[in] Contains the TCP port number to which to connect. Set to LDAP_SSL_PORT to obtain the default port, 636. This parameter is ignored if a host name includes a port number.
secure
[in] If non-zero, the function uses SSL encryption. If the value is 0, the function establishes a plain TCP connection and uses clear text (no encryption).

Return Values

If the function succeeds, it returns a session handle, in the form of a pointer to an LDAP structure.

If the function fails, the return value is NULL.Use LdapGetLastError to retrieve the error code.

Remarks

Call ldap_sslinit to create a connection block to a secured LDAP server. The HostName parameter can be NULL in which case the run time attempts to find the "default" LDAP server. The hosts are tried in the order listed, stopping with the first one to which a successful connection is made.

The function allocates an LDAP structure to maintain state information for the session, and returns a handle to this structure. You pass this handle to subsequent LDAP function calls during the course of the session.

Multithreading: Calls to ldap_sslinit are thread-safe.

Microsoft implements security features, like SSL, through its SSPI capabilities.

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, LdapGetLastError, SSPI Options for Distributed Applications