1LDAP_OPEN(3)               Library Functions Manual               LDAP_OPEN(3)
2
3
4

NAME

6       ldap_init, ldap_initialize, ldap_open - Initialize the LDAP library and
7       open a connection to an LDAP server
8

LIBRARY

10       OpenLDAP LDAP (libldap, -lldap)
11

SYNOPSIS

13       #include <ldap.h>
14
15       LDAP *ldap_open(host, port)
16       char *host;
17       int port;
18
19       LDAP *ldap_init(host, port)
20       char *host;
21       int port;
22
23       int ldap_initialize(ldp, uri)
24       LDAP **ldp;
25       char *uri;
26
27       #include <ldap_pvt.h>
28
29       int ldap_init_fd(fd, proto, uri, ldp)
30       ber_socket_t fd;
31       int proto;
32       char *uri;
33       LDAP **ldp;
34

DESCRIPTION

36       ldap_open() opens a connection to an LDAP server and allocates an  LDAP
37       structure which is used to identify the connection and to maintain per-
38       connection information.  ldap_init() allocates an  LDAP  structure  but
39       does  not  open  an initial connection.  ldap_initialize() allocates an
40       LDAP structure but does not open an initial connection.  ldap_init_fd()
41       allocates  an  LDAP  structure using an existing connection on the pro‐
42       vided socket.  One of these routines must be called before  any  opera‐
43       tions are attempted.
44
45       ldap_open()  takes  host, the hostname on which the LDAP server is run‐
46       ning, and port, the port number to which to connect.   If  the  default
47       IANA-assigned port of 389 is desired, LDAP_PORT should be specified for
48       port.  The host parameter may contain a blank-separated list  of  hosts
49       to  try  to  connect  to,  and  each host may optionally by of the form
50       host:port.  If present, the  :port  overrides  the  port  parameter  to
51       ldap_open().   Upon successfully making a connection to an LDAP server,
52       ldap_open() returns a pointer to an opaque LDAP structure, which should
53       be  passed to subsequent calls to ldap_bind(), ldap_search(), etc. Cer‐
54       tain fields in the LDAP structure can be set to  indicate  size  limit,
55       time  limit,  and  how  aliases are handled during operations; read and
56       write access to those fields must occur by  calling  ldap_get_option(3)
57       and ldap_set_option(3) respectively, whenever possible.
58
59       ldap_init()  acts just like ldap_open(), but does not open a connection
60       to the LDAP server.  The actual connection open  will  occur  when  the
61       first operation is attempted.
62
63       ldap_initialize()  acts  like  ldap_init(),  but  it returns an integer
64       indicating either success or the failure reason, and it allows to spec‐
65       ify  details  for the connection in the schema portion of the URI.  The
66       uri parameter may be a comma- or whitespace-separated list of URIs con‐
67       taining  only  the  schema,  the host, and the port fields.  Apart from
68       ldap, other (non-standard) recognized values of the  schema  field  are
69       ldaps (LDAP over TLS), ldapi (LDAP over IPC), and cldap (connectionless
70       LDAP).  If other fields are present, the behavior is undefined.
71
72       At this time, ldap_open() and ldap_init() are deprecated  in  favor  of
73       ldap_initialize(),  essentially  because the latter allows to specify a
74       schema in the URI and it explicitly returns an error code.
75
76       ldap_init_fd() allows an LDAP structure  to  be  initialized  using  an
77       already-opened  connection.  The  proto  parameter  should  be  one  of
78       LDAP_PROTO_TCP, LDAP_PROTO_UDP,  or  LDAP_PROTO_IPC  for  a  connection
79       using TCP, UDP, or IPC, respectively. The value LDAP_PROTO_EXT may also
80       be specified if user-supplied sockbuf handlers are going  to  be  used.
81       Note  that  support for UDP is not implemented unless libldap was built
82       with LDAP_CONNECTIONLESS defined.  The uri parameter may optionally  be
83       provided for informational purposes.
84
85       Note:  the first call into the LDAP library also initializes the global
86       options for the library. As such  the  first  call  should  be  single-
87       threaded or otherwise protected to insure that only one call is active.
88       It is recommended that ldap_get_option() or ldap_set_option()  be  used
89       in the program's main thread before any additional threads are created.
90       See ldap_get_option(3).
91
92

ERRORS

94       If an error occurs, ldap_open() and ldap_init() will  return  NULL  and
95       errno    should    be   set   appropriately.    ldap_initialize()   and
96       ldap_init_fd() will directly return the LDAP  code  associated  to  the
97       error (or LDAP_SUCCESS in case of success); errno should be set as well
98       whenever appropriate.
99

SEE ALSO

101       ldap(3), ldap_bind(3),  ldap_get_option(3),  ldap_set_option(3),  lber-
102       sockbuf(3), errno(3)
103

ACKNOWLEDGEMENTS

105       OpenLDAP  Software  is developed and maintained by The OpenLDAP Project
106       <http://www.openldap.org/>.  OpenLDAP Software is derived from  Univer‐
107       sity of Michigan LDAP 3.3 Release.
108
109
110
111OpenLDAP 2.4.23                   2010/06/30                      LDAP_OPEN(3)
Impressum