]> git.sur5r.net Git - openldap/commitdiff
entry_schema_check() rename
authorKurt Zeilenga <kurt@openldap.org>
Tue, 25 Apr 2000 13:07:14 +0000 (13:07 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 25 Apr 2000 13:07:14 +0000 (13:07 +0000)
servers/slapd/back-ldbm/add.c
servers/slapd/back-ldbm/modify.c
servers/slapd/tools/slapadd.c

index 44c70c63cf766bd09103f3186786454195c7b41c..8623e2504018a35ce96c6aa36a28729af37592e1 100644 (file)
@@ -29,7 +29,7 @@ ldbm_back_add(
        Entry           *p = NULL;
        int                     rootlock = 0;
        int                     rc; 
-
+       char    *text;
 #ifdef SLAPD_SCHEMA_NOT_COMPAT
        static AttributeDescription *children = NULL;
 #else
@@ -50,15 +50,17 @@ ldbm_back_add(
                return( -1 );
        }
 
-       if ( schema_check_entry( e ) != 0 ) {
+       rc = entry_schema_check( e, NULL, &text );
+
+       if ( rc != LDAP_SUCCESS ) {
                ldap_pvt_thread_mutex_unlock(&li->li_add_mutex);
 
-               Debug( LDAP_DEBUG_TRACE, "entry failed schema check\n",
-                       0, 0, 0 );
+               Debug( LDAP_DEBUG_TRACE, "entry failed schema check: %s\n",
+                       text, 0, 0 );
 
                entry_free( e );
-               send_ldap_result( conn, op, LDAP_OBJECT_CLASS_VIOLATION,
-                       NULL, NULL, NULL, NULL );
+               send_ldap_result( conn, op, rc,
+                       NULL, text, NULL, NULL );
                return( -1 );
        }
 
@@ -121,10 +123,10 @@ ldbm_back_add(
                        /* free parent and writer lock */
                        cache_return_entry_w( &li->li_cache, p ); 
 
-                       Debug( LDAP_DEBUG_TRACE, "no access to parent\n", 0,
+                       Debug( LDAP_DEBUG_TRACE, "no write access to parent\n", 0,
                            0, 0 );
                        send_ldap_result( conn, op, LDAP_INSUFFICIENT_ACCESS,
-                           NULL, NULL, NULL, NULL );
+                           NULL, "no write access to parent", NULL, NULL );
 
 
                        entry_free( e );
@@ -141,7 +143,7 @@ ldbm_back_add(
                            0, 0 );
 
                        send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM,
-                           NULL, NULL, NULL, NULL );
+                           NULL, "parent is an alias", NULL, NULL );
 
                        entry_free( e );
                        return -1;
@@ -223,8 +225,8 @@ ldbm_back_add(
                entry_free( e );
 
                send_ldap_result( conn, op,
-                       rc > 0 ? LDAP_ALREADY_EXISTS : LDAP_OPERATIONS_ERROR,
-                       NULL, NULL, NULL, NULL );
+                       rc > 0 ? LDAP_ALREADY_EXISTS : LDAP_OTHER,
+                       NULL, rc > 0 ? NULL : "cache add failed", NULL, NULL );
 
                return( -1 );
        }
@@ -240,8 +242,8 @@ ldbm_back_add(
        if ( index_add_entry( be, e ) != 0 ) {
                Debug( LDAP_DEBUG_TRACE, "index_add_entry failed\n", 0,
                    0, 0 );
-               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
-                       NULL, NULL, NULL, NULL );
+               send_ldap_result( conn, op, LDAP_OTHER,
+                       NULL, "index generation failed", NULL, NULL );
 
                goto return_results;
        }
@@ -250,8 +252,8 @@ ldbm_back_add(
        if ( dn2id_add( be, e->e_ndn, e->e_id ) != 0 ) {
                Debug( LDAP_DEBUG_TRACE, "dn2id_add failed\n", 0,
                    0, 0 );
-               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
-                       NULL, NULL, NULL, NULL );
+               send_ldap_result( conn, op, LDAP_OTHER,
+                       NULL, "DN index generation failed", NULL, NULL );
 
                goto return_results;
        }
@@ -261,8 +263,8 @@ ldbm_back_add(
                Debug( LDAP_DEBUG_TRACE, "id2entry_add failed\n", 0,
                    0, 0 );
                (void) dn2id_delete( be, e->e_ndn, e->e_id );
-               send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR,
-                       NULL, NULL, NULL, NULL );
+               send_ldap_result( conn, op, LDAP_OTHER,
+                       NULL, "entry store failed", NULL, NULL );
 
                goto return_results;
        }
index adce8f5b150f2088bda4bf7708078f437d5431e3..c98662ee7b070a0b0e34b4ddd9fba35f3f6f7061 100644 (file)
@@ -36,7 +36,8 @@ int ldbm_modify_internal(
     Entry      *e 
 )
 {
-       int err;
+       int rc, err;
+       char *text;
        Modification    *mod;
        Modifications   *ml;
        Attribute       *save_attrs;
@@ -105,11 +106,13 @@ int ldbm_modify_internal(
        ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
 
        /* check that the entry still obeys the schema */
-       if ( schema_check_entry( e ) != 0 ) {
+       rc = entry_schema_check( e, save_attrs, &text );
+       if ( rc != LDAP_SUCCESS ) {
                attrs_free( e->e_attrs );
                e->e_attrs = save_attrs;
-               Debug( LDAP_DEBUG_ANY, "entry failed schema check\n", 0, 0, 0 );
-               return LDAP_OBJECT_CLASS_VIOLATION;
+               Debug( LDAP_DEBUG_ANY, "entry failed schema check: %s\n",
+                       text, 0, 0 );
+               return rc;
        }
 
        /* check for abandon */
@@ -397,7 +400,7 @@ delete_values(
                        Debug( LDAP_DEBUG_ARGS,
                            "could not find value for attr %s\n",
                            mod->mod_type, 0, 0 );
-                       return( LDAP_NO_SUCH_ATTRIBUTE );
+                       return LDAP_NO_SUCH_ATTRIBUTE;
                }
        }
 #endif
index fb4694985dff2ad902e16597ba255661709b4a43..f92d98c366793103d4dd5f62ca7146944e2d9af0 100644 (file)
@@ -69,9 +69,10 @@ main( int argc, char **argv )
 
                if( !noschemacheck ) {
                        /* check schema */
-                       if ( schema_check_entry( e ) != 0 ) {
-                               fprintf( stderr, "%s: schema violation in entry dn=\"%s\" (line=%d)\n",
-                                       progname, e->e_dn, lineno );
+                       char *text;
+                       if ( entry_schema_check( e, NULL, &text ) != LDAP_SUCCESS ) {
+                               fprintf( stderr, "%s: dn=\"%s\" (line=%d): %s\n",
+                                       progname, e->e_dn, lineno, text );
                                rc = EXIT_FAILURE;
                                entry_free( e );
                                if( continuemode ) continue;