ldap_init(3ldap)


ldap_init -- initialize LDAP library

Synopsis

#include <lber.h> 
#include <ldap.h> 

LDAP *ldap_init(char *host, int port);

Description

ldap_init initializes a session with an LDAP server. It does not cause any contact with the server. After initializing a session, it is necessary to perform a bind function to the server. See ldap_simple_bind(3ldap).

As parameters, ldap_init takes host, the hostname on which the LDAP server is running, and port, the port number to which to connect. If the default IANA-assigned port of 389 is desired, LDAP_PORT should be specified for port.

The host parameter may contain a blank-separated list of hosts to try to connect to, and each host may optionally be of the form host:port. The host may be either in the from of a hostname or a dotted string giving an IP address. If present, the :port overrides the port parameter to ldap_init. If more than one server is specified, the servers will eventually be tried in the order given, stopping with the first one to which a successful connection is made.

Upon successfully initializing a session, ldap_init returns an LDAP structure which is used to identify the session and to maintain per-session information. Users are advised to use the ldap_get_option(3ldap) and ldap_set_option(3ldap) functions to access the per-session information rather than accessing the structure directly.

There a similar function, ldap_open(3ldap), which is defined in RFC 1823. For the latest version of the LDAP API, it is expected that ldap_init will be the preferred mechanism.

Return values

If an error occurs, ldap_init returns NULL with no further qualifying information. If no error occurs, ldap_init returns a pointer to an LDAP structure which can be used to identify the session.

References

Intro(3ldap), ldap_bind(3ldap), ldap_open(3ldap), ldap_perror(3ldap), ldap_simple_bind(3ldap), ldap_unbind(3ldap)
30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.