2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/string.h>
13 #include <ac/socket.h>
14 #include <ac/unistd.h>
16 #include "slapcommon.h"
19 main( int argc, char **argv )
24 int rc = EXIT_SUCCESS;
26 slap_tool_init( "slapadd", SLAPADD, argc, argv );
28 if( !be->be_entry_open &&
29 !be->be_entry_close &&
32 fprintf( stderr, "%s: database doesn't support necessary operations.\n",
40 if( be->be_entry_open( be, 1 ) != 0 ) {
41 fprintf( stderr, "%s: could not open database.\n",
46 while( ldif_read_record( ldiffp, &lineno, &buf, &lmax ) ) {
48 Entry *e = str2entry( buf );
51 fprintf( stderr, "%s: could not parse entry (line=%d)\n",
54 if( continuemode ) continue;
58 if( !noschemacheck ) {
59 /* make sure the DN is valid */
60 if( dn_normalize_case( e->e_ndn ) == NULL ) {
61 fprintf( stderr, "%s: bad dn=\"%s\" (line=%d)\n",
62 progname, e->e_dn, lineno );
65 if( continuemode ) continue;
70 if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
71 fprintf( stderr, "%s: entry dn=\"%s\" violates schema violation (line=%d)\n",
72 progname, e->e_dn, lineno );
75 if( continuemode ) continue;
80 if( select_backend( e->e_ndn ) != be ) {
81 fprintf( stderr, "%s: database not configured to hold dn=\"%s\" (line=%d)\n",
82 progname, e->e_dn, lineno );
85 if( continuemode ) continue;
90 id = be->be_entry_put( be, e );
93 fprintf( stderr, "%s: could not add entry dn=\"%s\" (line=%d)\n",
94 progname, e->e_dn, lineno );
97 if( continuemode ) continue;
100 } else if ( verbose ) {
101 fprintf( stderr, "added: \"%s\" (%08lx)\n",
102 e->e_dn, (long) id );
108 be->be_entry_close( be );