X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fbind.c;h=262dd3c4b8cb773d354a02a131d9b8da5d090d66;hb=740f1b422edc48c9eeed8346c45872a63b683370;hp=c8daed7bfe2bab60394ff27c11edfd81d114a4d0;hpb=73276e84ae32e9e148197971d1d6729739980353;p=openldap diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index c8daed7bfe..262dd3c4b8 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -1,4 +1,8 @@ /* bind.c - decode an ldap bind operation and pass it to a backend db */ +/* + * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. + * COPYING RESTRICTIONS APPLY, see COPYRIGHT file + */ /* * Copyright (c) 1995 Regents of the University of Michigan. @@ -21,11 +25,6 @@ #include "slap.h" -char *supportedSASLMechanisms[] = { - "X-DIGEST-MD5", - NULL -}; - int do_bind( Connection *conn, @@ -36,7 +35,7 @@ do_bind( ber_int_t version; ber_tag_t method; char *mech; - char *cdn, *ndn; + char *dn, *ndn; ber_tag_t tag; int rc = LDAP_SUCCESS; struct berval cred; @@ -44,7 +43,7 @@ do_bind( Debug( LDAP_DEBUG_TRACE, "do_bind\n", 0, 0, 0 ); - cdn = NULL; + dn = NULL; ndn = NULL; mech = NULL; cred.bv_val = NULL; @@ -98,7 +97,7 @@ do_bind( * } */ - tag = ber_scanf( ber, "{iat" /*}*/, &version, &cdn, &method ); + tag = ber_scanf( ber, "{iat" /*}*/, &version, &dn, &method ); if ( tag == LBER_ERROR ) { Debug( LDAP_DEBUG_ANY, "bind: ber_scanf failed\n", 0, 0, 0 ); @@ -108,6 +107,15 @@ do_bind( goto cleanup; } + ndn = ch_strdup( dn ); + + if ( dn_normalize_case( ndn ) == NULL ) { + Debug( LDAP_DEBUG_ANY, "bind: invalid dn (%s)\n", dn, 0, 0 ); + send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL, + "invalid DN", NULL, NULL ); + goto cleanup; + } + op->o_protocol = version; if( method != LDAP_AUTH_SASL ) { @@ -145,16 +153,14 @@ do_bind( if( method == LDAP_AUTH_SASL ) { Debug( LDAP_DEBUG_TRACE, "do_sasl_bind: dn (%s) mech %s\n", - cdn, mech, NULL ); + dn, mech, NULL ); } else { Debug( LDAP_DEBUG_TRACE, "do_bind: version %d dn (%s) method %d\n", - version, cdn, method ); + version, dn, method ); } - ndn = dn_normalize_case( ch_strdup( cdn ) ); - - Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d BIND dn=\"%s\" method=%d\n", - conn->c_connid, op->o_opid, ndn, method, 0 ); + Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d BIND dn=\"%s\" method=%ld\n", + op->o_connid, op->o_opid, ndn, (unsigned long) method, 0 ); if ( version < LDAP_VERSION_MIN || version > LDAP_VERSION_MAX ) { Debug( LDAP_DEBUG_ANY, "unknown version %d\n", version, 0, 0 ); @@ -274,11 +280,14 @@ do_bind( /* alias suffix */ char *edn; + /* deref suffix alias if appropriate */ + ndn = suffix_alias( be, ndn ); + if ( (*be->be_bind)( be, conn, op, ndn, method, mech, &cred, &edn ) == 0 ) { ldap_pvt_thread_mutex_lock( &conn->c_mutex ); - conn->c_cdn = cdn; - cdn = NULL; + conn->c_cdn = dn; + dn = NULL; if(edn != NULL) { conn->c_dn = edn; @@ -306,8 +315,8 @@ do_bind( } cleanup: - if( cdn != NULL ) { - free( cdn ); + if( dn != NULL ) { + free( dn ); } if( ndn != NULL ) { free( ndn );