1LDAP_BIND(3)               Library Functions Manual               LDAP_BIND(3)
2
3
4

NAME

6       ldap_bind,     ldap_bind_s,    ldap_simple_bind,    ldap_simple_bind_s,
7       ldap_sasl_bind,     ldap_sasl_bind_s,     ldap_sasl_interactive_bind_s,
8       ldap_parse_sasl_bind_result,         ldap_unbind,        ldap_unbind_s,
9       ldap_unbind_ext, ldap_unbind_ext_s, ldap_set_rebind_proc  -  LDAP  bind
10       routines
11

LIBRARY

13       OpenLDAP LDAP (libldap, -lldap)
14

SYNOPSIS

16       #include <ldap.h>
17
18       int ldap_bind(LDAP *ld, const char *who, const char *cred,
19              int method);
20
21       int ldap_bind_s(LDAP *ld, const char *who, const char *cred,
22              int method);
23
24       int ldap_simple_bind(LDAP *ld, const char *who, const char *passwd);
25
26       int ldap_simple_bind_s(LDAP *ld, const char *who, const char *passwd);
27
28       int ldap_sasl_bind(LDAP *ld, const char *dn, const char *mechanism,
29              struct berval *cred, LDAPControl *sctrls[],
30              LDAPControl *cctrls[], int *msgidp);
31
32       int ldap_sasl_bind_s(LDAP *ld, const char *dn, const char *mechanism,
33              struct berval *cred, LDAPControl *sctrls[],
34              LDAPControl *cctrls[], struct berval **servercredp);
35
36       int ldap_parse_sasl_bind_result(LDAP *ld, LDAPMessage *res,
37              struct berval **servercredp, int freeit);
38
39       int ldap_sasl_interactive_bind_s(LDAP *ld, const char *dn,
40              const char *mechs,
41              LDAPControl *sctrls[], LDAPControl *cctrls[],
42              unsigned flags, LDAP_SASL_INTERACT_PROC *interact,
43              void *defaults);
44
45       int (LDAP_SASL_INTERACT_PROC)(LDAP *ld, unsigned flags, void *defaults, void *sasl_interact);
46
47       int ldap_unbind(LDAP *ld);
48
49       int ldap_unbind_s(LDAP *ld);
50
51       int ldap_unbind_ext(LDAP *ld, LDAPControl *sctrls[],
52              LDAPControl *cctrls[]);
53
54       int ldap_unbind_ext_s(LDAP *ld, LDAPControl *sctrls[],
55              LDAPControl *cctrls[]);
56
57       int ldap_set_rebind_proc (LDAP *ld, LDAP_REBIND_PROC *ldap_proc, void *params);
58
59       int (LDAP_REBIND_PROC)(LDAP *ld, LDAP_CONST char *url, ber_tag_t request, ber_int_t msgid, void *params);
60

DESCRIPTION

62       These  routines  provide various interfaces to the LDAP bind operation.
63       After an association with an LDAP server is made using ldap_init(3), an
64       LDAP  bind  operation  should  be performed before other operations are
65       attempted over the connection.  An LDAP bind  is  required  when  using
66       Version  2  of  the  LDAP protocol; it is optional for Version 3 but is
67       usually needed due to security considerations.
68
69       There are three types of bind calls, ones providing simple  authentica‐
70       tion,  ones providing SASL authentication, and general routines capable
71       of doing either simple or SASL authentication.
72
73       SASL (Simple Authentication and Security Layer) that can negotiate  one
74       of  many different kinds of authentication.  Both synchronous and asyn‐
75       chronous versions of each variant of the bind call are  provided.   All
76       routines   take   ld   as  their  first  parameter,  as  returned  from
77       ldap_init(3).
78

SIMPLE AUTHENTICATION

80       The simplest form of the bind call is ldap_simple_bind_s().   It  takes
81       the  DN  to  bind  as  in who, and the userPassword associated with the
82       entry  in  passwd.   It  returns  an   LDAP   error   indication   (see
83       ldap_error(3)).   The  ldap_simple_bind()  call is asynchronous, taking
84       the same parameters but only initiating the bind operation and  return‐
85       ing the message id of the request it sent.  The result of the operation
86       can be obtained by a subsequent call to ldap_result(3).
87

GENERAL AUTHENTICATION

89       The ldap_bind() and ldap_bind_s() routines can be used when the authen‐
90       tication method to use needs to be selected at runtime.  They both take
91       an extra method parameter selecting the authentication method  to  use.
92       It  should  be set to LDAP_AUTH_SIMPLE to select simple authentication.
93       ldap_bind() returns  the  message  id  of  the  request  it  initiates.
94       ldap_bind_s() returns an LDAP error indication.
95

SASL AUTHENTICATION

