]> git.sur5r.net Git - openldap/blob - doc/man/man3/ldap_open.3
clarify field description in rewriteRule statement
[openldap] / doc / man / man3 / ldap_open.3
1 .TH LDAP_OPEN 3 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" $OpenLDAP$
3 .\" Copyright 1998-2003 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
5 .SH NAME
6 ldap_init, 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 .SH DESCRIPTION
26 .LP
27 .B ldap_open()
28 opens a connection to an LDAP server and allocates an LDAP
29 structure which is used to identify
30 the connection and to maintain per-connection information.
31 .B ldap_init()
32 allocates an LDAP structure but does not open an initial connection.  One
33 of these two routines must be called before any operations are attempted.
34 .LP
35 .B ldap_open()
36 takes \fIhost\fP, the hostname on which the LDAP server is
37 running, and \fIport\fP, the port number to which to connect.  If the default
38 IANA-assigned port of 389 is desired, LDAP_PORT should be specified for
39 \fIport\fP.  The \fIhost\fP parameter may contain a blank-separated list
40 of hosts to try to connect to, and each host may optionally by of the form
41 \fIhost:port\fP.  If present, the \fI:port\fP overrides the \fIport\fP
42 parameter to
43 .BR ldap_open() .
44 Upon successfully making a connection to an
45 LDAP server,
46 .B ldap_open()
47 returns a pointer to an LDAP structure (defined below), which
48 should be passed to subsequent calls to
49 .BR ldap_bind() ,
50 .BR ldap_search() ,
51 etc. Certain fields in the LDAP structure can be set to indicate size limit,
52 time limit, and how aliases are handled during operations.  See <ldap.h>
53 for more details.
54 .LP
55 .nf
56 .ft tt
57         typedef struct ldap {
58                 /* ... other stuff you should not mess with ... */
59                 char            ld_lberoptions;
60                 int             ld_deref;
61         #define LDAP_DEREF_NEVER        0
62         #define LDAP_DEREF_SEARCHING    1
63         #define LDAP_DEREF_FINDING      2
64         #define LDAP_DEREF_ALWAYS       3
65                 int             ld_timelimit;
66                 int             ld_sizelimit;
67         #define LDAP_NO_LIMIT           0
68                 int             ld_errno;
69                 char            *ld_error;
70                 char            *ld_matched;
71                 int             ld_refhoplimit;
72                 unsigned long   ld_options;
73         #define LDAP_OPT_REFERRALS      0x00000002 /* set by default */
74         #define LDAP_OPT_RESTART        0x00000004
75                 /* ... other stuff you should not mess with ... */
76         } LDAP;
77 .ft
78 .fi
79 .LP
80 .B
81 ldap_init()
82 acts just like
83 .BR ldap_open() ,
84 but does not open a connection
85 to the LDAP server.  The actual connection open will occur when the
86 first operation is attempted.  At this time,
87 .B ldap_init()
88 is preferred.  
89 .B ldap_open() will be depreciated in a later release.
90 .SH ERRORS
91 If an error occurs, these routines will return NULL and errno should be
92 set appropriately.
93 .SH OPTIONS
94 Options that affect a particular LDAP instance may be set by modifying
95 the \fIld_options\fP field in the LDAP structure.  This field is set
96 to \fILDAP_OPT_REFERRALS\fP in
97 .B ldap_open() and
98 .B ldap_init(),
99 which causes the library to automatically follow referrals
100 to other servers that may be returned in response to an LDAP operation.
101 .LP
102 The other supported option is \fILDAP_OPT_RESTART\fP, which if set will
103 cause the LDAP library to restart the
104 .BR select (2)
105 system call when it is interrupted by the system (i.e., errno is set to
106 EINTR).  This option is not supported on the Macintosh and under MS-DOS.
107 .LP
108 An option can be turned off by clearing the appropriate bit in the
109 \fIld_options\fP field.
110 .SH NOTES
111 There are other elements in the LDAP structure that you should not
112 change. You should not make any assumptions about the order of elements
113 in the LDAP structure.
114 .SH SEE ALSO
115 .BR ldap (3),
116 .BR ldap_bind (3),
117 .BR errno (3)
118 .SH ACKNOWLEDGEMENTS
119 .B OpenLDAP
120 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
121 .B OpenLDAP
122 is derived from University of Michigan LDAP 3.3 Release.