]> git.sur5r.net Git - openldap/blob - doc/man/man3/ldap_bind.3
improve timeout support (ITS#4157, ITS#4663); manpage cleanup
[openldap] / doc / man / man3 / ldap_bind.3
1 .TH LDAP_BIND 3 "RELEASEDATE" "OpenLDAP LDVERSION"
2 .\" $OpenLDAP$
3 .\" Copyright 1998-2006 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply.  See COPYRIGHT/LICENSE.
5 .SH NAME
6 ldap_bind, ldap_bind_s, ldap_simple_bind, ldap_simple_bind_s, ldap_sasl_bind, ldap_sasl_bind_s, ldap_sasl_interactive_bind_s, ldap_parse_sasl_bind_result, ldap_unbind, ldap_unbind_s, ldap_unbind_ext, ldap_unbind_ext_s, ldap_set_rebind_proc \- LDAP bind routines
7 .SH LIBRARY
8 OpenLDAP LDAP (libldap, -lldap)
9 .SH SYNOPSIS
10 .nf
11 .B #include <ldap.h>
12 .LP
13 .BI "int ldap_bind(LDAP *" ld ", const char *" who ", const char *" cred ","
14 .RS
15 .BI "int " method ");"
16 .RE
17 .LP
18 .BI "int ldap_bind_s(LDAP *" ld ", const char *" who ", const char *" cred ","
19 .RS
20 .BI "int " method ");"
21 .RE
22 .LP
23 .BI "int ldap_simple_bind(LDAP *" ld ", const char *" who ", const char *" passwd ");"
24 .LP
25 .BI "int ldap_simple_bind_s(LDAP *" ld ", const char *" who ", const char *" passwd ");"
26 .LP
27 .BI "int ldap_sasl_bind(LDAP *" ld ", const char *" dn ", const char *" mechanism ","
28 .RS
29 .BI "struct berval *" cred ", LDAPControl *" sctrls "[],"
30 .BI "LDAPControl *" cctrls "[], int *" msgidp ");"
31 .RE
32 .LP
33 .BI "int ldap_sasl_bind_s(LDAP *" ld ", const char *" dn ", const char *" mechanism ","
34 .RS
35 .BI "struct berval *" cred ", LDAPControl *" sctrls "[],"
36 .BI "LDAPControl *" cctrls "[], struct berval **" servercredp ");"
37 .RE
38 .LP
39 .BI "int ldap_parse_sasl_bind_result(LDAP *" ld ", LDAPMessage *" res ","
40 .RS
41 .BI "struct berval **" servercredp ", int " freeit ");"
42 .RE
43 .LP
44 .BI "int ldap_sasl_interactive_bind_s(LDAP *" ld ", const char *" dn ","
45 .RS
46 .BI "const char *" mechs ","
47 .BI "LDAPControl *" sctrls "[], LDAPControl *" cctrls "[],"
48 .BI "unsigned " flags ", LDAP_SASL_INTERACT_PROC *" interact ","
49 .BI "void *" defaults ");"
50 .RE
51 .LP
52 .BI "int ldap_unbind(LDAP *" ld ");"
53 .LP
54 .BI "int ldap_unbind_s(LDAP *" ld ");"
55 .\" .LP
56 .\" .ft B
57 .\" void ldap_set_rebind_proc( ld, rebindproc )
58 .\" .ft
59 .\" LDAP *ld;
60 .\" int (*rebindproc)();
61 .LP
62 .BI "int ldap_unbind_ext(LDAP *" ld ", LDAPControl *" sctrls "[],"
63 .RS
64 .BI LDAPControl *" cctrls "[]);"
65 .RE
66 .LP
67 .BI "int ldap_unbind_ext_s(LDAP *" ld ", LDAPControl *" sctrls "[],"
68 .RS
69 .BI LDAPControl *" cctrls "[]);"
70 .RE
71 .LP
72 .BI "int ldap_set_rebind_proc (LDAP *" ld ", LDAP_REBIND_PROC *" ldap_proc ", void *" params);"
73 .SH DESCRIPTION
74 .LP
75 These routines provide various interfaces to the LDAP bind operation.
76 After an association with an LDAP server is made using
77 .BR ldap_init (3),
78 an LDAP bind operation should be performed before other operations are
79 attempted over the connection.  An LDAP bind is required when using
80 Version 2 of the LDAP protocol; it is optional for Version 3 but is
81 usually needed due to security considerations.
82 .LP
83 There are three types of bind calls, ones providing simple authentication,
84 ones providing SASL authentication, and general routines capable of doing
85 either simple or SASL authentication.
86 .LP
87 .B SASL
88 (Simple Authentication and Security Layer)
89 that can negotiate one of many different kinds of authentication.
90 Both synchronous and asynchronous versions of each variant of the bind
91 call are provided.  All routines
92 take \fIld\fP as their first parameter, as returned from
93 .BR ldap_init (3).
94 .SH SIMPLE AUTHENTICATION
95 The simplest form of the bind call is
96 .BR ldap_simple_bind_s() .
97 It takes the DN to bind as in \fIwho\fP, and the userPassword associated
98 with the entry in \fIpasswd\fP.  It returns an LDAP error indication
99 (see
100 .BR ldap_error (3)).
101 The
102 .B ldap_simple_bind()
103 call is asynchronous,
104 taking the same parameters but only initiating the bind operation and
105 returning the message id of the request it sent.  The result of the
106 operation can be obtained by a subsequent call to
107 .BR ldap_result (3).
108 .SH GENERAL AUTHENTICATION
109 The
110 .B ldap_bind()
111 and
112 .B ldap_bind_s()
113 routines can be used when the
114 authentication method to use needs to be selected at runtime.  They
115 both take an extra \fImethod\fP parameter selecting the authentication
116 method to use.  It should be set to LDAP_AUTH_SIMPLE
117 to select simple authentication.
118 .B ldap_bind()
119 returns the message id of the request it initiates.
120 .B ldap_bind_s()
121 returns an LDAP error indication.
122 .SH SASL AUTHENTICATION
123 Description still under construction...
124 .SH REBINDING
125 .LP
126 The
127 .B ldap_set_rebind_proc
128 function() sets the process to use for binding when an operation returns a
129 referral. This function is used when an application needs to bind to another server
130 in order to follow a referral or search continuation reference.
131 .LP
132 The function takes \fIld\fP, the \fIrebind\fP function, and the \fIparams\fP,
133 the arbitrary data like state information which the client might need to properly rebind.
134 The LDAP_OPT_REFERRALS option in the \fIld\fP must be set to ON for the libraries
135 to use the rebind function. Use the
136 .BR ldap_set_option
137 function to set the value.
138 .LP
139 The rebind function has the following syntax.
140 .B int rebind_function (LDAP *ld, const char *url,int request,ber_int_t   msgid);
141 .LP
142 The \fIld\fP parameter must be used by the application when binding to the
143 referred server if the application wants the libraries to follow the referral.
144 .LP
145 The \fIurl\fP parameter points to the URL referral string received from the LDAP server.
146 The LDAP application can use the 
147 .BR ldap_url_parse()
148 .LP
149 The \fIrequest\fP parameter specifies the request operation that generated the referral. 
150 function to parse the string into its components.
151 .LP
152 The \fImsgid\fP parameter specifies the message ID of the request generating the referral.
153 .LP
154 The LDAP libraries set all the parameters when they call the rebind function. The application
155 should not attempt to free either the ld or the url structures in the rebind function.
156 .LP
157 The application must supply to the rebind function the required authentication information such as,
158 user name, password, and certificates. The rebind function must use a synchronous bind method.
159 .SH UNBINDING
160 The
161 .B ldap_unbind()
162 call is used to unbind from the directory,
163 terminate the current association, and free the resources contained
164 in the \fIld\fP structure.  Once it is called, the connection to
165 the LDAP server is closed, and the \fIld\fP structure is invalid.
166 The
167 .B ldap_unbind_s()
168 call is just another name for
169 .BR ldap_unbind() ;
170 both of these calls are synchronous in nature.
171 .\" .SH RE-BINDING WHILE FOLLOWING REFERRALS
172 .\" The
173 .\" .B ldap_set_rebind_proc()
174 .\" call is used to set a routine that will be called back to obtain bind
175 .\" credentials used when a new server is contacted during the following of
176 .\" an LDAP referral.  Note that this function is only available when the
177 .\" LDAP libraries are compiled with LDAP_REFERRALS defined and is only
178 .\" used when the ld_options field in the LDAP structure has
179 .\" LDAP_OPT_REFERRALS set (this is the default).  If
180 .\" .B ldap_set_rebind_proc()
181 .\" is never called, or if it is called with a NULL \fIrebindproc\fP
182 .\" parameter, an unauthenticated simple LDAP bind will always be done
183 .\" when chasing referrals.
184 .\" .LP
185 .\" \fIrebindproc\fP should be a function that is declared like this:
186 .\" .LP
187 .\" .nf
188 .\" int rebindproc( LDAP *ld, char **whop, char **credp,
189 .\" int *methodp, int freeit );
190 .\" .fi
191 .\" .LP
192 .\" The LDAP library will first call the rebindproc to obtain the
193 .\" referral bind credentials, and the \fIfreeit\fP parameter will be
194 .\" zero.  The \fIwhop\fP, \fIcredp\fP, and \fImethodp\fP should be
195 .\" set as appropriate.  If the rebindproc returns LDAP_SUCCESS, referral
196 .\" processing continues, and the rebindproc will be called a second
197 .\" time with \fIfreeit\fP non-zero to give your application a chance to
198 .\" free any memory allocated in the previous call.
199 .\" .LP
200 .\" If anything but LDAP_SUCCESS is returned by the first call to
201 .\" the rebindproc, then referral processing is stopped and that error code
202 .\" is returned for the original LDAP operation.
203 .LP
204 The
205 .B ldap_unbind_ext()
206 and
207 .B ldap_unbind_ext_s()
208 allows the operations to sepicify  controls.
209 .SH ERRORS
210 Asynchronous routines will return -1 in case of error, setting the
211 \fIld_errno\fP parameter of the \fIld\fP structure.  Synchronous
212 routines return whatever \fIld_errno\fP is set to.  See
213 .BR ldap_error (3)
214 for more information.
215 .SH NOTES
216 If an anonymous bind is sufficient for the application,the rebind process
217 need not be provided. The LDAP libraries with the LDAP_OPT_REFERRALS option
218 set to ON (default value) will automatically follow referrals using an anonymous bind.
219 .LP
220 If the application needs stronger authentication than an anonymous bind,
221 you need to provide a rebind process for that authentication method.
222 The bind method must be synchronous.
223 .SH SEE ALSO
224 .BR ldap (3),
225 .BR ldap_error (3),
226 .BR ldap_open (3),
227 .BR ldap_set_option (3),
228 .BR ldap_url_parse (3)
229 .B RFC 4422
230 (http://www.rfc-editor.org),
231 .B Cyrus SASL
232 (http://asg.web.cmu.edu/sasl/)
233 .SH ACKNOWLEDGEMENTS
234 .B OpenLDAP
235 is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
236 .B OpenLDAP
237 is derived from University of Michigan LDAP 3.3 Release.