3 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
10 #include <ac/stdlib.h>
13 #include <ac/string.h>
14 #include <ac/socket.h>
15 #include <ac/unistd.h>
17 #include "slapcommon.h"
20 main( int argc, char **argv )
25 int rc = EXIT_SUCCESS;
27 slap_tool_init( "slapadd", SLAPADD, argc, argv );
29 if( !be->be_entry_open &&
30 !be->be_entry_close &&
33 fprintf( stderr, "%s: database doesn't support necessary operations.\n",
42 if( be->be_entry_open( be, 1 ) != 0 ) {
43 fprintf( stderr, "%s: could not open database.\n",
48 while( ldif_read_record( ldiffp, &lineno, &buf, &lmax ) ) {
50 Entry *e = str2entry( buf );
53 fprintf( stderr, "%s: could not parse entry (line=%d)\n",
56 if( continuemode ) continue;
60 if( !noschemacheck ) {
61 /* make sure the DN is valid */
62 if( dn_normalize( e->e_ndn ) == NULL ) {
63 fprintf( stderr, "%s: bad dn=\"%s\" (line=%d)\n",
64 progname, e->e_dn, lineno );
67 if( continuemode ) continue;
72 if ( global_schemacheck && oc_schema_check( e ) != 0 ) {
73 fprintf( stderr, "%s: schema violation in entry dn=\"%s\" (line=%d)\n",
74 progname, e->e_dn, lineno );
77 if( continuemode ) continue;
82 if( select_backend( e->e_ndn ) != be ) {
83 fprintf( stderr, "%s: database not configured to hold dn=\"%s\" (line=%d)\n",
84 progname, e->e_dn, lineno );
87 if( continuemode ) continue;
92 id = be->be_entry_put( be, e );
95 fprintf( stderr, "%s: could not add entry dn=\"%s\" (line=%d)\n",
96 progname, e->e_dn, lineno );
99 if( continuemode ) continue;
102 } else if ( verbose ) {
103 fprintf( stderr, "added: \"%s\" (%08lx)\n",
104 e->e_dn, (long) id );
112 be->be_entry_close( be );