]> git.sur5r.net Git - openldap/blob - servers/slapd/add.c
cb93cee577f6705dc40491e3569a1fe96cf4beac
[openldap] / servers / slapd / add.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /*
7  * Copyright (c) 1995 Regents of the University of Michigan.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms are permitted
11  * provided that this notice is preserved and that due credit is given
12  * to the University of Michigan at Ann Arbor. The name of the University
13  * may not be used to endorse or promote products derived from this
14  * software without specific prior written permission. This software
15  * is provided ``as is'' without express or implied warranty.
16  */
17
18 #include "portable.h"
19
20 #include <stdio.h>
21 #include <ac/string.h>
22 #include <ac/time.h>
23 #include <ac/socket.h>
24
25 #include "ldap_pvt.h"
26 #include "slap.h"
27 #include "slapi.h"
28
29 #ifdef LDAP_SLAPI
30 static Slapi_PBlock *initAddPlugin( Backend *be, Connection *conn, Operation *op,
31         struct berval *dn, Entry *e, int manageDSAit );
32 static int doPreAddPluginFNs( Backend *be, Slapi_PBlock *pb );
33 static void doPostAddPluginFNs( Backend *be, Slapi_PBlock *pb );
34 #endif /* LDAP_SLAPI */
35
36 int
37 do_add( Connection *conn, Operation *op )
38 {
39         BerElement      *ber = op->o_ber;
40         char            *last;
41         struct berval dn = { 0, NULL };
42         ber_len_t       len;
43         ber_tag_t       tag;
44         Entry           *e;
45         Backend         *be;
46         Modifications   *modlist = NULL;
47         Modifications   **modtail = &modlist;
48         Modifications   tmp;
49         const char *text;
50         LDAPRDN         *rdn = NULL;
51         int             cnt;
52         int                     rc = LDAP_SUCCESS;
53         int     manageDSAit;
54 #ifdef LDAP_SLAPI
55         Slapi_PBlock    *pb = NULL;
56 #endif /* LDAP_SLAPI */
57
58 #ifdef NEW_LOGGING
59         LDAP_LOG( OPERATION, ENTRY, "do_add: conn %d enter\n", conn->c_connid,0,0 );
60 #else
61         Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 );
62 #endif
63         /*
64          * Parse the add request.  It looks like this:
65          *
66          *      AddRequest := [APPLICATION 14] SEQUENCE {
67          *              name    DistinguishedName,
68          *              attrs   SEQUENCE OF SEQUENCE {
69          *                      type    AttributeType,
70          *                      values  SET OF AttributeValue
71          *              }
72          *      }
73          */
74
75         /* get the name */
76         if ( ber_scanf( ber, "{m", /*}*/ &dn ) == LBER_ERROR ) {
77 #ifdef NEW_LOGGING
78                 LDAP_LOG( OPERATION, ERR, 
79                         "do_add: conn %d ber_scanf failed\n", conn->c_connid,0,0 );
80 #else
81                 Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
82 #endif
83                 send_ldap_disconnect( conn, op,
84                         LDAP_PROTOCOL_ERROR, "decoding error" );
85                 return -1;
86         }
87
88         e = (Entry *) ch_calloc( 1, sizeof(Entry) );
89
90         rc = dnPrettyNormal( NULL, &dn, &e->e_name, &e->e_nname );
91
92         if( rc != LDAP_SUCCESS ) {
93 #ifdef NEW_LOGGING
94                 LDAP_LOG( OPERATION, ERR, 
95                         "do_add: conn %d invalid dn (%s)\n", conn->c_connid, dn.bv_val, 0 );
96 #else
97                 Debug( LDAP_DEBUG_ANY, "do_add: invalid dn (%s)\n", dn.bv_val, 0, 0 );
98 #endif
99                 send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
100                             "invalid DN", NULL, NULL );
101                 goto done;
102         }
103
104 #ifdef NEW_LOGGING
105         LDAP_LOG( OPERATION, ARGS, 
106                 "do_add: conn %d  dn (%s)\n", conn->c_connid, e->e_dn, 0 );
107 #else
108         Debug( LDAP_DEBUG_ARGS, "do_add: dn (%s)\n", e->e_dn, 0, 0 );
109 #endif
110
111         /* get the attrs */
112         for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
113             tag = ber_next_element( ber, &len, last ) )
114         {
115                 Modifications *mod;
116                 ber_tag_t rtag;
117
118                 rtag = ber_scanf( ber, "{m{W}}", &tmp.sml_type, &tmp.sml_bvalues );
119
120                 if ( rtag == LBER_ERROR ) {
121 #ifdef NEW_LOGGING
122                         LDAP_LOG( OPERATION, ERR, 
123                                    "do_add: conn %d      decoding error \n", conn->c_connid, 0, 0 );
124 #else
125                         Debug( LDAP_DEBUG_ANY, "do_add: decoding error\n", 0, 0, 0 );
126 #endif
127                         send_ldap_disconnect( conn, op,
128                                 LDAP_PROTOCOL_ERROR, "decoding error" );
129                         rc = -1;
130                         goto done;
131                 }
132
133                 if ( tmp.sml_bvalues == NULL ) {
134 #ifdef NEW_LOGGING
135                         LDAP_LOG( OPERATION, INFO, 
136                                 "do_add: conn %d         no values for type %s\n",
137                                 conn->c_connid, tmp.sml_type.bv_val, 0 );
138 #else
139                         Debug( LDAP_DEBUG_ANY, "no values for type %s\n",
140                                 tmp.sml_type.bv_val, 0, 0 );
141 #endif
142                         send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
143                                 NULL, "no values for attribute type", NULL, NULL );
144                         goto done;
145                 }
146                 mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
147                 
148                 mod->sml_op = LDAP_MOD_ADD;
149                 mod->sml_next = NULL;
150                 mod->sml_desc = NULL;
151                 mod->sml_type = tmp.sml_type;
152                 mod->sml_bvalues = tmp.sml_bvalues;
153
154                 *modtail = mod;
155                 modtail = &mod->sml_next;
156         }
157
158         if ( ber_scanf( ber, /*{*/ "}") == LBER_ERROR ) {
159 #ifdef NEW_LOGGING
160                 LDAP_LOG( OPERATION, ERR, 
161                         "do_add: conn %d ber_scanf failed\n", conn->c_connid, 0, 0 );
162 #else
163                 Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
164 #endif
165                 send_ldap_disconnect( conn, op,
166                         LDAP_PROTOCOL_ERROR, "decoding error" );
167                 rc = -1;
168                 goto done;
169         }
170
171         if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
172 #ifdef NEW_LOGGING
173                 LDAP_LOG( OPERATION, INFO, 
174                         "do_add: conn %d get_ctrls failed\n", conn->c_connid, 0, 0 );
175 #else
176                 Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
177 #endif
178                 goto done;
179         } 
180
181         if ( modlist == NULL ) {
182                 send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
183                         NULL, "no attributes provided", NULL, NULL );
184                 goto done;
185         }
186
187         Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu ADD dn=\"%s\"\n",
188             op->o_connid, op->o_opid, e->e_dn, 0, 0 );
189
190         if( e->e_nname.bv_len == 0 ) {
191                 /* protocolError may be a more appropriate error */
192                 send_ldap_result( conn, op, rc = LDAP_ALREADY_EXISTS,
193                         NULL, "root DSE already exists",
194                         NULL, NULL );
195                 goto done;
196
197         } else if ( bvmatch( &e->e_nname, &global_schemandn ) ) {
198                 send_ldap_result( conn, op, rc = LDAP_ALREADY_EXISTS,
199                         NULL, "subschema subentry already exists",
200                         NULL, NULL );
201                 goto done;
202         }
203
204         /*
205          * Get attribute type(s) and attribute value(s) of our rdn,
206          */
207         if ( ldap_bv2rdn( &e->e_name, &rdn, (char **)&text,
208                 LDAP_DN_FORMAT_LDAP ) )
209         {
210                 send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX,
211                         NULL, "unknown type(s) used in RDN",
212                         NULL, NULL );
213                 goto done;
214         }
215
216         /* Check for RDN attrs in entry */
217         for ( cnt = 0; rdn[ 0 ][ cnt ]; cnt++ ) {
218                 AttributeDescription    *desc = NULL;
219                 Modifications           *mod;
220                 MatchingRule            *mr;
221                 int                     i;
222
223                 rc = slap_bv2ad( &rdn[ 0 ][ cnt ]->la_attr, 
224                                 &desc, &text );
225
226                 if ( rc != LDAP_SUCCESS ) {
227                         send_ldap_result( conn, op, rc,
228                                         NULL, text, NULL, NULL );
229                         goto done;
230                 }
231
232                 for (mod = modlist; mod; mod = mod->sml_next) {
233                         AttributeDescription    *mod_desc = NULL;
234
235                         rc = slap_bv2ad( &mod->sml_type, 
236                                         &mod_desc, &text );
237                         if ( rc != LDAP_SUCCESS ) {
238                                 send_ldap_result( conn, op, rc,
239                                                 NULL, text, NULL, NULL );
240                                 goto done;
241                         }
242
243                         if (mod_desc == desc) {
244                                 break;
245                         }
246                 }
247
248                 if (mod == NULL) {
249 #define BAILOUT
250 #ifdef BAILOUT
251                         /* bail out */
252                         send_ldap_result( conn, op, 
253                                 rc = LDAP_NO_SUCH_ATTRIBUTE,
254                                 NULL,
255                                 "RDN attribute value assertion not present in entry", 
256                                 NULL, NULL );
257                         goto done;
258
259 #else /* ! BAILOUT */
260                         struct berval   bv;
261         
262                         /* add attribute type and value to modlist */
263                         mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
264                 
265                         mod->sml_op = LDAP_MOD_ADD;
266                         mod->sml_next = NULL;
267                         mod->sml_desc = NULL;
268
269                         ber_dupbv( &mod->sml_type,
270                                         &rdn[ 0 ][ cnt ]->la_attr );
271
272                         mod->sml_bvalues = NULL;
273                         ber_dupbv( &bv, &rdn[ 0 ][ cnt ]->la_value );
274                         ber_bvarray_add( &mod->sml_bvalues, &bv );
275
276                         *modtail = mod;
277                         modtail = &mod->sml_next;
278                         continue;
279 #endif /* ! BAILOUT */
280                 }
281
282                 mr = desc->ad_type->sat_equality;
283                 if (mr == NULL || !mr->smr_match ) {
284                         /* bail out */
285                         send_ldap_result( conn, op, 
286                                         rc = LDAP_INVALID_SYNTAX,
287                                         NULL,
288                                         "attribute in RDN lacks matching rule", 
289                                         NULL, NULL );
290                         goto done;
291                 }
292
293                 for (i = 0; mod->sml_bvalues[ i ].bv_val; i++) {
294                         int             match = 0;
295                         
296                         rc = value_match(&match, desc, mr,
297                                         SLAP_MR_VALUE_SYNTAX_MATCH,
298                                         &mod->sml_bvalues[ i ],
299                                         &rdn[ 0 ][ cnt ]->la_value, &text);
300
301                         if ( rc != LDAP_SUCCESS ) {
302                                 send_ldap_result( conn, op, rc,
303                                                 NULL, text, NULL, NULL);
304                                 goto done;
305                         }
306
307                         if (match == 0) {
308                                 break;
309                         }
310                 }
311
312                 /* not found? */
313                 if (mod->sml_bvalues[ i ].bv_val == NULL) {
314 #ifdef BAILOUT
315                         /* bailout */
316                         send_ldap_result( conn, op, 
317                                         rc = LDAP_NO_SUCH_ATTRIBUTE,
318                                         NULL,
319                                         "value in RDN not listed in entry", 
320                                         NULL, NULL );
321                         goto done;
322
323 #else /* ! BAILOUT */
324                         struct berval   bv;
325
326                         /* add attribute type and value to modlist */
327                         ber_dupbv( &bv, &rdn[ 0 ][ cnt ]->la_value );
328                         ber_bvarray_add( &mod->sml_bvalues, &bv );
329                         continue;
330 #endif /* ! BAILOUT */
331                 }
332         }
333
334         manageDSAit = get_manageDSAit( op );
335
336         /*
337          * We could be serving multiple database backends.  Select the
338          * appropriate one, or send a referral to our "referral server"
339          * if we don't hold it.
340          */
341         be = select_backend( &e->e_nname, manageDSAit, 0 );
342         if ( be == NULL ) {
343                 BerVarray ref = referral_rewrite( default_referral,
344                         NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
345
346                 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
347                         NULL, NULL, ref ? ref : default_referral, NULL );
348
349                 if ( ref ) ber_bvarray_free( ref );
350                 goto done;
351         }
352
353         /* check restrictions */
354         rc = backend_check_restrictions( be, conn, op, NULL, &text ) ;
355         if( rc != LDAP_SUCCESS ) {
356                 send_ldap_result( conn, op, rc,
357                         NULL, text, NULL, NULL );
358                 goto done;
359         }
360
361         /* check for referrals */
362         rc = backend_check_referrals( be, conn, op, &e->e_name, &e->e_nname );
363         if ( rc != LDAP_SUCCESS ) {
364                 goto done;
365         }
366
367 #ifdef LDAP_SLAPI
368         pb = initAddPlugin( be, conn, op, &dn, e, manageDSAit );
369 #endif /* LDAP_SLAPI */
370
371         /*
372          * do the add if 1 && (2 || 3)
373          * 1) there is an add function implemented in this backend;
374          * 2) this backend is master for what it holds;
375          * 3) it's a replica and the dn supplied is the updatedn.
376          */
377         if ( be->be_add ) {
378                 /* do the update here */
379                 int repl_user = be_isupdate(be, &op->o_ndn );
380 #ifndef SLAPD_MULTIMASTER
381                 if ( !be->be_update_ndn.bv_len || repl_user )
382 #endif
383                 {
384                         int update = be->be_update_ndn.bv_len;
385                         char textbuf[SLAP_TEXT_BUFLEN];
386                         size_t textlen = sizeof textbuf;
387
388                         rc = slap_mods_check( modlist, update, &text,
389                                 textbuf, textlen );
390
391                         if( rc != LDAP_SUCCESS ) {
392                                 send_ldap_result( conn, op, rc,
393                                         NULL, text, NULL, NULL );
394                                 goto done;
395                         }
396
397                         if ( !repl_user ) {
398                                 for( modtail = &modlist;
399                                         *modtail != NULL;
400                                         modtail = &(*modtail)->sml_next )
401                                 {
402                                         assert( (*modtail)->sml_op == LDAP_MOD_ADD );
403                                         assert( (*modtail)->sml_desc != NULL );
404                                 }
405                                 rc = slap_mods_opattrs( be, op, modlist, modtail, &text,
406                                         textbuf, textlen );
407                                 if( rc != LDAP_SUCCESS ) {
408                                         send_ldap_result( conn, op, rc,
409                                                 NULL, text, NULL, NULL );
410                                         goto done;
411                                 }
412                         }
413
414                         rc = slap_mods2entry( modlist, &e, repl_user, &text,
415                                 textbuf, textlen );
416                         if( rc != LDAP_SUCCESS ) {
417                                 send_ldap_result( conn, op, rc,
418                                         NULL, text, NULL, NULL );
419                                 goto done;
420                         }
421
422 #ifdef LDAP_SLAPI
423                         /*
424                          * Call the preoperation plugin here, because the entry
425                          * will actually contain something.
426                          */
427                         rc = doPreAddPluginFNs( be, pb );
428                         if ( rc != LDAP_SUCCESS ) {
429                                 /* plugin will have sent result */
430                                 goto done;
431                         }
432 #endif /* LDAP_SLAPI */
433
434                         if ( (*be->be_add)( be, conn, op, e ) == 0 ) {
435 #ifdef SLAPD_MULTIMASTER
436                                 if ( !repl_user )
437 #endif
438                                 {
439                                         replog( be, op, &e->e_name, &e->e_nname, e );
440                                 }
441                                 be_entry_release_w( be, conn, op, e );
442                                 e = NULL;
443                         }
444
445 #ifndef SLAPD_MULTIMASTER
446                 } else {
447                         BerVarray defref;
448                         BerVarray ref;
449 #ifdef LDAP_SLAPI
450                         /*
451                          * SLAPI_ADD_ENTRY will be empty, but this may be acceptable
452                          * on replicas (for now, it involves the minimum code intrusion).
453                          */
454                         rc = doPreAddPluginFNs( be, pb );
455                         if ( rc != LDAP_SUCCESS ) {
456                                 /* plugin will have sent result */
457                                 goto done;
458                         }
459 #endif /* LDAP_SLAPI */
460
461                         defref = be->be_update_refs
462                                 ? be->be_update_refs : default_referral;
463                         ref = referral_rewrite( defref,
464                                 NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
465
466                         send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
467                                 ref ? ref : defref, NULL );
468
469                         if ( ref ) ber_bvarray_free( ref );
470 #endif /* SLAPD_MULTIMASTER */
471                 }
472         } else {
473 #ifdef LDAP_SLAPI
474             rc = doPreAddPluginFNs( be, pb );
475             if ( rc != LDAP_SUCCESS ) {
476                 /* plugin will have sent result */
477                 goto done;
478             }
479 #endif
480 #ifdef NEW_LOGGING
481             LDAP_LOG( OPERATION, INFO, 
482                        "do_add: conn %d  no backend support\n", conn->c_connid, 0, 0 );
483 #else
484             Debug( LDAP_DEBUG_ARGS, "    do_add: no backend support\n", 0, 0, 0 );
485 #endif
486             send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
487                               NULL, "operation not supported within namingContext", NULL, NULL );
488         }
489
490 #ifdef LDAP_SLAPI
491         doPostAddPluginFNs( be, pb );
492 #endif /* LDAP_SLAPI */
493
494 done:
495         if( modlist != NULL ) {
496                 slap_mods_free( modlist );
497         }
498         if( e != NULL ) {
499                 entry_free( e );
500         }
501
502         return rc;
503 }
504
505 int
506 slap_mods2entry(
507         Modifications *mods,
508         Entry **e,
509         int repl_user,
510         const char **text,
511         char *textbuf, size_t textlen )
512 {
513         Attribute **tail = &(*e)->e_attrs;
514         assert( *tail == NULL );
515
516         *text = textbuf;
517
518         for( ; mods != NULL; mods = mods->sml_next ) {
519                 Attribute *attr;
520
521                 assert( mods->sml_op == LDAP_MOD_ADD );
522                 assert( mods->sml_desc != NULL );
523
524                 attr = attr_find( (*e)->e_attrs, mods->sml_desc );
525
526                 if( attr != NULL ) {
527 #define SLURPD_FRIENDLY
528 #ifdef SLURPD_FRIENDLY
529                         ber_len_t i,j;
530
531                         if( !repl_user ) {
532                                 snprintf( textbuf, textlen,
533                                         "attribute '%s' provided more than once",
534                                         mods->sml_desc->ad_cname.bv_val );
535                                 return LDAP_TYPE_OR_VALUE_EXISTS;
536                         }
537
538                         for( i=0; attr->a_vals[i].bv_val; i++ ) {
539                                 /* count them */
540                         }
541                         for( j=0; mods->sml_bvalues[j].bv_val; j++ ) {
542                                 /* count them */
543                         }
544                         j++;    /* NULL */
545                         
546                         attr->a_vals = ch_realloc( attr->a_vals,
547                                 sizeof( struct berval ) * (i+j) );
548
549                         /* should check for duplicates */
550
551                         AC_MEMCPY( &attr->a_vals[i], mods->sml_bvalues,
552                                 sizeof( struct berval ) * j );
553
554                         /* trim the mods array */
555                         ch_free( mods->sml_bvalues );
556                         mods->sml_bvalues = NULL;
557
558                         continue;
559 #else
560                         snprintf( textbuf, textlen,
561                                 "attribute '%s' provided more than once",
562                                 mods->sml_desc->ad_cname.bv_val );
563                         return LDAP_TYPE_OR_VALUE_EXISTS;
564 #endif
565                 }
566
567                 if( mods->sml_bvalues[1].bv_val != NULL ) {
568                         /* check for duplicates */
569                         int             i, j;
570                         MatchingRule *mr = mods->sml_desc->ad_type->sat_equality;
571
572                         /* check if the values we're adding already exist */
573                         if( mr == NULL || !mr->smr_match ) {
574                                 for ( i = 0; mods->sml_bvalues[i].bv_val != NULL; i++ ) {
575                                         /* test asserted values against themselves */
576                                         for( j = 0; j < i; j++ ) {
577                                                 if ( bvmatch( &mods->sml_bvalues[i],
578                                                         &mods->sml_bvalues[j] ) ) {
579                                                         /* value exists already */
580                                                         snprintf( textbuf, textlen,
581                                                                 "%s: value #%d provided more than once",
582                                                                 mods->sml_desc->ad_cname.bv_val, j );
583                                                         return LDAP_TYPE_OR_VALUE_EXISTS;
584                                                 }
585                                         }
586                                 }
587
588                         } else {
589                                 int             rc;
590                                 const char      *text = NULL;
591                                 char            textbuf[ SLAP_TEXT_BUFLEN ]  = { '\0' };
592                                 
593                                 rc = modify_check_duplicates( mods->sml_desc, mr,
594                                                 NULL, mods->sml_bvalues, 0,
595                                                 &text, textbuf, sizeof( textbuf ) );
596
597                                 if ( rc != LDAP_SUCCESS ) {
598                                         return rc;
599                                 }
600                         }
601                 }
602
603                 attr = ch_calloc( 1, sizeof(Attribute) );
604
605                 /* move ad to attr structure */
606                 attr->a_desc = mods->sml_desc;
607                 mods->sml_desc = NULL;
608
609                 /* move values to attr structure */
610                 /*      should check for duplicates */
611                 attr->a_vals = mods->sml_bvalues;
612                 mods->sml_bvalues = NULL;
613
614                 *tail = attr;
615                 tail = &attr->a_next;
616         }
617
618         return LDAP_SUCCESS;
619 }
620
621 #ifdef LDAP_SLAPI
622 static Slapi_PBlock *initAddPlugin( Backend *be, Connection *conn, Operation *op,
623         struct berval *dn, Entry *e, int manageDSAit )
624 {
625         Slapi_PBlock *pb;
626
627         pb = op->o_pb;
628
629         slapi_x_backend_set_pb( pb, be );
630         slapi_x_connection_set_pb( pb, conn );
631         slapi_x_operation_set_pb( pb, op );
632
633         slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn->bv_val );
634         slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
635         slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
636
637         return pb;
638 }
639
640 static int doPreAddPluginFNs( Backend *be, Slapi_PBlock *pb )
641 {
642         int rc;
643
644         rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_ADD_FN, pb );
645         if ( rc != 0 ) {
646                 /*
647                  * A preoperation plugin failure will abort the
648                  * entire operation.
649                  */
650 #ifdef NEW_LOGGING
651                 LDAP_LOG( OPERATION, INFO, "do_add: add preoperation plugin failed\n",
652                                 0, 0, 0);
653 #else
654                 Debug(LDAP_DEBUG_TRACE, "do_add: add preoperation plugin failed.\n",
655                                 0, 0, 0);
656                 if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0 )
657                         rc = LDAP_OTHER;
658 #endif
659         } else {
660                 rc = LDAP_SUCCESS;
661         }
662
663         return rc;
664 }
665
666 static void doPostAddPluginFNs( Backend *be, Slapi_PBlock *pb )
667 {
668         int rc;
669
670         rc = doPluginFNs( be, SLAPI_PLUGIN_POST_ADD_FN, pb );
671         if ( rc != 0 ) {
672 #ifdef NEW_LOGGING
673                 LDAP_LOG( OPERATION, INFO, "do_add: add postoperation plugin failed\n",
674                                 0, 0, 0);
675 #else
676                 Debug(LDAP_DEBUG_TRACE, "do_add: add preoperation plugin failed.\n",
677                                 0, 0, 0);
678 #endif
679         }
680 }
681 #endif /* LDAP_SLAPI */