]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-meta/conn.c
Improve schema error messages
[openldap] / servers / slapd / back-meta / conn.c
index e703f57698bd50b013a46064346116acfba6eab5..739af0e44b5ab6c1ebf767d319027dfdac17327d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 1998-2001 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  *
  * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
@@ -275,26 +275,27 @@ init_one_conn(
        /*
         * If the connection dn is not null, an attempt to rewrite it is made
         */
-       if ( conn->c_cdn != NULL && conn->c_cdn[ 0 ] != '\0' ) {
+       if ( conn->c_dn.bv_len != 0 ) {
+               
                /*
                 * Rewrite the bind dn if needed
                 */
-               lsc->bound_dn = NULL;
+               lsc->bound_dn.bv_val = NULL;
                switch ( rewrite_session( lt->rwinfo, "bindDn",
-                                       conn->c_cdn, conn,
-                                       &lsc->bound_dn ) ) {
+                                       conn->c_dn.bv_val, conn, 
+                                       &lsc->bound_dn.bv_val ) ) {
                case REWRITE_REGEXEC_OK:
-                       if ( lsc->bound_dn == NULL ) {
-                               lsc->bound_dn = ch_strdup( conn->c_cdn );
+                       if ( lsc->bound_dn.bv_val == NULL ) {
+                               ber_dupbv( &lsc->bound_dn, &conn->c_dn );
                        }
 #ifdef NEW_LOGGING
-                       LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
-                                       "[rw] bindDn: \"%s\" -> \"%s\"\n",
-                                       conn->c_cdn, lsc->bound_dn ));
+                       LDAP_LOG( BACK_META, DETAIL1,
+                               "[rw] bindDn: \"%s\" -> \"%s\"\n",
+                               conn->c_dn.bv_val, lsc->bound_dn.bv_val, 0 );
 #else /* !NEW_LOGGING */
                        Debug( LDAP_DEBUG_ARGS,
-                                       "rw> bindDn: \"%s\" -> \"%s\"\n%s",
-                                       conn->c_cdn, lsc->bound_dn, "" );
+                                       "rw> bindDn: \"%s\" -> \"%s\"\n",
+                                       conn->c_dn.bv_val, lsc->bound_dn.bv_val, 0 );
 #endif /* !NEW_LOGGING */
                        break;
                        
@@ -312,8 +313,11 @@ init_one_conn(
                                        NULL, NULL );
                        return LDAP_OPERATIONS_ERROR;
                }
+
+               assert( lsc->bound_dn.bv_val );
+
        } else {
-               lsc->bound_dn = NULL;
+               ber_str2bv( "", 0, 1, &lsc->bound_dn );
        }
 
        lsc->bound = META_UNBOUND;
@@ -340,12 +344,11 @@ init_one_conn(
 struct metaconn *
 meta_back_getconn(
                struct metainfo *li,
-               Connection *conn,
-               Operation *op,
-               int op_type,
-               const char *ndn,
-               int *candidate
-               )
+               Connection      *conn,
+               Operation       *op,
+               int             op_type,
+               struct berval   *ndn,
+               int             *candidate )
 {
        struct metaconn *lc, lc_curr;
        int vers, cached = -1, i = -1, err = LDAP_SUCCESS;
@@ -399,13 +402,13 @@ meta_back_getconn(
                }
                                
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
-                               "meta_back_getconn: got target %d"
-                               " for ndn=\"%s\" from cache\n", i, ndn ));
+               LDAP_LOG( BACK_META, INFO,
+                       "meta_back_getconn: got target %d for ndn=\"%s\" from cache\n", 
+                       i, ndn->bv_val, 0 );
 #else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_CACHE,
        "==>meta_back_getconn: got target %d for ndn=\"%s\" from cache\n%s",
-                               i, ndn, "" );
+                               i, ndn->bv_val, "" );
 #endif /* !NEW_LOGGING */
 
                /*
@@ -467,11 +470,9 @@ meta_back_getconn(
         * if no unique candidate ...
         */
        } else {
-               int ndnlen = strlen( ndn );     
                for ( i = 0; i < li->ntargets; i++ ) {
                        if ( i == cached 
-               || meta_back_is_candidate( li->targets[ i ]->suffix,
-                                       ndn, ndnlen ) ) {
+               || meta_back_is_candidate( &li->targets[ i ]->suffix, ndn ) ) {
 
                                /*
                                 * The target is activated; if needed, it is
@@ -511,9 +512,8 @@ meta_back_getconn(
                ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
 
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
-                               "meta_back_getconn: conn %ld inserted\n",
-                               lc->conn->c_connid ));
+               LDAP_LOG( BACK_META, INFO,
+                       "meta_back_getconn: conn %ld inserted\n", lc->conn->c_connid, 0, 0);
 #else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_TRACE,
                        "=>meta_back_getconn: conn %ld inserted\n%s%s",
@@ -531,9 +531,8 @@ meta_back_getconn(
                }
        } else {
 #ifdef NEW_LOGGING
-               LDAP_LOG(( "backend", LDAP_LEVEL_INFO,
-                               "meta_back_getconn: conn %ld fetched\n",
-                               lc->conn->c_connid ));
+               LDAP_LOG( BACK_META, INFO,
+                       "meta_back_getconn: conn %ld fetched\n", lc->conn->c_connid, 0, 0 );
 #else /* !NEW_LOGGING */
                Debug( LDAP_DEBUG_TRACE,
                        "=>meta_back_getconn: conn %ld fetched\n%s%s",