]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/bind.c
Factor out ldif2* intialization to ldif2common.c
[openldap] / servers / slapd / bind.c
index c09d4098e7218bfb47bef0561cf9abe38d9a4440..34d617e6273b876232b1622cdc8a74b4b85bc653 100644 (file)
 
 #include "slap.h"
 
-char *supportedSASLMechanisms[] = {
-       "X-DIGEST-MD5",
-       NULL
-};
-
 int
 do_bind(
     Connection *conn,
@@ -36,7 +31,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 +39,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 +93,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 +103,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,14 +149,12 @@ 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",
            op->o_connid, op->o_opid, ndn, method, 0 );
 
@@ -274,11 +276,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 +311,8 @@ do_bind(
        }
 
 cleanup:
-       if( cdn != NULL ) {
-               free( cdn );
+       if( dn != NULL ) {
+               free( dn );
        }
        if( ndn != NULL ) {
                free( ndn );