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"
47 BerElement *ber = op->o_ber;
50 struct berval mech = BER_BVNULL;
51 struct berval dn = BER_BVNULL;
56 LDAP_LOG( OPERATION, ENTRY, "do_bind: conn %d\n", op->o_connid, 0, 0 );
58 Debug( LDAP_DEBUG_TRACE, "do_bind\n", 0, 0, 0 );
62 * Force to connection to "anonymous" until bind succeeds.
64 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
65 if ( op->o_conn->c_sasl_bind_in_progress ) {
66 be = op->o_conn->c_authz_backend;
68 if ( op->o_conn->c_dn.bv_len ) {
69 /* log authorization identity demotion */
70 Statslog( LDAP_DEBUG_STATS,
71 "conn=%lu op=%lu BIND anonymous mech=implicit ssf=0\n",
72 op->o_connid, op->o_opid, 0, 0, 0 );
74 connection2anonymous( op->o_conn );
75 if ( op->o_conn->c_sasl_bind_in_progress ) {
76 op->o_conn->c_authz_backend = be;
78 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
79 if ( op->o_dn.bv_val != NULL ) {
80 free( op->o_dn.bv_val );
81 op->o_dn.bv_val = ch_strdup( "" );
84 if ( op->o_ndn.bv_val != NULL ) {
85 free( op->o_ndn.bv_val );
86 op->o_ndn.bv_val = ch_strdup( "" );
91 * Parse the bind request. It looks like this:
93 * BindRequest ::= SEQUENCE {
94 * version INTEGER, -- version
95 * name DistinguishedName, -- dn
96 * authentication CHOICE {
97 * simple [0] OCTET STRING -- passwd
98 * krbv42ldap [1] OCTET STRING
99 * krbv42dsa [2] OCTET STRING
100 * SASL [3] SaslCredentials
104 * SaslCredentials ::= SEQUENCE {
105 * mechanism LDAPString,
106 * credentials OCTET STRING OPTIONAL
110 tag = ber_scanf( ber, "{imt" /*}*/, &version, &dn, &method );
112 if ( tag == LBER_ERROR ) {
114 LDAP_LOG( OPERATION, ERR,
115 "do_bind: conn %d ber_scanf failed\n", op->o_connid, 0, 0 );
117 Debug( LDAP_DEBUG_ANY, "bind: ber_scanf failed\n", 0, 0, 0 );
119 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
124 op->o_protocol = version;
125 op->orb_method = method;
127 if( op->orb_method != LDAP_AUTH_SASL ) {
128 tag = ber_scanf( ber, /*{*/ "m}", &op->orb_cred );
131 tag = ber_scanf( ber, "{m" /*}*/, &mech );
133 if ( tag != LBER_ERROR ) {
135 tag = ber_peek_tag( ber, &len );
137 if ( tag == LDAP_TAG_LDAPCRED ) {
138 tag = ber_scanf( ber, "m", &op->orb_cred );
140 tag = LDAP_TAG_LDAPCRED;
141 op->orb_cred.bv_val = NULL;
142 op->orb_cred.bv_len = 0;
145 if ( tag != LBER_ERROR ) {
146 tag = ber_scanf( ber, /*{{*/ "}}" );
151 if ( tag == LBER_ERROR ) {
152 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
153 rs->sr_err = SLAPD_DISCONNECT;
157 if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
159 LDAP_LOG( OPERATION, INFO,
160 "do_bind: conn %d get_ctrls failed\n", op->o_connid, 0, 0 );
162 Debug( LDAP_DEBUG_ANY, "do_bind: get_ctrls failed\n", 0, 0, 0 );
167 /* We use the tmpmemctx here because it speeds up normalization.
168 * However, we must dup with regular malloc when storing any
169 * resulting DNs in the op or conn structures.
171 rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
173 if ( rs->sr_err != LDAP_SUCCESS ) {
175 LDAP_LOG( OPERATION, INFO,
176 "do_bind: conn %d invalid dn (%s)\n",
177 op->o_connid, dn.bv_val, 0 );
179 Debug( LDAP_DEBUG_ANY, "bind: invalid dn (%s)\n",
182 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
186 if( op->orb_method == LDAP_AUTH_SASL ) {
188 LDAP_LOG( OPERATION, DETAIL1,
189 "do_sasl_bind: conn %d dn (%s) mech %s\n",
190 op->o_connid, op->o_req_dn.bv_val, mech.bv_val );
192 Debug( LDAP_DEBUG_TRACE, "do_sasl_bind: dn (%s) mech %s\n",
193 op->o_req_dn.bv_val, mech.bv_val, NULL );
198 LDAP_LOG( OPERATION, DETAIL1,
199 "do_bind: version=%ld dn=\"%s\" method=%ld\n",
200 (unsigned long) version, op->o_req_dn.bv_val,
201 (unsigned long) op->orb_method );
203 Debug( LDAP_DEBUG_TRACE,
204 "do_bind: version=%ld dn=\"%s\" method=%ld\n",
205 (unsigned long) version, op->o_req_dn.bv_val,
206 (unsigned long) op->orb_method );
210 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu BIND dn=\"%s\" method=%ld\n",
211 op->o_connid, op->o_opid, op->o_req_dn.bv_val,
212 (unsigned long) op->orb_method, 0 );
214 if ( version < LDAP_VERSION_MIN || version > LDAP_VERSION_MAX ) {
216 LDAP_LOG( OPERATION, INFO,
217 "do_bind: conn %d unknown version = %ld\n",
218 op->o_connid, (unsigned long)version, 0 );
220 Debug( LDAP_DEBUG_ANY, "do_bind: unknown version=%ld\n",
221 (unsigned long) version, 0, 0 );
223 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
224 "requested protocol version not supported" );
227 } else if (!( global_allows & SLAP_ALLOW_BIND_V2 ) &&
228 version < LDAP_VERSION3 )
230 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
231 "historical protocol version requested, use LDAPv3 instead" );
236 * we set connection version regardless of whether bind succeeds or not.
238 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
239 op->o_conn->c_protocol = version;
240 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
242 /* check for inappropriate controls */
243 if( get_manageDSAit( op ) == SLAP_CRITICAL_CONTROL ) {
244 send_ldap_error( op, rs,
245 LDAP_UNAVAILABLE_CRITICAL_EXTENSION,
246 "manageDSAit control inappropriate" );
250 /* Set the bindop for the benefit of in-directory SASL lookups */
251 op->o_conn->c_sasl_bindop = op;
253 if ( op->orb_method == LDAP_AUTH_SASL ) {
254 if ( version < LDAP_VERSION3 ) {
256 LDAP_LOG( OPERATION, INFO,
257 "do_bind: conn %d sasl with LDAPv%ld\n",
258 op->o_connid, (unsigned long)version , 0 );
260 Debug( LDAP_DEBUG_ANY, "do_bind: sasl with LDAPv%ld\n",
261 (unsigned long) version, 0, 0 );
263 send_ldap_discon( op, rs,
264 LDAP_PROTOCOL_ERROR, "SASL bind requires LDAPv3" );
265 rs->sr_err = SLAPD_DISCONNECT;
269 if( mech.bv_len == 0 ) {
271 LDAP_LOG( OPERATION, INFO,
272 "do_bind: conn %d no SASL mechanism provided\n",
273 op->o_connid, 0, 0 );
275 Debug( LDAP_DEBUG_ANY,
276 "do_bind: no sasl mechanism provided\n",
279 send_ldap_error( op, rs, LDAP_AUTH_METHOD_NOT_SUPPORTED,
280 "no SASL mechanism provided" );
284 /* check restrictions */
285 if( backend_check_restrictions( op, rs, &mech ) != LDAP_SUCCESS ) {
286 send_ldap_result( op, rs );
290 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
291 if ( op->o_conn->c_sasl_bind_in_progress ) {
292 if( !bvmatch( &op->o_conn->c_sasl_bind_mech, &mech ) ) {
293 /* mechanism changed between bind steps */
294 slap_sasl_reset(op->o_conn);
297 ber_dupbv(&op->o_conn->c_sasl_bind_mech, &mech);
299 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
301 rs->sr_err = slap_sasl_bind( op, rs );
303 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
304 if( rs->sr_err == LDAP_SUCCESS ) {
305 ber_dupbv(&op->o_conn->c_dn, &op->orb_edn);
306 if( op->orb_edn.bv_len != 0 ) {
307 /* edn is always normalized already */
308 ber_dupbv( &op->o_conn->c_ndn, &op->o_conn->c_dn );
310 op->o_tmpfree( op->orb_edn.bv_val, op->o_tmpmemctx );
311 op->orb_edn.bv_val = NULL;
312 op->orb_edn.bv_len = 0;
313 op->o_conn->c_authmech = op->o_conn->c_sasl_bind_mech;
314 op->o_conn->c_sasl_bind_mech.bv_val = NULL;
315 op->o_conn->c_sasl_bind_mech.bv_len = 0;
316 op->o_conn->c_sasl_bind_in_progress = 0;
318 op->o_conn->c_sasl_ssf = op->orb_ssf;
319 if( op->orb_ssf > op->o_conn->c_ssf ) {
320 op->o_conn->c_ssf = op->orb_ssf;
323 if( op->o_conn->c_dn.bv_len != 0 ) {
324 ber_len_t max = sockbuf_max_incoming_auth;
325 ber_sockbuf_ctrl( op->o_conn->c_sb,
326 LBER_SB_OPT_SET_MAX_INCOMING, &max );
329 /* log authorization identity */
330 Statslog( LDAP_DEBUG_STATS,
331 "conn=%lu op=%lu BIND dn=\"%s\" mech=%s ssf=%d\n",
332 op->o_connid, op->o_opid,
333 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
334 op->o_conn->c_authmech.bv_val, op->orb_ssf );
337 LDAP_LOG( OPERATION, DETAIL1,
338 "do_bind: SASL/%s bind: dn=\"%s\" ssf=%d\n",
339 op->o_conn->c_authmech.bv_val,
340 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
343 Debug( LDAP_DEBUG_TRACE,
344 "do_bind: SASL/%s bind: dn=\"%s\" ssf=%d\n",
345 op->o_conn->c_authmech.bv_val,
346 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
350 } else if ( rs->sr_err == LDAP_SASL_BIND_IN_PROGRESS ) {
351 op->o_conn->c_sasl_bind_in_progress = 1;
354 if ( op->o_conn->c_sasl_bind_mech.bv_val ) {
355 free( op->o_conn->c_sasl_bind_mech.bv_val );
356 op->o_conn->c_sasl_bind_mech.bv_val = NULL;
357 op->o_conn->c_sasl_bind_mech.bv_len = 0;
359 op->o_conn->c_sasl_bind_in_progress = 0;
365 * Normally post-operation plugins are called only after the
366 * backend operation. Because the front-end performs SASL
367 * binds on behalf of the backend, we'll make a special
368 * exception to call the post-operation plugins after a
372 slapi_int_pblock_set_operation( pb, op );
373 slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
374 slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method );
375 slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
376 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
377 (void) slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb );
379 #endif /* LDAP_SLAPI */
381 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
386 /* Not SASL, cancel any in-progress bind */
387 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
389 if ( op->o_conn->c_sasl_bind_mech.bv_val != NULL ) {
390 free(op->o_conn->c_sasl_bind_mech.bv_val);
391 op->o_conn->c_sasl_bind_mech.bv_val = NULL;
392 op->o_conn->c_sasl_bind_mech.bv_len = 0;
394 op->o_conn->c_sasl_bind_in_progress = 0;
396 slap_sasl_reset( op->o_conn );
397 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
400 if ( op->orb_method == LDAP_AUTH_SIMPLE ) {
401 ber_str2bv( "SIMPLE", sizeof("SIMPLE")-1, 0, &mech );
402 /* accept "anonymous" binds */
403 if ( op->orb_cred.bv_len == 0 || op->o_req_ndn.bv_len == 0 ) {
404 rs->sr_err = LDAP_SUCCESS;
406 if( op->orb_cred.bv_len &&
407 !( global_allows & SLAP_ALLOW_BIND_ANON_CRED ))
409 /* cred is not empty, disallow */
410 rs->sr_err = LDAP_INVALID_CREDENTIALS;
412 } else if ( op->o_req_ndn.bv_len &&
413 !( global_allows & SLAP_ALLOW_BIND_ANON_DN ))
415 /* DN is not empty, disallow */
416 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
418 "unauthenticated bind (DN with no password) disallowed";
420 } else if ( global_disallows & SLAP_DISALLOW_BIND_ANON ) {
422 rs->sr_err = LDAP_INAPPROPRIATE_AUTH;
423 rs->sr_text = "anonymous bind disallowed";
426 backend_check_restrictions( op, rs, &mech );
430 * we already forced connection to "anonymous",
431 * just need to send success
433 send_ldap_result( op, rs );
435 LDAP_LOG( OPERATION, DETAIL1,
436 "do_bind: conn %d v%d anonymous bind\n",
437 op->o_connid, version , 0 );
439 Debug( LDAP_DEBUG_TRACE, "do_bind: v%d anonymous bind\n",
444 } else if ( global_disallows & SLAP_DISALLOW_BIND_SIMPLE ) {
445 /* disallow simple authentication */
446 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
447 rs->sr_text = "unwilling to perform simple authentication";
449 send_ldap_result( op, rs );
451 LDAP_LOG( OPERATION, INFO,
452 "do_bind: conn %d v%d simple bind(%s) disallowed\n",
453 op->o_connid, version, op->o_req_ndn.bv_val );
455 Debug( LDAP_DEBUG_TRACE,
456 "do_bind: v%d simple bind(%s) disallowed\n",
457 version, op->o_req_ndn.bv_val, 0 );
462 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
463 } else if ( op->orb_method == LDAP_AUTH_KRBV41 ) {
464 if ( global_disallows & SLAP_DISALLOW_BIND_KRBV4 ) {
465 /* disallow krbv4 authentication */
466 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
467 rs->sr_text = "unwilling to perform Kerberos V4 bind";
469 send_ldap_result( op, rs );
472 LDAP_LOG( OPERATION, DETAIL1,
473 "do_bind: conn %d v%d Kerberos V4 (step 1) bind refused\n",
474 op->o_connid, version , 0 );
476 Debug( LDAP_DEBUG_TRACE,
477 "do_bind: v%d Kerberos V4 (step 1) bind refused\n",
482 ber_str2bv( "KRBV4", sizeof("KRBV4")-1, 0, &mech );
484 } else if ( op->orb_method == LDAP_AUTH_KRBV42 ) {
485 rs->sr_err = LDAP_AUTH_METHOD_NOT_SUPPORTED;
486 rs->sr_text = "Kerberos V4 (step 2) bind not supported";
487 send_ldap_result( op, rs );
490 LDAP_LOG( OPERATION, DETAIL1,
491 "do_bind: conn %d v%d Kerberos V4 (step 2) bind refused\n",
492 op->o_connid, version , 0 );
494 Debug( LDAP_DEBUG_TRACE,
495 "do_bind: v%d Kerberos V4 (step 2) bind refused\n",
502 rs->sr_err = LDAP_AUTH_METHOD_NOT_SUPPORTED;
503 rs->sr_text = "unknown authentication method";
505 send_ldap_result( op, rs );
507 LDAP_LOG( OPERATION, INFO,
508 "do_bind: conn %ld v%d unknown authentication method (%ld)\n",
509 op->o_connid, version, op->orb_method );
511 Debug( LDAP_DEBUG_TRACE,
512 "do_bind: v%d unknown authentication method (%ld)\n",
513 version, op->orb_method, 0 );
519 * We could be serving multiple database backends. Select the
520 * appropriate one, or send a referral to our "referral server"
521 * if we don't hold it.
524 if ( (op->o_bd = select_backend( &op->o_req_ndn, 0, 0 )) == NULL ) {
525 if ( default_referral ) {
526 rs->sr_ref = referral_rewrite( default_referral,
527 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
528 if (!rs->sr_ref) rs->sr_ref = default_referral;
530 rs->sr_err = LDAP_REFERRAL;
531 send_ldap_result( op, rs );
533 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
536 /* noSuchObject is not allowed to be returned by bind */
537 rs->sr_err = LDAP_INVALID_CREDENTIALS;
538 send_ldap_result( op, rs );
544 /* check restrictions */
545 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
546 send_ldap_result( op, rs );
553 slapi_int_pblock_set_operation( pb, op );
554 slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
555 slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method );
556 slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
557 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
558 slapi_pblock_set( pb, SLAPI_CONN_DN, (void *)(0) );
560 rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_BIND_FN, pb );
563 LDAP_LOG( OPERATION, INFO,
564 "do_bind: Bind preoperation plugin returned %d\n",
567 Debug(LDAP_DEBUG_TRACE,
568 "do_bind: Bind preoperation plugin returned %d.\n",
573 case SLAPI_BIND_SUCCESS:
574 /* Continue with backend processing */
576 case SLAPI_BIND_FAIL:
577 /* Failure, server sends result */
578 rs->sr_err = LDAP_INVALID_CREDENTIALS;
579 send_ldap_result( op, rs );
582 case SLAPI_BIND_ANONYMOUS:
583 /* SLAPI_BIND_ANONYMOUS is undocumented XXX */
585 /* Authoritative, plugin sent result, or no plugins called. */
586 if ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE,
587 (void *)&rs->sr_err) != 0 )
589 rs->sr_err = LDAP_OTHER;
592 op->orb_edn.bv_val = NULL;
593 op->orb_edn.bv_len = 0;
595 if ( rs->sr_err == LDAP_SUCCESS ) {
596 slapi_pblock_get( pb, SLAPI_CONN_DN,
597 (void *)&op->orb_edn.bv_val );
598 if ( op->orb_edn.bv_val == NULL ) {
600 /* No plugins were called; continue. */
604 op->orb_edn.bv_len = strlen( op->orb_edn.bv_val );
606 rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn,
607 &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
608 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
609 ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn);
610 ber_dupbv(&op->o_conn->c_ndn, &op->o_req_ndn);
611 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
612 op->o_req_dn.bv_val = NULL;
613 op->o_req_dn.bv_len = 0;
614 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
615 op->o_req_ndn.bv_val = NULL;
616 op->o_req_ndn.bv_len = 0;
617 if ( op->o_conn->c_dn.bv_len != 0 ) {
618 ber_len_t max = sockbuf_max_incoming_auth;
619 ber_sockbuf_ctrl( op->o_conn->c_sb,
620 LBER_SB_OPT_SET_MAX_INCOMING, &max );
622 /* log authorization identity */
623 Statslog( LDAP_DEBUG_STATS,
624 "conn=%lu op=%lu BIND dn=\"%s\" mech=%s (SLAPI) ssf=0\n",
625 op->o_connid, op->o_opid,
626 op->o_conn->c_dn.bv_val ? 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;