1 /* bind.c - decode an ldap bind operation and pass it to a backend db */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2004 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
31 #include <ac/string.h>
32 #include <ac/socket.h>
37 #include "slapi/slapi.h"
46 BerElement *ber = op->o_ber;
49 struct berval mech = BER_BVNULL;
50 struct berval dn = BER_BVNULL;
55 LDAP_LOG( OPERATION, ENTRY, "do_bind: conn %d\n", op->o_connid, 0, 0 );
57 Debug( LDAP_DEBUG_TRACE, "do_bind\n", 0, 0, 0 );
61 * Force to connection to "anonymous" until bind succeeds.
63 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
64 if ( op->o_conn->c_sasl_bind_in_progress ) {
65 be = op->o_conn->c_authz_backend;
67 if ( op->o_conn->c_dn.bv_len ) {
68 /* log authorization identity demotion */
69 Statslog( LDAP_DEBUG_STATS,
70 "conn=%lu op=%lu BIND anonymous mech=implicit ssf=0\n",
71 op->o_connid, op->o_opid, 0, 0, 0 );
73 connection2anonymous( op->o_conn );
74 if ( op->o_conn->c_sasl_bind_in_progress ) {
75 op->o_conn->c_authz_backend = be;
77 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
78 if ( op->o_dn.bv_val != NULL ) {
79 free( op->o_dn.bv_val );
80 op->o_dn.bv_val = ch_strdup( "" );
83 if ( op->o_ndn.bv_val != NULL ) {
84 free( op->o_ndn.bv_val );
85 op->o_ndn.bv_val = ch_strdup( "" );
90 * Parse the bind request. It looks like this:
92 * BindRequest ::= SEQUENCE {
93 * version INTEGER, -- version
94 * name DistinguishedName, -- dn
95 * authentication CHOICE {
96 * simple [0] OCTET STRING -- passwd
97 * krbv42ldap [1] OCTET STRING
98 * krbv42dsa [2] OCTET STRING
99 * SASL [3] SaslCredentials
103 * SaslCredentials ::= SEQUENCE {
104 * mechanism LDAPString,
105 * credentials OCTET STRING OPTIONAL
109 tag = ber_scanf( ber, "{imt" /*}*/, &version, &dn, &method );
111 if ( tag == LBER_ERROR ) {
113 LDAP_LOG( OPERATION, ERR,
114 "do_bind: conn %d ber_scanf failed\n", op->o_connid, 0, 0 );
116 Debug( LDAP_DEBUG_ANY, "bind: ber_scanf failed\n", 0, 0, 0 );
118 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
119 rs->sr_err = SLAPD_DISCONNECT;
123 op->o_protocol = version;
124 op->orb_method = method;
126 if( op->orb_method != LDAP_AUTH_SASL ) {
127 tag = ber_scanf( ber, /*{*/ "m}", &op->orb_cred );
130 tag = ber_scanf( ber, "{m" /*}*/, &mech );
132 if ( tag != LBER_ERROR ) {
134 tag = ber_peek_tag( ber, &len );
136 if ( tag == LDAP_TAG_LDAPCRED ) {
137 tag = ber_scanf( ber, "m", &op->orb_cred );
139 tag = LDAP_TAG_LDAPCRED;
140 BER_BVZERO( &op->orb_cred );
143 if ( tag != LBER_ERROR ) {
144 tag = ber_scanf( ber, /*{{*/ "}}" );
149 if ( tag == LBER_ERROR ) {
150 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
151 rs->sr_err = SLAPD_DISCONNECT;
155 if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
157 LDAP_LOG( OPERATION, INFO,
158 "do_bind: conn %d get_ctrls failed\n", op->o_connid, 0, 0 );
160 Debug( LDAP_DEBUG_ANY, "do_bind: get_ctrls failed\n", 0, 0, 0 );
165 /* We use the tmpmemctx here because it speeds up normalization.
166 * However, we must dup with regular malloc when storing any
167 * resulting DNs in the op or conn structures.
169 rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
171 if ( rs->sr_err != LDAP_SUCCESS ) {
173 LDAP_LOG( OPERATION, INFO,
174 "do_bind: conn %d invalid dn (%s)\n",
175 op->o_connid, dn.bv_val, 0 );
177 Debug( LDAP_DEBUG_ANY, "bind: invalid dn (%s)\n",
180 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
184 if( op->orb_method == LDAP_AUTH_SASL ) {
186 LDAP_LOG( OPERATION, DETAIL1,
187 "do_sasl_bind: conn %d dn (%s) mech %s\n",
188 op->o_connid, op->o_req_dn.bv_val, mech.bv_val );
190 Debug( LDAP_DEBUG_TRACE, "do_sasl_bind: dn (%s) mech %s\n",
191 op->o_req_dn.bv_val, mech.bv_val, NULL );
196 LDAP_LOG( OPERATION, DETAIL1,
197 "do_bind: version=%ld dn=\"%s\" method=%ld\n",
198 (unsigned long) version, op->o_req_dn.bv_val,
199 (unsigned long) op->orb_method );
201 Debug( LDAP_DEBUG_TRACE,
202 "do_bind: version=%ld dn=\"%s\" method=%ld\n",
203 (unsigned long) version, op->o_req_dn.bv_val,
204 (unsigned long) op->orb_method );
208 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu BIND dn=\"%s\" method=%ld\n",
209 op->o_connid, op->o_opid, op->o_req_dn.bv_val,
210 (unsigned long) op->orb_method, 0 );
212 if ( version < LDAP_VERSION_MIN || version > LDAP_VERSION_MAX ) {
214 LDAP_LOG( OPERATION, INFO,
215 "do_bind: conn %d unknown version = %ld\n",
216 op->o_connid, (unsigned long)version, 0 );
218 Debug( LDAP_DEBUG_ANY, "do_bind: unknown version=%ld\n",
219 (unsigned long) version, 0, 0 );
221 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
222 "requested protocol version not supported" );
225 } else if (!( global_allows & SLAP_ALLOW_BIND_V2 ) &&
226 version < LDAP_VERSION3 )
228 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
229 "historical protocol version requested, use LDAPv3 instead" );
234 * we set connection version regardless of whether bind succeeds or not.
236 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
237 op->o_conn->c_protocol = version;
238 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
240 op->orb_tmp_mech = mech;
242 op->o_bd = frontendDB;
243 rs->sr_err = frontendDB->be_bind( op, rs );
246 if ( rs->sr_err == LDAP_SUCCESS ) {
247 if ( op->orb_method != LDAP_AUTH_SASL ) {
248 ber_dupbv( &op->o_conn->c_authmech, &mech );
250 op->o_conn->c_authtype = op->orb_method;
253 op->o_conn->c_sasl_bindop = NULL;
255 if( op->o_req_dn.bv_val != NULL ) {
256 slap_sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx );
257 BER_BVZERO( &op->o_req_dn );
259 if( op->o_req_ndn.bv_val != NULL ) {
260 slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
261 BER_BVZERO( &op->o_req_ndn );
268 fe_op_bind( Operation *op, SlapReply *rs )
270 struct berval mech = op->orb_tmp_mech;
272 /* check for inappropriate controls */
273 if( get_manageDSAit( op ) == SLAP_CRITICAL_CONTROL ) {
274 send_ldap_error( op, rs,
275 LDAP_UNAVAILABLE_CRITICAL_EXTENSION,
276 "manageDSAit control inappropriate" );
280 /* Set the bindop for the benefit of in-directory SASL lookups */
281 op->o_conn->c_sasl_bindop = op;
283 if ( op->orb_method == LDAP_AUTH_SASL ) {
284 if ( op->o_protocol < LDAP_VERSION3 ) {
286 LDAP_LOG( OPERATION, INFO,
287 "do_bind: conn %d sasl with LDAPv%ld\n",
288 op->o_connid, (unsigned long)op->o_protocol, 0 );
290 Debug( LDAP_DEBUG_ANY, "do_bind: sasl with LDAPv%ld\n",
291 (unsigned long)op->o_protocol, 0, 0 );
293 send_ldap_discon( op, rs,
294 LDAP_PROTOCOL_ERROR, "SASL bind requires LDAPv3" );
295 rs->sr_err = SLAPD_DISCONNECT;
299 if( mech.bv_len == 0 ) {
301 LDAP_LOG( OPERATION, INFO,
302 "do_bind: conn %d no SASL mechanism provided\n",
303 op->o_connid, 0, 0 );
305 Debug( LDAP_DEBUG_ANY,
306 "do_bind: no sasl mechanism provided\n",
309 send_ldap_error( op, rs, LDAP_AUTH_METHOD_NOT_SUPPORTED,
310 "no SASL mechanism provided" );
314 /* check restrictions */
315 if( backend_check_restrictions( op, rs, &mech ) != LDAP_SUCCESS ) {
316 send_ldap_result( op, rs );
320 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
321 if ( op->o_conn->c_sasl_bind_in_progress ) {
322 if( !bvmatch( &op->o_conn->c_sasl_bind_mech, &mech ) ) {
323 /* mechanism changed between bind steps */
324 slap_sasl_reset(op->o_conn);
327 ber_dupbv(&op->o_conn->c_sasl_bind_mech, &mech);
329 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
331 rs->sr_err = slap_sasl_bind( op, rs );
333 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
334 if( rs->sr_err == LDAP_SUCCESS ) {
335 ber_dupbv(&op->o_conn->c_dn, &op->orb_edn);
336 if( op->orb_edn.bv_len != 0 ) {
337 /* edn is always normalized already */
338 ber_dupbv( &op->o_conn->c_ndn, &op->o_conn->c_dn );
340 op->o_tmpfree( op->orb_edn.bv_val, op->o_tmpmemctx );
341 BER_BVZERO( &op->orb_edn );
342 op->o_conn->c_authmech = op->o_conn->c_sasl_bind_mech;
343 BER_BVZERO( &op->o_conn->c_sasl_bind_mech );
344 op->o_conn->c_sasl_bind_in_progress = 0;
346 op->o_conn->c_sasl_ssf = op->orb_ssf;
347 if( op->orb_ssf > op->o_conn->c_ssf ) {
348 op->o_conn->c_ssf = op->orb_ssf;
351 if( op->o_conn->c_dn.bv_len != 0 ) {
352 ber_len_t max = sockbuf_max_incoming_auth;
353 ber_sockbuf_ctrl( op->o_conn->c_sb,
354 LBER_SB_OPT_SET_MAX_INCOMING, &max );
357 /* log authorization identity */
358 Statslog( LDAP_DEBUG_STATS,
359 "conn=%lu op=%lu BIND dn=\"%s\" mech=%s ssf=%d\n",
360 op->o_connid, op->o_opid,
361 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
362 op->o_conn->c_authmech.bv_val, op->orb_ssf );
365 LDAP_LOG( OPERATION, DETAIL1,
366 "do_bind: SASL/%s bind: dn=\"%s\" ssf=%d\n",
367 op->o_conn->c_authmech.bv_val,
368 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
371 Debug( LDAP_DEBUG_TRACE,
372 "do_bind: SASL/%s bind: dn=\"%s\" ssf=%d\n",
373 op->o_conn->c_authmech.bv_val,
374 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
378 } else if ( rs->sr_err == LDAP_SASL_BIND_IN_PROGRESS ) {
379 op->o_conn->c_sasl_bind_in_progress = 1;
382 if ( op->o_conn->c_sasl_bind_mech.bv_val ) {
383 free( op->o_conn->c_sasl_bind_mech.bv_val );
384 BER_BVZERO( &op->o_conn->c_sasl_bind_mech );
386 op->o_conn->c_sasl_bind_in_progress = 0;
392 * Normally post-operation plugins are called only after the
393 * backend operation. Because the front-end performs SASL
394 * binds on behalf of the backend, we'll make a special
395 * exception to call the post-operation plugins after a
399 slapi_int_pblock_set_operation( pb, op );
400 slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)op->o_req_dn.bv_val );
401 slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method );
402 slapi_pblock_set( pb,
403 SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
404 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
405 (void) slapi_int_call_plugins( op->o_bd,
406 SLAPI_PLUGIN_POST_BIND_FN, pb );
408 #endif /* LDAP_SLAPI */
410 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
415 /* Not SASL, cancel any in-progress bind */
416 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
418 if ( op->o_conn->c_sasl_bind_mech.bv_val != NULL ) {
419 free(op->o_conn->c_sasl_bind_mech.bv_val);
420 BER_BVZERO( &op->o_conn->c_sasl_bind_mech );
422 op->o_conn->c_sasl_bind_in_progress = 0;
424 slap_sasl_reset( op->o_conn );
425 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
428 if ( op->orb_method == LDAP_AUTH_SIMPLE ) {
429 ber_str2bv( "SIMPLE", sizeof("SIMPLE")-1, 0, &mech );
430 /* accept "anonymous" binds */
431 if ( op->orb_cred.bv_len == 0 || op->o_req_ndn.bv_len == 0 ) {
432 rs->sr_err = LDAP_SUCCESS;
434 if( op->orb_cred.bv_len &&
435 !( global_allows & SLAP_ALLOW_BIND_ANON_CRED ))
437 /* cred is not empty, disallow */
438 rs->sr_err = LDAP_INVALID_CREDENTIALS;
440 } else if ( op->o_req_ndn.bv_len &&
441 !( global_allows & SLAP_ALLOW_BIND_ANON_DN ))
443 /* DN is not empty, disallow */
444 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
446 "unauthenticated bind (DN with no password) disallowed";
448 } else if ( global_disallows & SLAP_DISALLOW_BIND_ANON ) {
450 rs->sr_err = LDAP_INAPPROPRIATE_AUTH;
451 rs->sr_text = "anonymous bind disallowed";
454 backend_check_restrictions( op, rs, &mech );
458 * we already forced connection to "anonymous",
459 * just need to send success
461 send_ldap_result( op, rs );
463 LDAP_LOG( OPERATION, DETAIL1,
464 "do_bind: conn %d v%d anonymous bind\n",
465 op->o_connid, op->o_protocol, 0 );
467 Debug( LDAP_DEBUG_TRACE, "do_bind: v%d anonymous bind\n",
468 op->o_protocol, 0, 0 );
472 } else if ( global_disallows & SLAP_DISALLOW_BIND_SIMPLE ) {
473 /* disallow simple authentication */
474 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
475 rs->sr_text = "unwilling to perform simple authentication";
477 send_ldap_result( op, rs );
479 LDAP_LOG( OPERATION, INFO,
480 "do_bind: conn %d v%d simple bind(%s) disallowed\n",
481 op->o_connid, op->o_protocol, op->o_req_ndn.bv_val );
483 Debug( LDAP_DEBUG_TRACE,
484 "do_bind: v%d simple bind(%s) disallowed\n",
485 op->o_protocol, op->o_req_ndn.bv_val, 0 );
490 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
491 } else if ( op->orb_method == LDAP_AUTH_KRBV41 ) {
492 if ( global_disallows & SLAP_DISALLOW_BIND_KRBV4 ) {
493 /* disallow krbv4 authentication */
494 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
495 rs->sr_text = "unwilling to perform Kerberos V4 bind";
497 send_ldap_result( op, rs );
500 LDAP_LOG( OPERATION, DETAIL1,
501 "do_bind: conn %d v%d Kerberos V4 (step 1) bind refused\n",
502 op->o_connid, op->o_protocol, 0 );
504 Debug( LDAP_DEBUG_TRACE,
505 "do_bind: v%d Kerberos V4 (step 1) bind refused\n",
506 op->o_protocol, 0, 0 );
510 ber_str2bv( "KRBV4", sizeof("KRBV4")-1, 0, &mech );
512 } else if ( op->orb_method == LDAP_AUTH_KRBV42 ) {
513 rs->sr_err = LDAP_AUTH_METHOD_NOT_SUPPORTED;
514 rs->sr_text = "Kerberos V4 (step 2) bind not supported";
515 send_ldap_result( op, rs );
518 LDAP_LOG( OPERATION, DETAIL1,
519 "do_bind: conn %d v%d Kerberos V4 (step 2) bind refused\n",
520 op->o_connid, op->o_protocol, 0 );
522 Debug( LDAP_DEBUG_TRACE,
523 "do_bind: v%d Kerberos V4 (step 2) bind refused\n",
524 op->o_protocol, 0, 0 );
530 rs->sr_err = LDAP_AUTH_METHOD_NOT_SUPPORTED;
531 rs->sr_text = "unknown authentication method";
533 send_ldap_result( op, rs );
535 LDAP_LOG( OPERATION, INFO,
536 "do_bind: conn %ld v%d unknown authentication method (%ld)\n",
537 op->o_connid, op->o_protocol, op->orb_method );
539 Debug( LDAP_DEBUG_TRACE,
540 "do_bind: v%d unknown authentication method (%ld)\n",
541 op->o_protocol, op->orb_method, 0 );
547 * We could be serving multiple database backends. Select the
548 * appropriate one, or send a referral to our "referral server"
549 * if we don't hold it.
552 if ( (op->o_bd = select_backend( &op->o_req_ndn, 0, 0 )) == NULL ) {
553 if ( default_referral ) {
554 rs->sr_ref = referral_rewrite( default_referral,
555 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
556 if (!rs->sr_ref) rs->sr_ref = default_referral;
558 rs->sr_err = LDAP_REFERRAL;
559 send_ldap_result( op, rs );
561 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
564 /* noSuchObject is not allowed to be returned by bind */
565 rs->sr_err = LDAP_INVALID_CREDENTIALS;
566 send_ldap_result( op, rs );
572 /* check restrictions */
573 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
574 send_ldap_result( op, rs );
581 slapi_int_pblock_set_operation( pb, op );
582 slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)op->o_req_dn.bv_val );
583 slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method );
584 slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
585 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
586 slapi_pblock_set( pb, SLAPI_CONN_DN, (void *)(0) );
588 rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_BIND_FN, pb );
591 LDAP_LOG( OPERATION, INFO,
592 "do_bind: Bind preoperation plugin returned %d\n",
595 Debug(LDAP_DEBUG_TRACE,
596 "do_bind: Bind preoperation plugin returned %d.\n",
601 case SLAPI_BIND_SUCCESS:
602 /* Continue with backend processing */
604 case SLAPI_BIND_FAIL:
605 /* Failure, server sends result */
606 rs->sr_err = LDAP_INVALID_CREDENTIALS;
607 send_ldap_result( op, rs );
610 case SLAPI_BIND_ANONYMOUS:
611 /* SLAPI_BIND_ANONYMOUS is undocumented XXX */
613 /* Authoritative, plugin sent result, or no plugins called. */
614 if ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE,
615 (void *)&rs->sr_err) != 0 )
617 rs->sr_err = LDAP_OTHER;
620 BER_BVZERO( &op->orb_edn );
622 if ( rs->sr_err == LDAP_SUCCESS ) {
623 slapi_pblock_get( pb, SLAPI_CONN_DN,
624 (void *)&op->orb_edn.bv_val );
625 if ( BER_BVISNULL( &op->orb_edn ) ) {
627 /* No plugins were called; continue. */
631 op->orb_edn.bv_len = strlen( op->orb_edn.bv_val );
633 rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn,
634 &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
635 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
636 ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn);
637 ber_dupbv(&op->o_conn->c_ndn, &op->o_req_ndn);
638 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
639 BER_BVZERO( &op->o_req_dn );
640 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
641 BER_BVZERO( &op->o_req_ndn );
642 if ( op->o_conn->c_dn.bv_len != 0 ) {
643 ber_len_t max = sockbuf_max_incoming_auth;
644 ber_sockbuf_ctrl( op->o_conn->c_sb,
645 LBER_SB_OPT_SET_MAX_INCOMING, &max );
647 /* log authorization identity */
648 Statslog( LDAP_DEBUG_STATS,
649 "conn=%lu op=%lu BIND dn=\"%s\" mech=%s (SLAPI) ssf=0\n",
650 op->o_connid, op->o_opid,
651 op->o_conn->c_dn.bv_val
652 ? op->o_conn->c_dn.bv_val : "<empty>",
654 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
660 #endif /* LDAP_SLAPI */
662 if( op->o_bd->be_bind ) {
663 rs->sr_err = (op->o_bd->be_bind)( op, rs );
665 if ( rs->sr_err == 0 ) {
666 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
668 if( op->o_conn->c_authz_backend == NULL ) {
669 op->o_conn->c_authz_backend = op->o_bd;
672 /* be_bind returns regular/global edn */
673 if( op->orb_edn.bv_len ) {
674 op->o_conn->c_dn = op->orb_edn;
676 ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn);
679 ber_dupbv( &op->o_conn->c_ndn, &op->o_req_ndn );
681 if( op->o_conn->c_dn.bv_len != 0 ) {
682 ber_len_t max = sockbuf_max_incoming_auth;
683 ber_sockbuf_ctrl( op->o_conn->c_sb,
684 LBER_SB_OPT_SET_MAX_INCOMING, &max );
687 /* log authorization identity */
688 Statslog( LDAP_DEBUG_STATS,
689 "conn=%lu op=%lu BIND dn=\"%s\" mech=%s ssf=0\n",
690 op->o_connid, op->o_opid,
691 op->o_conn->c_dn.bv_val, mech.bv_val, 0 );
694 LDAP_LOG( OPERATION, DETAIL1,
695 "do_bind: v%d bind: \"%s\" to \"%s\" \n",
696 op->o_protocol, op->o_conn->c_dn.bv_val, op->o_conn->c_dn.bv_val );
698 Debug( LDAP_DEBUG_TRACE,
699 "do_bind: v%d bind: \"%s\" to \"%s\"\n",
700 op->o_protocol, op->o_req_dn.bv_val, op->o_conn->c_dn.bv_val );
703 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
705 /* send this here to avoid a race condition */
706 send_ldap_result( op, rs );
708 } else if (op->orb_edn.bv_val != NULL) {
709 free( op->orb_edn.bv_val );
713 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
714 "operation not supported within naming context" );
719 slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb ) < 0 )
722 LDAP_LOG( OPERATION, INFO,
723 "do_bind: Bind postoperation plugins failed\n",
726 Debug(LDAP_DEBUG_TRACE,
727 "do_bind: Bind postoperation plugins failed.\n",
731 #endif /* LDAP_SLAPI */