1 .TH LDAP_BIND 3 "RELEASEDATE" "OpenLDAP LDVERSION"
3 .\" Copyright 1998-2012 The OpenLDAP Foundation All Rights Reserved.
4 .\" Copying restrictions apply. See COPYRIGHT/LICENSE.
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
8 OpenLDAP LDAP (libldap, \-lldap)
13 .BI "int ldap_bind(LDAP *" ld ", const char *" who ", const char *" cred ","
15 .BI "int " method ");"
18 .BI "int ldap_bind_s(LDAP *" ld ", const char *" who ", const char *" cred ","
20 .BI "int " method ");"
23 .BI "int ldap_simple_bind(LDAP *" ld ", const char *" who ", const char *" passwd ");"
25 .BI "int ldap_simple_bind_s(LDAP *" ld ", const char *" who ", const char *" passwd ");"
27 .BI "int ldap_sasl_bind(LDAP *" ld ", const char *" dn ", const char *" mechanism ","
29 .BI "struct berval *" cred ", LDAPControl *" sctrls "[],"
30 .BI "LDAPControl *" cctrls "[], int *" msgidp ");"
33 .BI "int ldap_sasl_bind_s(LDAP *" ld ", const char *" dn ", const char *" mechanism ","
35 .BI "struct berval *" cred ", LDAPControl *" sctrls "[],"
36 .BI "LDAPControl *" cctrls "[], struct berval **" servercredp ");"
39 .BI "int ldap_parse_sasl_bind_result(LDAP *" ld ", LDAPMessage *" res ","
41 .BI "struct berval **" servercredp ", int " freeit ");"
44 .BI "int ldap_sasl_interactive_bind_s(LDAP *" ld ", const char *" dn ","
46 .BI "const char *" mechs ","
47 .BI "LDAPControl *" sctrls "[], LDAPControl *" cctrls "[],"
48 .BI "unsigned " flags ", LDAP_SASL_INTERACT_PROC *" interact ","
49 .BI "void *" defaults ");"
52 .BI "int ldap_sasl_interactive_bind(LDAP *" ld ", const char *" dn ","
54 .BI "const char *" mechs ","
55 .BI "LDAPControl *" sctrls "[], LDAPControl *" cctrls "[],"
56 .BI "unsigned " flags ", LDAP_SASL_INTERACT_PROC *" interact ","
57 .BI "void *" defaults ", LDAPMessage *" result ","
58 .BI "const char **" rmechp ", int *" msgidp ");"
61 .BI "int (LDAP_SASL_INTERACT_PROC)(LDAP *" ld ", unsigned " flags ", void *" defaults ", void *" sasl_interact ");"
63 .BI "int ldap_unbind(LDAP *" ld ");"
65 .BI "int ldap_unbind_s(LDAP *" ld ");"
67 .BI "int ldap_unbind_ext(LDAP *" ld ", LDAPControl *" sctrls "[],"
69 .BI "LDAPControl *" cctrls "[]);"
72 .BI "int ldap_unbind_ext_s(LDAP *" ld ", LDAPControl *" sctrls "[],"
74 .BI "LDAPControl *" cctrls "[]);"
77 .BI "int ldap_set_rebind_proc (LDAP *" ld ", LDAP_REBIND_PROC *" ldap_proc ", void *" params ");"
79 .BI "int (LDAP_REBIND_PROC)(LDAP *" ld ", LDAP_CONST char *" url ", ber_tag_t " request ", ber_int_t " msgid ", void *" params ");"
82 These routines provide various interfaces to the LDAP bind operation.
83 After an association with an LDAP server is made using
85 an LDAP bind operation should be performed before other operations are
86 attempted over the connection. An LDAP bind is required when using
87 Version 2 of the LDAP protocol; it is optional for Version 3 but is
88 usually needed due to security considerations.
90 There are three types of bind calls, ones providing simple authentication,
91 ones providing SASL authentication, and general routines capable of doing
92 either simple or SASL authentication.
95 (Simple Authentication and Security Layer)
96 can negotiate one of many different kinds of authentication.
97 Both synchronous and asynchronous versions of each variant of the bind
98 call are provided. All routines
99 take \fIld\fP as their first parameter, as returned from
101 .SH SIMPLE AUTHENTICATION
102 The simplest form of the bind call is
103 .BR ldap_simple_bind_s() .
104 It takes the DN to bind as in \fIwho\fP, and the userPassword associated
105 with the entry in \fIpasswd\fP. It returns an LDAP error indication
109 .B ldap_simple_bind()
110 call is asynchronous,
111 taking the same parameters but only initiating the bind operation and
112 returning the message id of the request it sent. The result of the
113 operation can be obtained by a subsequent call to
115 .SH GENERAL AUTHENTICATION
120 routines can be used when the
121 authentication method to use needs to be selected at runtime. They
122 both take an extra \fImethod\fP parameter selecting the authentication
123 method to use. It should be set to LDAP_AUTH_SIMPLE
124 to select simple authentication.
126 returns the message id of the request it initiates.
128 returns an LDAP error indication.
129 .SH SASL AUTHENTICATION
130 For SASL binds the server always ignores any provided DN, so the
132 parameter should always be NULL.
133 .BR ldap_sasl_bind_s ()
134 sends a single SASL bind request with the given SASL
136 and credentials in the
138 parameter. The format of the credentials depends on the particular
139 SASL mechanism in use. For mechanisms that provide mutual authentication
140 the server's credentials will be returned in the
143 The routine returns an LDAP error indication (see
146 .BR ldap_sasl_bind ()
147 call is asynchronous, taking the same parameters but only sending the
148 request and returning the message id of the request it sent. The result of
149 the operation can be obtained by a subsequent
152 The result must be additionally parsed by
153 .BR ldap_parse_sasl_bind_result ()
154 to obtain any server credentials sent from the server.
156 Many SASL mechanisms require multiple message exchanges to perform a
157 complete authentication. Applications should generally use
158 .BR ldap_sasl_interactive_bind_s ()
159 rather than calling the basic
160 .BR ldap_sasl_bind ()
161 functions directly. The
163 parameter should contain a space-separated list of candidate mechanisms
164 to use. If this parameter is NULL or empty the library will query
165 the supportedSASLMechanisms attribute from the server's rootDSE
166 for the list of SASL mechanisms the server supports. The
168 parameter controls the interaction used to retrieve any necessary
169 SASL authentication parameters and should be one of:
172 use defaults if available, prompt otherwise
174 LDAP_SASL_INTERACTIVE
182 function uses the provided
184 to handle requests from the SASL library for particular authentication
185 parameters. There is no defined format for the
188 it is up to the caller to use whatever format is appropriate for the
194 parameter comes from the underlying SASL library. When used with Cyrus SASL
197 structures. The Cyrus SASL library will prompt for a variety of inputs,
201 the realm for the authentication attempt
204 the username to authenticate
207 the password for the provided username
210 the username to use for proxy authorization
213 generic prompt for input with input echoing disabled
216 generic prompt for input with input echoing enabled
219 indicates the end of the array of prompts
221 See the Cyrus SASL documentation for more details.
223 Applications which need to manage connections asynchronously may use
224 .BR ldap_sasl_interactive_bind ()
225 instead of the synchronous version.
226 A valid mechs parameter must be supplied, otherwise the library will
227 be forced to query the server for a list of supported mechanisms,
228 and this query will be performed synchronously.
229 The other parameters are the same as
230 for the synchronous function, with three additional parameters.
231 The actual SASL mechanism that was used, and the message ID for use
234 will be returned in rmechp and msgidp, respectively.
235 The value in rmechp must not be modified by the caller and must be
236 passed back on each subsequent call. The message obtained from
238 must be passed in the result parameter.
239 This parameter must be NULL when initiating a new Bind. The caller
240 must free the result message after each call using
243 .BR ldap_sasl_interactive_bind ()
244 function returns an LDAP result code. If the code is
245 LDAP_SASL_BIND_IN_PROGRESS then the Bind is not complete yet, and
246 this function must be called again with the next result from the server.
250 .B ldap_set_rebind_proc
251 function() sets the process to use for binding when an operation returns a
252 referral. This function is used when an application needs to bind to another server
253 in order to follow a referral or search continuation reference.
255 The function takes \fIld\fP, the \fIrebind\fP function, and the \fIparams\fP,
256 the arbitrary data like state information which the client might need to properly rebind.
257 The LDAP_OPT_REFERRALS option in the \fIld\fP must be set to ON for the libraries
258 to use the rebind function. Use the
260 function to set the value.
262 The rebind function parameters are as follows:
264 The \fIld\fP parameter must be used by the application when binding to the
265 referred server if the application wants the libraries to follow the referral.
267 The \fIurl\fP parameter points to the URL referral string received from the LDAP server.
268 The LDAP application can use the
269 .BR ldap_url_parse (3)
270 function to parse the string into its components.
272 The \fIrequest\fP parameter specifies the type of request that generated the referral.
274 The \fImsgid\fP parameter specifies the message ID of the request generating the referral.
276 The \fIparams\fP parameter is the same value as passed originally to the
277 .BR ldap_set_rebind_proc ()
280 The LDAP libraries set all the parameters when they call the rebind function. The application
281 should not attempt to free either the ld or the url structures in the rebind function.
283 The application must supply to the rebind function the required authentication information such as,
284 user name, password, and certificates. The rebind function must use a synchronous bind method.
288 call is used to unbind from the directory,
289 terminate the current association, and free the resources contained
290 in the \fIld\fP structure. Once it is called, the connection to
291 the LDAP server is closed, and the \fIld\fP structure is invalid.
294 call is just another name for
296 both of these calls are synchronous in nature.
301 .B ldap_unbind_ext_s()
302 allows the operations to specify controls.
304 Asynchronous routines will return \-1 in case of error, setting the
305 \fIld_errno\fP parameter of the \fIld\fP structure. Synchronous
306 routines return whatever \fIld_errno\fP is set to. See
308 for more information.
310 If an anonymous bind is sufficient for the application, the rebind process
311 need not be provided. The LDAP libraries with the LDAP_OPT_REFERRALS option
312 set to ON (default value) will automatically follow referrals using an anonymous bind.
314 If the application needs stronger authentication than an anonymous bind,
315 you need to provide a rebind process for that authentication method.
316 The bind method must be synchronous.
321 .BR ldap_set_option (3),
322 .BR ldap_url_parse (3)
324 (http://www.rfc-editor.org),
326 (http://asg.web.cmu.edu/sasl/)