ldap_open(3ldap)


ldap_open -- initialize LDAP library

Synopsis

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

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

Description

ldap_open initializes a session with an LDAP server and opens a connection in the process. After opening a session, it is necessary to perform a bind function to the server. See ldap_simple_bind(3ldap).

The alternative style of using ldap_init(3ldap) instead of ldap_open is expected to be the preferred mechanism in the latest version of the LDAP API specification, where use of ldap_open may be deprecated.

As parameters, ldap_open 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_open. If more than one server is specified, the servers will be tried in the order given, stopping with the first one to which a successful connection is made.

Upon successfully starting a session, ldap_open 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.

Note that there is a somewhat similar function, ldap_init(3ldap), which is preferred by the latest API specification.

Return values

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

References

Intro(3ldap), ldap_bind(3ldap), ldap_init(3ldap), ldap_perror(3ldap), ldap_simple_bind(3ldap), ldap_unbind(3ldap)


30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.