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;
49 struct berval mech = { 0, NULL };
50 struct berval dn = { 0, NULL };
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, &op->orb_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" );
123 op->o_protocol = version;
125 if( op->orb_method != LDAP_AUTH_SASL ) {
126 tag = ber_scanf( ber, /*{*/ "m}", &op->orb_cred );
129 tag = ber_scanf( ber, "{m" /*}*/, &mech );
131 if ( tag != LBER_ERROR ) {
133 tag = ber_peek_tag( ber, &len );
135 if ( tag == LDAP_TAG_LDAPCRED ) {
136 tag = ber_scanf( ber, "m", &op->orb_cred );
138 tag = LDAP_TAG_LDAPCRED;
139 op->orb_cred.bv_val = NULL;
140 op->orb_cred.bv_len = 0;
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, (unsigned long) op->orb_method,
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 /* check for inappropriate controls */
241 if( get_manageDSAit( op ) == SLAP_CRITICAL_CONTROL ) {
242 send_ldap_error( op, rs,
243 LDAP_UNAVAILABLE_CRITICAL_EXTENSION,
244 "manageDSAit control inappropriate" );
248 /* Set the bindop for the benefit of in-directory SASL lookups */
249 op->o_conn->c_sasl_bindop = op;
251 if ( op->orb_method == LDAP_AUTH_SASL ) {
252 if ( version < LDAP_VERSION3 ) {
254 LDAP_LOG( OPERATION, INFO,
255 "do_bind: conn %d sasl with LDAPv%ld\n",
256 op->o_connid, (unsigned long)version , 0 );
258 Debug( LDAP_DEBUG_ANY, "do_bind: sasl with LDAPv%ld\n",
259 (unsigned long) version, 0, 0 );
261 send_ldap_discon( op, rs,
262 LDAP_PROTOCOL_ERROR, "SASL bind requires LDAPv3" );
263 rs->sr_err = SLAPD_DISCONNECT;
267 if( mech.bv_len == 0 ) {
269 LDAP_LOG( OPERATION, INFO,
270 "do_bind: conn %d no SASL mechanism provided\n",
271 op->o_connid, 0, 0 );
273 Debug( LDAP_DEBUG_ANY,
274 "do_bind: no sasl mechanism provided\n",
277 send_ldap_error( op, rs, LDAP_AUTH_METHOD_NOT_SUPPORTED,
278 "no SASL mechanism provided" );
282 /* check restrictions */
283 if( backend_check_restrictions( op, rs, &mech ) != LDAP_SUCCESS ) {
284 send_ldap_result( op, rs );
288 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
289 if ( op->o_conn->c_sasl_bind_in_progress ) {
290 if( !bvmatch( &op->o_conn->c_sasl_bind_mech, &mech ) ) {
291 /* mechanism changed between bind steps */
292 slap_sasl_reset(op->o_conn);
295 ber_dupbv(&op->o_conn->c_sasl_bind_mech, &mech);
297 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
299 rs->sr_err = slap_sasl_bind( op, rs );
301 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
302 if( rs->sr_err == LDAP_SUCCESS ) {
303 ber_dupbv(&op->o_conn->c_dn, &op->orb_edn);
304 if( op->orb_edn.bv_len != 0 ) {
305 /* edn is always normalized already */
306 ber_dupbv( &op->o_conn->c_ndn, &op->o_conn->c_dn );
308 op->o_tmpfree( op->orb_edn.bv_val, op->o_tmpmemctx );
309 op->orb_edn.bv_val = NULL;
310 op->orb_edn.bv_len = 0;
311 op->o_conn->c_authmech = op->o_conn->c_sasl_bind_mech;
312 op->o_conn->c_sasl_bind_mech.bv_val = NULL;
313 op->o_conn->c_sasl_bind_mech.bv_len = 0;
314 op->o_conn->c_sasl_bind_in_progress = 0;
316 op->o_conn->c_sasl_ssf = op->orb_ssf;
317 if( op->orb_ssf > op->o_conn->c_ssf ) {
318 op->o_conn->c_ssf = op->orb_ssf;
321 if( op->o_conn->c_dn.bv_len != 0 ) {
322 ber_len_t max = sockbuf_max_incoming_auth;
323 ber_sockbuf_ctrl( op->o_conn->c_sb,
324 LBER_SB_OPT_SET_MAX_INCOMING, &max );
327 /* log authorization identity */
328 Statslog( LDAP_DEBUG_STATS,
329 "conn=%lu op=%lu BIND dn=\"%s\" mech=%s ssf=%d\n",
330 op->o_connid, op->o_opid,
331 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
332 op->o_conn->c_authmech.bv_val, op->orb_ssf );
335 LDAP_LOG( OPERATION, DETAIL1,
336 "do_bind: SASL/%s bind: dn=\"%s\" ssf=%d\n",
337 op->o_conn->c_authmech.bv_val,
338 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
341 Debug( LDAP_DEBUG_TRACE,
342 "do_bind: SASL/%s bind: dn=\"%s\" ssf=%d\n",
343 op->o_conn->c_authmech.bv_val,
344 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
348 } else if ( rs->sr_err == LDAP_SASL_BIND_IN_PROGRESS ) {
349 op->o_conn->c_sasl_bind_in_progress = 1;
352 if ( op->o_conn->c_sasl_bind_mech.bv_val ) {
353 free( op->o_conn->c_sasl_bind_mech.bv_val );
354 op->o_conn->c_sasl_bind_mech.bv_val = NULL;
355 op->o_conn->c_sasl_bind_mech.bv_len = 0;
357 op->o_conn->c_sasl_bind_in_progress = 0;
363 * Normally post-operation plugins are called only after the
364 * backend operation. Because the front-end performs SASL
365 * binds on behalf of the backend, we'll make a special
366 * exception to call the post-operation plugins after a
370 slapi_int_pblock_set_operation( pb, op );
371 slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
372 slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method );
373 slapi_pblock_set( pb, 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, SLAPI_PLUGIN_POST_BIND_FN, pb );
377 #endif /* LDAP_SLAPI */
379 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
384 /* Not SASL, cancel any in-progress bind */
385 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
387 if ( op->o_conn->c_sasl_bind_mech.bv_val != NULL ) {
388 free(op->o_conn->c_sasl_bind_mech.bv_val);
389 op->o_conn->c_sasl_bind_mech.bv_val = NULL;
390 op->o_conn->c_sasl_bind_mech.bv_len = 0;
392 op->o_conn->c_sasl_bind_in_progress = 0;
394 slap_sasl_reset( op->o_conn );
395 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
398 if ( op->orb_method == LDAP_AUTH_SIMPLE ) {
399 ber_str2bv( "SIMPLE", sizeof("SIMPLE")-1, 0, &mech );
400 /* accept "anonymous" binds */
401 if ( op->orb_cred.bv_len == 0 || op->o_req_ndn.bv_len == 0 ) {
402 rs->sr_err = LDAP_SUCCESS;
404 if( op->orb_cred.bv_len &&
405 !( global_allows & SLAP_ALLOW_BIND_ANON_CRED ))
407 /* cred is not empty, disallow */
408 rs->sr_err = LDAP_INVALID_CREDENTIALS;
410 } else if ( op->o_req_ndn.bv_len &&
411 !( global_allows & SLAP_ALLOW_BIND_ANON_DN ))
413 /* DN is not empty, disallow */
414 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
416 "unauthenticated bind (DN with no password) disallowed";
418 } else if ( global_disallows & SLAP_DISALLOW_BIND_ANON ) {
420 rs->sr_err = LDAP_INAPPROPRIATE_AUTH;
421 rs->sr_text = "anonymous bind disallowed";
424 backend_check_restrictions( op, rs, &mech );
428 * we already forced connection to "anonymous",
429 * just need to send success
431 send_ldap_result( op, rs );
433 LDAP_LOG( OPERATION, DETAIL1,
434 "do_bind: conn %d v%d anonymous bind\n",
435 op->o_connid, version , 0 );
437 Debug( LDAP_DEBUG_TRACE, "do_bind: v%d anonymous bind\n",
442 } else if ( global_disallows & SLAP_DISALLOW_BIND_SIMPLE ) {
443 /* disallow simple authentication */
444 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
445 rs->sr_text = "unwilling to perform simple authentication";
447 send_ldap_result( op, rs );
449 LDAP_LOG( OPERATION, INFO,
450 "do_bind: conn %d v%d simple bind(%s) disallowed\n",
451 op->o_connid, version, op->o_req_ndn.bv_val );
453 Debug( LDAP_DEBUG_TRACE,
454 "do_bind: v%d simple bind(%s) disallowed\n",
455 version, op->o_req_ndn.bv_val, 0 );
460 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
461 } else if ( op->orb_method == LDAP_AUTH_KRBV41 || op->orb_method == LDAP_AUTH_KRBV42 ) {
462 if ( global_disallows & SLAP_DISALLOW_BIND_KRBV4 ) {
463 /* disallow simple authentication */
464 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
465 rs->sr_text = "unwilling to perform Kerberos V4 bind";
467 send_ldap_result( op, rs );
469 LDAP_LOG( OPERATION, DETAIL1,
470 "do_bind: conn %d v%d Kerberos V4 bind\n",
471 op->o_connid, version , 0 );
473 Debug( LDAP_DEBUG_TRACE, "do_bind: v%d Kerberos V4 bind\n",
478 ber_str2bv( "KRBV4", sizeof("KRBV4")-1, 0, &mech );
482 rs->sr_err = LDAP_AUTH_METHOD_NOT_SUPPORTED;
483 rs->sr_text = "unknown authentication method";
485 send_ldap_result( op, rs );
487 LDAP_LOG( OPERATION, INFO,
488 "do_bind: conn %ld v%d unknown authentication method (%ld)\n",
489 op->o_connid, version, op->orb_method );
491 Debug( LDAP_DEBUG_TRACE,
492 "do_bind: v%d unknown authentication method (%ld)\n",
493 version, op->orb_method, 0 );
499 * We could be serving multiple database backends. Select the
500 * appropriate one, or send a referral to our "referral server"
501 * if we don't hold it.
504 if ( (op->o_bd = select_backend( &op->o_req_ndn, 0, 0 )) == NULL ) {
505 if ( default_referral ) {
506 rs->sr_ref = referral_rewrite( default_referral,
507 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
508 if (!rs->sr_ref) rs->sr_ref = default_referral;
510 rs->sr_err = LDAP_REFERRAL;
511 send_ldap_result( op, rs );
513 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
516 /* noSuchObject is not allowed to be returned by bind */
517 rs->sr_err = LDAP_INVALID_CREDENTIALS;
518 send_ldap_result( op, rs );
524 /* check restrictions */
525 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
526 send_ldap_result( op, rs );
530 #if defined( LDAP_SLAPI )
533 slapi_int_pblock_set_operation( pb, op );
534 slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
535 slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method );
536 slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
537 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(0) );
538 slapi_pblock_set( pb, SLAPI_CONN_DN, (void *)(0) );
540 rc = slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_PRE_BIND_FN, pb );
543 LDAP_LOG( OPERATION, INFO,
544 "do_bind: Bind preoperation plugin returned %d\n",
547 Debug(LDAP_DEBUG_TRACE,
548 "do_bind: Bind preoperation plugin returned %d.\n",
553 case SLAPI_BIND_SUCCESS:
554 /* Continue with backend processing */
556 case SLAPI_BIND_FAIL:
557 /* Failure, server sends result */
558 rs->sr_err = LDAP_INVALID_CREDENTIALS;
559 send_ldap_result( op, rs );
562 case SLAPI_BIND_ANONYMOUS:
563 /* SLAPI_BIND_ANONYMOUS is undocumented XXX */
565 /* Authoritative, plugin sent result, or no plugins called. */
566 if ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE,
567 (void *)&rs->sr_err) != 0 )
569 rs->sr_err = LDAP_OTHER;
572 op->orb_edn.bv_val = NULL;
573 op->orb_edn.bv_len = 0;
575 if ( rs->sr_err == LDAP_SUCCESS ) {
576 slapi_pblock_get( pb, SLAPI_CONN_DN, (void *)&op->orb_edn.bv_val );
577 if ( op->orb_edn.bv_val == NULL ) {
579 /* No plugins were called; continue. */
583 op->orb_edn.bv_len = strlen( op->orb_edn.bv_val );
585 rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn,
586 &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
587 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
588 ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn);
589 ber_dupbv(&op->o_conn->c_ndn, &op->o_req_ndn);
590 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
591 op->o_req_dn.bv_val = NULL;
592 op->o_req_dn.bv_len = 0;
593 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
594 op->o_req_ndn.bv_val = NULL;
595 op->o_req_ndn.bv_len = 0;
596 if ( op->o_conn->c_dn.bv_len != 0 ) {
597 ber_len_t max = sockbuf_max_incoming_auth;
598 ber_sockbuf_ctrl( op->o_conn->c_sb,
599 LBER_SB_OPT_SET_MAX_INCOMING, &max );
601 /* log authorization identity */
602 Statslog( LDAP_DEBUG_STATS,
603 "conn=%lu op=%lu BIND dn=\"%s\" mech=%s (SLAPI) ssf=0\n",
604 op->o_connid, op->o_opid,
605 op->o_conn->c_dn.bv_val ? op->o_conn->c_dn.bv_val : "<empty>",
607 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
613 #endif /* defined( LDAP_SLAPI ) */
615 if( op->o_bd->be_bind ) {
616 rs->sr_err = (op->o_bd->be_bind)( op, rs );
618 if ( rs->sr_err == 0 ) {
619 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
621 if( op->o_conn->c_authz_backend == NULL ) {
622 op->o_conn->c_authz_backend = op->o_bd;
625 /* be_bind returns regular/global edn */
626 if( op->orb_edn.bv_len ) {
627 op->o_conn->c_dn = op->orb_edn;
629 ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn);
632 ber_dupbv( &op->o_conn->c_ndn, &op->o_req_ndn );
634 if( op->o_conn->c_dn.bv_len != 0 ) {
635 ber_len_t max = sockbuf_max_incoming_auth;
636 ber_sockbuf_ctrl( op->o_conn->c_sb,
637 LBER_SB_OPT_SET_MAX_INCOMING, &max );
640 /* log authorization identity */
641 Statslog( LDAP_DEBUG_STATS,
642 "conn=%lu op=%lu BIND dn=\"%s\" mech=%s ssf=0\n",
643 op->o_connid, op->o_opid,
644 op->o_conn->c_dn.bv_val, mech.bv_val, 0 );
647 LDAP_LOG( OPERATION, DETAIL1,
648 "do_bind: v%d bind: \"%s\" to \"%s\" \n",
649 version, op->o_conn->c_dn.bv_val, op->o_conn->c_dn.bv_val );
651 Debug( LDAP_DEBUG_TRACE,
652 "do_bind: v%d bind: \"%s\" to \"%s\"\n",
653 version, dn.bv_val, op->o_conn->c_dn.bv_val );
656 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
658 /* send this here to avoid a race condition */
659 send_ldap_result( op, rs );
661 } else if (op->orb_edn.bv_val != NULL) {
662 free( op->orb_edn.bv_val );
666 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
667 "operation not supported within naming context" );
670 #if defined( LDAP_SLAPI )
671 if ( pb != NULL && slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_POST_BIND_FN, pb ) < 0 ) {
673 LDAP_LOG( OPERATION, INFO,
674 "do_bind: Bind postoperation plugins failed\n",
677 Debug(LDAP_DEBUG_TRACE,
678 "do_bind: Bind postoperation plugins failed.\n",
682 #endif /* defined( LDAP_SLAPI ) */
685 if ( rs->sr_err == LDAP_SUCCESS ) {
686 if ( op->orb_method != LDAP_AUTH_SASL ) {
687 ber_dupbv( &op->o_conn->c_authmech, &mech );
689 op->o_conn->c_authtype = op->orb_method;
692 op->o_conn->c_sasl_bindop = NULL;
694 if( op->o_req_dn.bv_val != NULL ) {
695 sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx );
696 op->o_req_dn.bv_val = NULL;
698 if( op->o_req_ndn.bv_val != NULL ) {
699 sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
700 op->o_req_ndn.bv_val = NULL;