97       For  SASL  binds  the  server always ignores any provided DN, so the dn
98       parameter should always be NULL.   ldap_sasl_bind_s()  sends  a  single
99       SASL  bind request with the given SASL mechanism and credentials in the
100       cred parameter. The format of the credentials depends on the particular
101       SASL  mechanism  in use. For mechanisms that provide mutual authentica‐
102       tion the server's credentials  will  be  returned  in  the  servercredp
103       parameter.    The   routine  returns  an  LDAP  error  indication  (see
104       ldap_error(3)).  The ldap_sasl_bind() call is asynchronous, taking  the
105       same  parameters but only sending the request and returning the message
106       id of the request it sent. The result of the operation can be  obtained
107       by  a  subsequent call to ldap_result(3).  The result must be addition‐
108       ally parsed by ldap_parse_sasl_bind_result() to obtain any server  cre‐
109       dentials sent from the server.
110
111       Many  SASL  mechanisms  require multiple message exchanges to perform a
112       complete   authentication.   Applications    should    generally    use
113       ldap_sasl_interactive_bind_s()    rather   than   calling   the   basic
114       ldap_sasl_bind() functions directly. The mechs parameter should contain
115       a  space-separated list of candidate mechanisms to use. If this parame‐
116       ter is NULL or empty the library will query the supportedSASLMechanisms
117       attribute from the server's rootDSE for the list of SASL mechanisms the
118       server supports. The flags parameter controls the interaction  used  to
119       retrieve any necessary SASL authentication parameters and should be one
120       of:
121
122       LDAP_SASL_AUTOMATIC
123              use defaults if available, prompt otherwise
124
125       LDAP_SASL_INTERACTIVE
126              always prompt
127
128       LDAP_SASL_QUIET
129              never prompt
130
131       The interact function uses the provided  defaults  to  handle  requests
132       from  the  SASL library for particular authentication parameters. There
133       is no defined format for the defaults information;  it  is  up  to  the
134       caller  to use whatever format is appropriate for the supplied interact
135       function.  The sasl_interact parameter comes from the  underlying  SASL
136       library.  When used with Cyrus SASL this is an array of sasl_interact_t
137       structures. The Cyrus SASL library will prompt for a variety of inputs,
138       including:
139
140       SASL_CB_GETREALM
141              the realm for the authentication attempt
142
143       SASL_CB_AUTHNAME
144              the username to authenticate
145
146       SASL_CB_PASS
147              the password for the provided username
148
149       SASL_CB_USER
150              the username to use for proxy authorization
151
152       SASL_CB_NOECHOPROMPT
153              generic prompt for input with input echoing disabled
154
155       SASL_CB_ECHOPROMPT
156              generic prompt for input with input echoing enabled
157
158       SASL_CB_LIST_END
159              indicates the end of the array of prompts
160
161       See the Cyrus SASL documentation for more details.
162

REBINDING

164       The ldap_set_rebind_proc function() sets the process to use for binding
165       when an operation returns a referral. This function  is  used  when  an
166       application needs to bind to another server in order to follow a refer‐
167       ral or search continuation reference.
168
169       The function takes ld, the rebind function, and the params,  the  arbi‐
170       trary  data like state information which the client might need to prop‐
171       erly rebind.  The LDAP_OPT_REFERRALS option in the ld must be set to ON
172       for  the  libraries to use the rebind function. Use the ldap_set_option
173       function to set the value.
174
175       The rebind function parameters are as follows:
176
177       The ld parameter must be used by the application when  binding  to  the
178       referred  server  if  the application wants the libraries to follow the
179       referral.
180
181       The url parameter points to the URL referral string received  from  the
182       LDAP  server.  The LDAP application can use the ldap_url_parse(3) func‐
183       tion to parse the string into its components.
184
185       The request parameter specifies the type of request that generated  the
186       referral.
187
188       The  msgid parameter specifies the message ID of the request generating
189       the referral.
190
191       The params parameter is the same value  as  passed  originally  to  the
192       ldap_set_rebind_proc() function.
193
194       The  LDAP  libraries  set  all the parameters when they call the rebind
195       function. The application should not attempt to free either the  ld  or
196       the url structures in the rebind function.
197
198       The application must supply to the rebind function the required authen‐
199       tication information such as, user name,  password,  and  certificates.
200       The rebind function must use a synchronous bind method.
201

UNBINDING

203       The  ldap_unbind() call is used to unbind from the directory, terminate
204       the current association, and free the resources  contained  in  the  ld
205       structure.   Once  it  is  called, the connection to the LDAP server is
206       closed, and the ld structure is invalid.  The ldap_unbind_s()  call  is
207       just  another  name for ldap_unbind(); both of these calls are synchro‐
208       nous in nature.
209
210       The ldap_unbind_ext() and ldap_unbind_ext_s() allows the operations  to
211       specify  controls.
212

ERRORS

214       Asynchronous  routines  will  return  -1  in case of error, setting the
215       ld_errno parameter of the ld structure.   Synchronous  routines  return
216       whatever ld_errno is set to.  See ldap_error(3) for more information.
217

NOTES

219       If  an  anonymous  bind  is  sufficient for the application, the rebind
220       process  need  not  be  provided.   The   LDAP   libraries   with   the
221       LDAP_OPT_REFERRALS  option set to ON (default value) will automatically
222       follow referrals using an anonymous bind.
223
224       If the application needs  stronger  authentication  than  an  anonymous
225       bind,  you  need  to  provide  a rebind process for that authentication
226       method.  The bind method must be synchronous.
227

SEE ALSO

229       ldap(3),     ldap_error(3),      ldap_open(3),      ldap_set_option(3),
230       ldap_url_parse(3)  RFC  4422  (http://www.rfc-editor.org),  Cyrus  SASL
231       (http://asg.web.cmu.edu/sasl/)
232

ACKNOWLEDGEMENTS

234       OpenLDAP Software is developed and maintained by The  OpenLDAP  Project
235       <http://www.openldap.org/>.   OpenLDAP Software is derived from Univer‐
236       sity of Michigan LDAP 3.3 Release.
237
238
239
240OpenLDAP 2.4.23                   2010/06/30                      LDAP_BIND(3)
Impressum