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 op->orb_cred.bv_val = NULL;
141 op->orb_cred.bv_len = 0;
144 if ( tag != LBER_ERROR ) {
145 tag = ber_scanf( ber, /*{{*/ "}}" );
150 if ( tag == LBER_ERROR ) {
151 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
152 rs->sr_err = SLAPD_DISCONNECT;
156 if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
158 LDAP_LOG( OPERATION, INFO,
159 "do_bind: conn %d get_ctrls failed\n", op->o_connid, 0, 0 );
161 Debug( LDAP_DEBUG_ANY, "do_bind: get_ctrls failed\n", 0, 0, 0 );
166 /* We use the tmpmemctx here because it speeds up normalization.
167 * However, we must dup with regular malloc when storing any
168 * resulting DNs in the op or conn structures.
170 rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
172 if ( rs->sr_err != LDAP_SUCCESS ) {
174 LDAP_LOG( OPERATION, INFO,
175 "do_bind: conn %d invalid dn (%s)\n",
176 op->o_connid, dn.bv_val, 0 );
178 Debug( LDAP_DEBUG_ANY, "bind: invalid dn (%s)\n",
181 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
185 if( op->orb_method == LDAP_AUTH_SASL ) {
187 LDAP_LOG( OPERATION, DETAIL1,
188 "do_sasl_bind: conn %d dn (%s) mech %s\n",
189 op->o_connid, op->o_req_dn.bv_val, mech.bv_val );
191 Debug( LDAP_DEBUG_TRACE, "do_sasl_bind: dn (%s) mech %s\n",
192 op->o_req_dn.bv_val, mech.bv_val, NULL );
197 LDAP_LOG( OPERATION, DETAIL1,
198 "do_bind: version=%ld dn=\"%s\" method=%ld\n",
199 (unsigned long) version, op->o_req_dn.bv_val,
200 (unsigned long) op->orb_method );
202 Debug( LDAP_DEBUG_TRACE,
203 "do_bind: version=%ld dn=\"%s\" method=%ld\n",
204 (unsigned long) version, op->o_req_dn.bv_val,
205 (unsigned long) op->orb_method );
209 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu BIND dn=\"%s\" method=%ld\n",
210 op->o_connid, op->o_opid, op->o_req_dn.bv_val,
211 (unsigned long) op->orb_method, 0 );
213 if ( version < LDAP_VERSION_MIN || version > LDAP_VERSION_MAX ) {
215 LDAP_LOG( OPERATION, INFO,
216 "do_bind: conn %d unknown version = %ld\n",
217 op->o_connid, (unsigned long)version, 0 );
219 Debug( LDAP_DEBUG_ANY, "do_bind: unknown version=%ld\n",
220 (unsigned long) version, 0, 0 );
222 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
223 "requested protocol version not supported" );
226 } else if (!( global_allows & SLAP_ALLOW_BIND_V2 ) &&
227 version < LDAP_VERSION3 )
229 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
230 "historical protocol version requested, use LDAPv3 instead" );
235 * we set connection version regardless of whether bind succeeds or not.
237 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
238 op->o_conn->c_protocol = version;
239 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
241 /* check for inappropriate controls */
242 if( get_manageDSAit( op ) == SLAP_CRITICAL_CONTROL ) {
243 send_ldap_error( op, rs,
244 LDAP_UNAVAILABLE_CRITICAL_EXTENSION,
245 "manageDSAit control inappropriate" );
249 /* Set the bindop for the benefit of in-directory SASL lookups */
250 op->o_conn->c_sasl_bindop = op;
252 if ( op->orb_method == LDAP_AUTH_SASL ) {
253 if ( version < LDAP_VERSION3 ) {
255 LDAP_LOG( OPERATION, INFO,
256 "do_bind: conn %d sasl with LDAPv%ld\n",
257 op->o_connid, (unsigned long)version , 0 );
259 Debug( LDAP_DEBUG_ANY, "do_bind: sasl with LDAPv%ld\n",
260 (unsigned long) version, 0, 0 );
262 send_ldap_discon( op, rs,
263 LDAP_PROTOCOL_ERROR, "SASL bind requires LDAPv3" );
264 rs->sr_err = SLAPD_DISCONNECT;
268 if( mech.bv_len == 0 ) {
270 LDAP_LOG( OPERATION, INFO,
271 "do_bind: conn %d no SASL mechanism provided\n",
272 op->o_connid, 0, 0 );
274 Debug( LDAP_DEBUG_ANY,
275 "do_bind: no sasl mechanism provided\n",
278 send_ldap_error( op, rs, LDAP_AUTH_METHOD_NOT_SUPPORTED,
279 "no SASL mechanism provided" );
283 /* check restrictions */
284 if( backend_check_restrictions( op, rs, &mech ) != LDAP_SUCCESS ) {
285 send_ldap_result( op, rs );
289 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
290 if ( op->o_conn->c_sasl_bind_in_progress ) {
291 if( !bvmatch( &op->o_conn->c_sasl_bind_mech, &mech ) ) {
292 /* mechanism changed between bind steps */
293 slap_sasl_reset(op->o_conn);
296 ber_dupbv(&op->o_conn->c_sasl_bind_mech, &mech);
298 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
300 rs->sr_err = slap_sasl_bind( op, rs );
302 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
303 if( rs->sr_err == LDAP_SUCCESS ) {
304 ber_dupbv(&op->o_conn->c_dn, &op->orb_edn);
305 if( op->orb_edn.bv_len != 0 ) {
306 /* edn is always normalized already */
307 ber_dupbv( &op->o_conn->c_ndn, &op->o_conn->c_dn );
309 op->o_tmpfree( op->orb_edn.bv_val, op->o_tmpmemctx );
310 BER_BVZERO( &op->orb_edn );
311 op->o_conn->c_authmech = op->o_conn->c_sasl_bind_mech;
312 BER_BVZERO( &op->o_conn->c_sasl_bind_mech );
313 op->o_conn->c_sasl_bind_in_progress = 0;
315 op->o_conn->c_sasl_ssf = op->orb_ssf;
316 if( op->orb_ssf > op->o_conn->c_ssf ) {
317 op->o_conn->c_ssf = op->orb_ssf;
320 if( op->o_conn->c_dn.bv_len != 0 ) {
321 ber_len_t max = sockbuf_max_incoming_auth;
322 ber_sockbuf_ctrl( op->o_conn->c_sb,
323 LBER_SB_OPT_SET_MAX_INCOMING, &max );
326 /* log authorization identity */
327 Statslog( LDAP_DEBUG_STATS,
328 "conn=%lu op=%lu BIND dn=\"%s\" mech=%s ssf=%d\n",
329 op->o_connid, op->o_opid,
330 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
331 op->o_conn->c_authmech.bv_val, op->orb_ssf );
334 LDAP_LOG( OPERATION, DETAIL1,
335 "do_bind: SASL/%s bind: dn=\"%s\" ssf=%d\n",
336 op->o_conn->c_authmech.bv_val,
337 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
340 Debug( LDAP_DEBUG_TRACE,
341 "do_bind: SASL/%s bind: dn=\"%s\" ssf=%d\n",
342 op->o_conn->c_authmech.bv_val,
343 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
347 } else if ( rs->sr_err == LDAP_SASL_BIND_IN_PROGRESS ) {
348 op->o_conn->c_sasl_bind_in_progress = 1;
351 if ( op->o_conn->c_sasl_bind_mech.bv_val ) {
352 free( op->o_conn->c_sasl_bind_mech.bv_val );
353 op->o_conn->c_sasl_bind_mech.bv_val = NULL;
354 op->o_conn->c_sasl_bind_mech.bv_len = 0;
356 op->o_conn->c_sasl_bind_in_progress = 0;
362 * Normally post-operation plugins are called only after the
363 * backend operation. Because the front-end performs SASL
364 * binds on behalf of the backend, we'll make a special
365 * exception to call the post-operation plugins after a
369 slapi_int_pblock_set_operation( pb, op );
370 slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
371 slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method );
372 slapi_pblock_set( pb,
373 SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
374 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
375 (void) slapi_int_call_plugins( op->o_bd,
376 SLAPI_PLUGIN_POST_BIND_FN, pb );
378 #endif /* LDAP_SLAPI */
380 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
385 /* Not SASL, cancel any in-progress bind */
386 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
388 if ( op->o_conn->c_sasl_bind_mech.bv_val != NULL ) {
389 free(op->o_conn->c_sasl_bind_mech.bv_val);
390 op->o_conn->c_sasl_bind_mech.bv_val = NULL;
391 op->o_conn->c_sasl_bind_mech.bv_len = 0;
393 op->o_conn->c_sasl_bind_in_progress = 0;
395 slap_sasl_reset( op->o_conn );
396 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
399 if ( op->orb_method == LDAP_AUTH_SIMPLE ) {
400 ber_str2bv( "SIMPLE", sizeof("SIMPLE")-1, 0, &mech );
401 /* accept "anonymous" binds */
402 if ( op->orb_cred.bv_len == 0 || op->o_req_ndn.bv_len == 0 ) {
403 rs->sr_err = LDAP_SUCCESS;
405 if( op->orb_cred.bv_len &&
406 !( global_allows & SLAP_ALLOW_BIND_ANON_CRED ))
408 /* cred is not empty, disallow */
409 rs->sr_err = LDAP_INVALID_CREDENTIALS;
411 } else if ( op->o_req_ndn.bv_len &&
412 !( global_allows & SLAP_ALLOW_BIND_ANON_DN ))
414 /* DN is not empty, disallow */
415 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
417 "unauthenticated bind (DN with no password) disallowed";
419 } else if ( global_disallows & SLAP_DISALLOW_BIND_ANON ) {
421 rs->sr_err = LDAP_INAPPROPRIATE_AUTH;
422 rs->sr_text = "anonymous bind disallowed";
425 backend_check_restrictions( op, rs, &mech );
429 * we already forced connection to "anonymous",
430 * just need to send success
432 send_ldap_result( op, rs );
434 LDAP_LOG( OPERATION, DETAIL1,
435 "do_bind: conn %d v%d anonymous bind\n",
436 op->o_connid, version , 0 );
438 Debug( LDAP_DEBUG_TRACE, "do_bind: v%d anonymous bind\n",
443 } else if ( global_disallows & SLAP_DISALLOW_BIND_SIMPLE ) {
444 /* disallow simple authentication */
445 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
446 rs->sr_text = "unwilling to perform simple authentication";
448 send_ldap_result( op, rs );
450 LDAP_LOG( OPERATION, INFO,
451 "do_bind: conn %d v%d simple bind(%s) disallowed\n",
452 op->o_connid, version, op->o_req_ndn.bv_val );
454 Debug( LDAP_DEBUG_TRACE,
455 "do_bind: v%d simple bind(%s) disallowed\n",
456 version, op->o_req_ndn.bv_val, 0 );
461 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
462 } else if ( op->orb_method == LDAP_AUTH_KRBV41 ) {
463 if ( global_disallows & SLAP_DISALLOW_BIND_KRBV4 ) {
464 /* disallow krbv4 authentication */
465 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
466 rs->sr_text = "unwilling to perform Kerberos V4 bind";
468 send_ldap_result( op, rs );
471 LDAP_LOG( OPERATION, DETAIL1,
472 "do_bind: conn %d v%d Kerberos V4 (step 1) bind refused\n",
473 op->o_connid, version , 0 );
475 Debug( LDAP_DEBUG_TRACE,
476 "do_bind: v%d Kerberos V4 (step 1) bind refused\n",
481 ber_str2bv( "KRBV4", sizeof("KRBV4")-1, 0, &mech );
483 } else if ( op->orb_method == LDAP_AUTH_KRBV42 ) {
484 rs->sr_err = LDAP_AUTH_METHOD_NOT_SUPPORTED;
485 rs->sr_text = "Kerberos V4 (step 2) bind not supported";
486 send_ldap_result( op, rs );
489 LDAP_LOG( OPERATION, DETAIL1,
490 "do_bind: conn %d v%d Kerberos V4 (step 2) bind refused\n",
491 op->o_connid, version , 0 );
493 Debug( LDAP_DEBUG_TRACE,
494 "do_bind: v%d Kerberos V4 (step 2) bind refused\n",
501 rs->sr_err = LDAP_AUTH_METHOD_NOT_SUPPORTED;
502 rs->sr_text = "unknown authentication method";
504 send_ldap_result( op, rs );
506 LDAP_LOG( OPERATION, INFO,
507 "do_bind: conn %ld v%d unknown authentication method (%ld)\n",
508 op->o_connid, version, op->orb_method );
510 Debug( LDAP_DEBUG_TRACE,
511 "do_bind: v%d unknown authentication method (%ld)\n",
512 version, op->orb_method, 0 );
518 * We could be serving multiple database backends. Select the
519 * appropriate one, or send a referral to our "referral server"
520 * if we don't hold it.
523 if ( (op->o_bd = select_backend( &op->o_req_ndn, 0, 0 )) == NULL ) {
524 if ( default_referral ) {
525 rs->sr_ref = referral_rewrite( default_referral,
526 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
527 if (!rs->sr_ref) rs->sr_ref = default_referral;
529 rs->sr_err = LDAP_REFERRAL;
530 send_ldap_result( op, rs );
532 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
535 /* noSuchObject is not allowed to be returned by bind */
536 rs->sr_err = LDAP_INVALID_CREDENTIALS;
537 send_ldap_result( op, rs );
543 /* check restrictions */
544 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
545 send_ldap_result( op, rs );
552 slapi_int_pblock_set_operation( pb, op );
553 slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
554 slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method );
555 slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
556 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
557 slapi_pblock_set( pb, SLAPI_CONN_DN, (void *)(0) );
559 rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_BIND_FN, pb );
562 LDAP_LOG( OPERATION, INFO,
563 "do_bind: Bind preoperation plugin returned %d\n",
566 Debug(LDAP_DEBUG_TRACE,
567 "do_bind: Bind preoperation plugin returned %d.\n",
572 case SLAPI_BIND_SUCCESS:
573 /* Continue with backend processing */
575 case SLAPI_BIND_FAIL:
576 /* Failure, server sends result */
577 rs->sr_err = LDAP_INVALID_CREDENTIALS;
578 send_ldap_result( op, rs );
581 case SLAPI_BIND_ANONYMOUS:
582 /* SLAPI_BIND_ANONYMOUS is undocumented XXX */
584 /* Authoritative, plugin sent result, or no plugins called. */
585 if ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE,
586 (void *)&rs->sr_err) != 0 )
588 rs->sr_err = LDAP_OTHER;
591 op->orb_edn.bv_val = NULL;
592 op->orb_edn.bv_len = 0;
594 if ( rs->sr_err == LDAP_SUCCESS ) {
595 slapi_pblock_get( pb, SLAPI_CONN_DN,
596 (void *)&op->orb_edn.bv_val );
597 if ( op->orb_edn.bv_val == NULL ) {
599 /* No plugins were called; continue. */
603 op->orb_edn.bv_len = strlen( op->orb_edn.bv_val );
605 rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn,
606 &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
607 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
608 ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn);
609 ber_dupbv(&op->o_conn->c_ndn, &op->o_req_ndn);
610 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
611 op->o_req_dn.bv_val = NULL;
612 op->o_req_dn.bv_len = 0;
613 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
614 op->o_req_ndn.bv_val = NULL;
615 op->o_req_ndn.bv_len = 0;
616 if ( op->o_conn->c_dn.bv_len != 0 ) {
617 ber_len_t max = sockbuf_max_incoming_auth;
618 ber_sockbuf_ctrl( op->o_conn->c_sb,
619 LBER_SB_OPT_SET_MAX_INCOMING, &max );
621 /* log authorization identity */
622 Statslog( LDAP_DEBUG_STATS,
623 "conn=%lu op=%lu BIND dn=\"%s\" mech=%s (SLAPI) ssf=0\n",
624 op->o_connid, op->o_opid,
625 op->o_conn->c_dn.bv_val
626 ? op->o_conn->c_dn.bv_val : "<empty>",
628 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
634 #endif /* LDAP_SLAPI */
636 if( op->o_bd->be_bind ) {
637 rs->sr_err = (op->o_bd->be_bind)( op, rs );
639 if ( rs->sr_err == 0 ) {
640 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
642 if( op->o_conn->c_authz_backend == NULL ) {
643 op->o_conn->c_authz_backend = op->o_bd;
646 /* be_bind returns regular/global edn */
647 if( op->orb_edn.bv_len ) {
648 op->o_conn->c_dn = op->orb_edn;
650 ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn);
653 ber_dupbv( &op->o_conn->c_ndn, &op->o_req_ndn );
655 if( op->o_conn->c_dn.bv_len != 0 ) {
656 ber_len_t max = sockbuf_max_incoming_auth;
657 ber_sockbuf_ctrl( op->o_conn->c_sb,
658 LBER_SB_OPT_SET_MAX_INCOMING, &max );
661 /* log authorization identity */
662 Statslog( LDAP_DEBUG_STATS,
663 "conn=%lu op=%lu BIND dn=\"%s\" mech=%s ssf=0\n",
664 op->o_connid, op->o_opid,
665 op->o_conn->c_dn.bv_val, mech.bv_val, 0 );
668 LDAP_LOG( OPERATION, DETAIL1,
669 "do_bind: v%d bind: \"%s\" to \"%s\" \n",
670 version, op->o_conn->c_dn.bv_val, op->o_conn->c_dn.bv_val );
672 Debug( LDAP_DEBUG_TRACE,
673 "do_bind: v%d bind: \"%s\" to \"%s\"\n",
674 version, dn.bv_val, op->o_conn->c_dn.bv_val );
677 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
679 /* send this here to avoid a race condition */
680 send_ldap_result( op, rs );
682 } else if (op->orb_edn.bv_val != NULL) {
683 free( op->orb_edn.bv_val );
687 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
688 "operation not supported within naming context" );
693 slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb ) < 0 )
696 LDAP_LOG( OPERATION, INFO,
697 "do_bind: Bind postoperation plugins failed\n",
700 Debug(LDAP_DEBUG_TRACE,
701 "do_bind: Bind postoperation plugins failed.\n",
705 #endif /* LDAP_SLAPI */
708 if ( rs->sr_err == LDAP_SUCCESS ) {
709 if ( op->orb_method != LDAP_AUTH_SASL ) {
710 ber_dupbv( &op->o_conn->c_authmech, &mech );
712 op->o_conn->c_authtype = op->orb_method;
715 op->o_conn->c_sasl_bindop = NULL;
717 if( op->o_req_dn.bv_val != NULL ) {
718 slap_sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx );
719 op->o_req_dn.bv_val = NULL;
721 if( op->o_req_ndn.bv_val != NULL ) {
722 slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
723 op->o_req_ndn.bv_val = NULL;