Debug( LDAP_DEBUG_TRACE,
"<= str2entry: str2ad(%s): %s\n", type, text, 0 );
+ if( slapMode & SLAP_TOOL_MODE ) {
+ entry_free( e );
+ free( value.bv_val );
+ free( type );
+ return NULL;
+ }
+
rc = slap_str2undef_ad( type, &ad, &text );
if( rc != LDAP_SUCCESS ) {
entry_free( e );
free( value.bv_val );
free( type );
- return( NULL );
+ return NULL;
+ }
+ }
+
+ if( slapMode & SLAP_TOOL_MODE ) {
+ slap_syntax_validate_func *validate =
+ ad->ad_type->sat_syntax->ssyn_validate;
+
+ if( !validate ) {
+ Debug( LDAP_DEBUG_ANY,
+ "str2entry: no validator for syntax %s\n",
+ ad->ad_type->sat_syntax->ssyn_oid, 0, 0 );
+ entry_free( e );
+ free( value.bv_val );
+ free( type );
+ return NULL;
+ }
+
+ /*
+ * validate value per syntax
+ */
+ rc = validate( ad->ad_type->sat_syntax, &value );
+
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_TRACE,
+ "str2entry: invalid value for syntax %s\n",
+ ad->ad_type->sat_syntax->ssyn_oid, 0, 0 );
+ entry_free( e );
+ free( value.bv_val );
+ free( type );
+ return NULL;
}
}
/* make sure the DN is valid */
if( dn_normalize( e->e_ndn ) == NULL ) {
- fprintf( stderr, "%s: bad dn=\"%s\" (line=%d)\n",
+ fprintf( stderr, "%s: invalid dn=\"%s\" (line=%d)\n",
progname, e->e_dn, lineno );
rc = EXIT_FAILURE;
entry_free( e );
break;
}
- /* make sure the DN is valid */
+ /* make sure the DN is not empty */
if( e->e_ndn == '\0' ) {
fprintf( stderr, "%s: empty dn=\"%s\" (line=%d)\n",
progname, e->e_dn, lineno );
break;
}
- if( !noschemacheck ) {
+ /* check backend */
+ if( select_backend( e->e_ndn ) != be ) {
+ fprintf( stderr, "%s: database not configured to "
+ "hold dn=\"%s\" (line=%d)\n",
+ progname, e->e_dn, lineno );
+ rc = EXIT_FAILURE;
+ entry_free( e );
+ if( continuemode ) continue;
+ break;
+ }
+
+ if( global_schemacheck ) {
/* check schema */
const char *text;
if ( entry_schema_check( e, NULL, &text ) != LDAP_SUCCESS ) {
if( continuemode ) continue;
break;
}
-
- /* check backend */
- if( select_backend( e->e_ndn ) != be ) {
- fprintf( stderr, "%s: database not configured to hold dn=\"%s\" (line=%d)\n",
- progname, e->e_dn, lineno );
- rc = EXIT_FAILURE;
- entry_free( e );
- if( continuemode ) continue;
- break;
- }
}
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 );
if( continuemode ) continue;
break;
- } else if ( verbose ) {
+ }
+
+ if ( verbose ) {
fprintf( stderr, "added: \"%s\" (%08lx)\n",
e->e_dn, (long) id );
}
char *conffile = SLAPD_DEFAULT_CONFIGFILE;
int truncatemode = 0;
int verbose = 0;
-int noschemacheck = 0;
int continuemode = 0;
char *ldiffile = NULL;
char *options = NULL;
fprintf( stderr,
"usage: %s [-v] [-c] [-d debuglevel] [-f configfile]\n"
- "\t[-n databasenumber | -b suffix]", progname );
+ "\t[-n databasenumber | -b suffix]", progname );
switch( tool ) {
case SLAPADD:
- options = "\t[-s] [-l ldiffile]\n";
+ options = "\t[-l ldiffile]\n";
break;
case SLAPCAT:
switch( tool ) {
case SLAPADD:
- options = "b:cd:f:l:n:stv";
+ options = "b:cd:f:l:n:tv";
break;
case SLAPINDEX:
dbnum = atoi( optarg ) - 1;
break;
- case 's': /* disable schema checking */
- noschemacheck++;
- break;
-
case 't': /* turn on truncate */
truncatemode++;
mode |= SLAP_TRUNCATE_MODE;