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