#include <lber.h> #include <ldap.h>LDAP
ldap_open(char
host, int port);
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.