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