]> git.sur5r.net Git - openldap/blob - doc/man/man3/ldap_open.3
Use soelim to fix .so problem
[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 .SH DESCRIPTION
32 .LP
33 .B ldap_open()
34 opens a connection to an LDAP server and allocates an LDAP
35 structure which is used to identify
36 the connection and to maintain per-connection information.
37 .B ldap_init()
38 allocates an LDAP structure but does not open an initial connection.
39 .B ldap_initialize()
40 allocates an LDAP structure but does not open an initial connection.  One
41 of these three routines must be called before any operations are attempted.
42 .LP
43 .B ldap_open()
44 takes \fIhost\fP, the hostname on which the LDAP server is
45 running, and \fIport\fP, the port number to which to connect.  If the default
46 IANA-assigned port of 389 is desired, LDAP_PORT should be specified for
47 \fIport\fP.  The \fIhost\fP parameter may contain a blank-separated list
48 of hosts to try to connect to, and each host may optionally by of the form
49 \fIhost:port\fP.  If present, the \fI:port\fP overrides the \fIport\fP
50 parameter to
51 .BR ldap_open() .
52 Upon successfully making a connection to an
53 LDAP server,
54 .B ldap_open()
55 returns a pointer to an opaque LDAP structure, which should be passed
56 to subsequent calls to
57 .BR ldap_bind() ,
58 .BR ldap_search() ,
59 etc. Certain fields in the LDAP structure can be set to indicate size limit,
60 time limit, and how aliases are handled during operations; read and write access 
61 to those fields must occur by calling
62 .BR ldap_get_option (3) 
63 and
64 .BR ldap_set_option (3)
65 respectively, whenever possible.
66 .LP
67 .B
68 ldap_init()
69 acts just like
70 .BR ldap_open() ,
71 but does not open a connection
72 to the LDAP server.  The actual connection open will occur when the
73 first operation is attempted.
74 .LP
75 .B ldap_initialize()
76 acts like
77 .BR ldap_init() ,
78 but it returns an integer indicating either success or the failure reason,
79 and it allows to specify details for the connection in the schema portion
80 of the URI.
81 .LP
82 At this time,
83 .B ldap_open()
84 and 
85 .B ldap_init()
86 are deprecated in favor of
87 .BR ldap_initialize() ,
88 essentially because the latter allows to specify a schema in the URI
89 and it explicitly returns an error code.
90 .SH ERRORS
91 If an error occurs,
92 .B ldap_open()
93 and
94 .B ldap_init()
95 will return NULL and errno should be set appropriately.
96 .B ldap_initialize()
97 will directly return the LDAP code associated to the error (or
98 .I LDAP_SUCCESS
99 in case of success);
100 errno should be set as well whenever appropriate.
101 .SH SEE ALSO
102 .BR ldap (3),
103 .BR ldap_bind (3),
104 .BR ldap_get_option (3),
105 .BR ldap_set_option (3),
106 .BR errno (3)
107 .SH ACKNOWLEDGEMENTS
108 .so ../Project