]> git.sur5r.net Git - openldap/blob - doc/man/man3/ldap_open.3
ITS#4707 added ldap_init_fd()
[openldap] / doc / man / man3 / ldap_open.3
1 .TH LDAP_OPEN 3 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" $OpenLDAP$
3 .\" Copyright 1998-2007 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
5 .SH NAME
6 ldap_init, ldap_initialize, ldap_open \- Initialize the LDAP library and open a connection to an LDAP server
7 .SH LIBRARY
8 OpenLDAP LDAP (libldap, -lldap)
9 .SH SYNOPSIS
10 .nf
11 .ft B
12 #include <ldap.h>
13 .LP
14 .ft B
15 LDAP *ldap_open(host, port)
16 .ft
17 char *host;
18 int port;
19 .LP
20 .ft B
21 LDAP *ldap_init(host, port)
22 .ft
23 char *host;
24 int port;
25 .LP
26 .ft B
27 int ldap_initialize(ldp, uri)
28 .ft
29 LDAP **ldp;
30 char *uri;
31 .LP
32 .ft B
33 #include <ldap_pvt.h>
34 .LP
35 .ft B
36 int ldap_init_fd(fd, proto, uri, ldp)
37 .ft
38 ber_socket_t fd;
39 int proto;
40 char *uri;
41 LDAP **ldp;
42 .SH DESCRIPTION
43 .LP
44 .B ldap_open()
45 opens a connection to an LDAP server and allocates an LDAP
46 structure which is used to identify
47 the connection and to maintain per-connection information.
48 .B ldap_init()
49 allocates an LDAP structure but does not open an initial connection.
50 .B ldap_initialize()
51 allocates an LDAP structure but does not open an initial connection.
52 .B ldap_init_fd()
53 allocates an LDAP structure using an existing connection on the
54 provided socket.
55 One
56 of these routines must be called before any operations are attempted.
57 .LP
58 .B ldap_open()
59 takes \fIhost\fP, the hostname on which the LDAP server is
60 running, and \fIport\fP, the port number to which to connect.  If the default
61 IANA-assigned port of 389 is desired, LDAP_PORT should be specified for
62 \fIport\fP.  The \fIhost\fP parameter may contain a blank-separated list
63 of hosts to try to connect to, and each host may optionally by of the form
64 \fIhost:port\fP.  If present, the \fI:port\fP overrides the \fIport\fP
65 parameter to
66 .BR ldap_open() .
67 Upon successfully making a connection to an
68 LDAP server,
69 .B ldap_open()
70 returns a pointer to an opaque LDAP structure, which should be passed
71 to subsequent calls to
72 .BR ldap_bind() ,
73 .BR ldap_search() ,
74 etc. Certain fields in the LDAP structure can be set to indicate size limit,
75 time limit, and how aliases are handled during operations; read and write access 
76 to those fields must occur by calling
77 .BR ldap_get_option (3) 
78 and
79 .BR ldap_set_option (3)
80 respectively, whenever possible.
81 .LP
82 .B
83 ldap_init()
84 acts just like
85 .BR ldap_open() ,
86 but does not open a connection
87 to the LDAP server.  The actual connection open will occur when the
88 first operation is attempted.
89 .LP
90 .B ldap_initialize()
91 acts like
92 .BR ldap_init() ,
93 but it returns an integer indicating either success or the failure reason,
94 and it allows to specify details for the connection in the schema portion
95 of the URI.
96 .LP
97 At this time,
98 .B ldap_open()
99 and 
100 .B ldap_init()
101 are deprecated in favor of
102 .BR ldap_initialize() ,
103 essentially because the latter allows to specify a schema in the URI
104 and it explicitly returns an error code.
105 .LP
106 .B ldap_init_fd()
107 allows an LDAP structure to be initialized using an already-opened
108 connection. The
109 .I proto
110 parameter should be one of
111 .BR LDAP_PROTO_TCP ,
112 .BR LDAP_PROTO_UDP ,
113 or 
114 .B LDAP_PROTO_IPC
115 for a connection using TCP, UDP, or IPC, respectively. The value
116 .B LDAP_PROTO_EXT
117 may also be specified if user-supplied sockbuf handlers are going to
118 be used. The
119 .I uri
120 parameter may optionally be provided for informational purposes.
121
122 .SH ERRORS
123 If an error occurs,
124 .B ldap_open()
125 and
126 .B ldap_init()
127 will return NULL and errno should be set appropriately.
128 .B ldap_initialize()
129 and
130 .B ldap_init_fd()
131 will directly return the LDAP code associated to the error (or
132 .I LDAP_SUCCESS
133 in case of success);
134 errno should be set as well whenever appropriate.
135 .SH SEE ALSO
136 .BR ldap (3),
137 .BR ldap_bind (3),
138 .BR ldap_get_option (3),
139 .BR ldap_set_option (3),
140 .BR lber-sockbuf (3),
141 .BR errno (3)
142 .SH ACKNOWLEDGEMENTS
143 .so ../Project