ldapssl_init

Creates an LDAP session handle that is SSL enabled.

LDAP Version:v3
Library:*ldapssl.*
NDS Version:7.xx or higher
Platform:NLM, Windows (NT, 95, 98, 2000, XP, Vista 32-bit and 64-bit ), Linux (32-bit and 64-bit), Solaris, AIX, and HP-UX

Syntax

  #include <ldap_ssl.h>
  
  LDAP * ldapssl_init (
     const char   *host,
     int           port,
     int           secure);
  
  

Parameters

host

(IN) Contains the names of the available hosts, each separated by a space, or a list of IP addresses (in dot format) of the hosts, each separated by a space. If a port number is included with the name or the address, it is separated from them with a colon (:).

port

(IN) Contains the TCP port number to connect to, which for an SSL connection is the SSL port number of the LDAP server. If a port number is included with the host parameter, this parameter is ignored.

secure

(IN) Specifies whether the connection is established over SSL.

  • Zero—do not establish the connection over SSL (which makes this function essentially the same as the ldap_init function)

  • Non-zero—establish the connection over SSL

Return Values

>0

Success; session handle

NULL

Unsuccessful

Remarks

If you connect to an LDAP v2 server, you must call an LDAP bind operation before performing any operations. If you connect to an LDAP v3 server, some operations can be performed before calling a bind operation.

Before calling this function, you must first call the ldapssl_client_init function which initializes the SSL library.

Calling the ldapssl_init function is equivalent to calling the ldap_init function followed by the ldapssl_install_routines function.

The ldapssl_init function does not actually communicate with the LDAP server. Communication begins when the application binds or does some other operation.

The LDAP libraries first contact the first server listed in the host parameter. If they are unable to communicate with that server, they try the next server and then the next.

The session handle returned contains opaque data identifying the session. To get or set handle information, use ldap_set_option and ldap_get_option. For a list of the handle options, see Section 6.10, Session Preference Options.

For sample code, see sslbind.c.

IMPORTANT:The ldap_init function allocates memory for the LDAP structure. This memory must be freed by calling ldap_unbind or ldap_unbind_s even when an LDAP bind function is not called or the LDAP bind function fails.

See Also

ldapssl_client_init, ldap_init