]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/tools/slapadd.c
First stable an implementing latest namedref specification.
[openldap] / servers / slapd / tools / slapadd.c
index ab8f06c01a97e8e00e3b6ea0256cd27cae68fb3f..55b536c43dcde2143c23038713e7898105602103 100644 (file)
@@ -58,7 +58,7 @@ main( int argc, char **argv )
                }
 
                /* make sure the DN is valid */
-               if( dn_normalize( e->e_ndn ) == NULL ) {
+               if( dn_normalize( e->e_ndn ) == NULL || e->e_ndn[0] == '\0' ) {
                        fprintf( stderr, "%s: invalid dn=\"%s\" (line=%d)\n",
                                progname, e->e_dn, lineno );
                        rc = EXIT_FAILURE;
@@ -78,20 +78,28 @@ main( int argc, char **argv )
                }
 
                /* check backend */
-               if( select_backend( e->e_ndn ) != be ) {
-                       fprintf( stderr, "%s: database not configured to "
+               if( select_backend( e->e_ndn, is_entry_referral(e) ) != be )
+               {
+                       fprintf( stderr, "%s: database (%s) not configured to "
                                "hold dn=\"%s\" (line=%d)\n",
-                               progname, e->e_dn, lineno );
+                               progname,
+                               be ? be->be_suffix[0] : "<none>",
+                               e->e_dn, lineno );
                        rc = EXIT_FAILURE;
                        entry_free( e );
                        if( continuemode ) continue;
                        break;
                }
 
-               if( !noschemacheck ) {
+               if( global_schemacheck ) {
                        /* check schema */
                        const char *text;
-                       if ( entry_schema_check( e, NULL, &text ) != LDAP_SUCCESS ) {
+                       char textbuf[SLAP_TEXT_BUFLEN];
+                       size_t textlen = sizeof textbuf;
+
+                       rc = entry_schema_check( e, NULL, &text, textbuf, textlen );
+
+                       if( rc != LDAP_SUCCESS ) {
                                fprintf( stderr, "%s: dn=\"%s\" (line=%d): %s\n",
                                        progname, e->e_dn, lineno, text );
                                rc = EXIT_FAILURE;
@@ -102,7 +110,6 @@ main( int argc, char **argv )
                }
 
                id = be->be_entry_put( be, e );
-
                if( id == NOID ) {
                        fprintf( stderr, "%s: could not add entry dn=\"%s\" (line=%d)\n",
                                progname, e->e_dn, lineno );
@@ -111,7 +118,9 @@ main( int argc, char **argv )
                        if( continuemode ) continue;
                        break;
 
-               } else if ( verbose ) {
+               }
+               
+               if ( verbose ) {
                        fprintf( stderr, "added: \"%s\" (%08lx)\n",
                                e->e_dn, (long) id );
                }