]> git.sur5r.net Git - openldap/blob - servers/slapd/add.c
cleanup
[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             rc = doPreAddPluginFNs( be, pb );
474             if ( rc != LDAP_SUCCESS ) {
475                 /* plugin will have sent result */
476                 goto done;
477             }
478 #ifdef NEW_LOGGING
479             LDAP_LOG( OPERATION, INFO, 
480                        "do_add: conn %d  no backend support\n", conn->c_connid, 0, 0 );
481 #else
482             Debug( LDAP_DEBUG_ARGS, "    do_add: no backend support\n", 0, 0, 0 );
483 #endif
484             send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
485                               NULL, "operation not supported within namingContext", NULL, NULL );
486         }
487
488 #ifdef LDAP_SLAPI
489         doPostAddPluginFNs( be, pb );
490 #endif /* LDAP_SLAPI */
491
492 done:
493         if( modlist != NULL ) {
494                 slap_mods_free( modlist );
495         }
496         if( e != NULL ) {
497                 entry_free( e );
498         }
499
500         return rc;
501 }
502
503 int
504 slap_mods2entry(
505         Modifications *mods,
506         Entry **e,
507         int repl_user,
508         const char **text,
509         char *textbuf, size_t textlen )
510 {
511         Attribute **tail = &(*e)->e_attrs;
512         assert( *tail == NULL );
513
514         *text = textbuf;
515
516         for( ; mods != NULL; mods = mods->sml_next ) {
517                 Attribute *attr;
518
519                 assert( mods->sml_op == LDAP_MOD_ADD );
520                 assert( mods->sml_desc != NULL );
521
522                 attr = attr_find( (*e)->e_attrs, mods->sml_desc );
523
524                 if( attr != NULL ) {
525 #define SLURPD_FRIENDLY
526 #ifdef SLURPD_FRIENDLY
527                         ber_len_t i,j;
528
529                         if( !repl_user ) {
530                                 snprintf( textbuf, textlen,
531                                         "attribute '%s' provided more than once",
532                                         mods->sml_desc->ad_cname.bv_val );
533                                 return LDAP_TYPE_OR_VALUE_EXISTS;
534                         }
535
536                         for( i=0; attr->a_vals[i].bv_val; i++ ) {
537                                 /* count them */
538                         }
539                         for( j=0; mods->sml_bvalues[j].bv_val; j++ ) {
540                                 /* count them */
541                         }
542                         j++;    /* NULL */
543                         
544                         attr->a_vals = ch_realloc( attr->a_vals,
545                                 sizeof( struct berval ) * (i+j) );
546
547                         /* should check for duplicates */
548
549                         AC_MEMCPY( &attr->a_vals[i], mods->sml_bvalues,
550                                 sizeof( struct berval ) * j );
551
552                         /* trim the mods array */
553                         ch_free( mods->sml_bvalues );
554                         mods->sml_bvalues = NULL;
555
556                         continue;
557 #else
558                         snprintf( textbuf, textlen,
559                                 "attribute '%s' provided more than once",
560                                 mods->sml_desc->ad_cname.bv_val );
561                         return LDAP_TYPE_OR_VALUE_EXISTS;
562 #endif
563                 }
564
565                 if( mods->sml_bvalues[1].bv_val != NULL ) {
566                         /* check for duplicates */
567                         int             i, j;
568                         MatchingRule *mr = mods->sml_desc->ad_type->sat_equality;
569
570                         /* check if the values we're adding already exist */
571                         if( mr == NULL || !mr->smr_match ) {
572                                 for ( i = 0; mods->sml_bvalues[i].bv_val != NULL; i++ ) {
573                                         /* test asserted values against themselves */
574                                         for( j = 0; j < i; j++ ) {
575                                                 if ( bvmatch( &mods->sml_bvalues[i],
576                                                         &mods->sml_bvalues[j] ) ) {
577                                                         /* value exists already */
578                                                         snprintf( textbuf, textlen,
579                                                                 "%s: value #%d provided more than once",
580                                                                 mods->sml_desc->ad_cname.bv_val, j );
581                                                         return LDAP_TYPE_OR_VALUE_EXISTS;
582                                                 }
583                                         }
584                                 }
585
586                         } else {
587                                 int             rc;
588                                 const char      *text = NULL;
589                                 char            textbuf[ SLAP_TEXT_BUFLEN ]  = { '\0' };
590                                 
591                                 rc = modify_check_duplicates( mods->sml_desc, mr,
592                                                 NULL, mods->sml_bvalues, 0,
593                                                 &text, textbuf, sizeof( textbuf ) );
594
595                                 if ( rc != LDAP_SUCCESS ) {
596                                         return rc;
597                                 }
598                         }
599                 }
600
601                 attr = ch_calloc( 1, sizeof(Attribute) );
602
603                 /* move ad to attr structure */
604                 attr->a_desc = mods->sml_desc;
605                 mods->sml_desc = NULL;
606
607                 /* move values to attr structure */
608                 /*      should check for duplicates */
609                 attr->a_vals = mods->sml_bvalues;
610                 mods->sml_bvalues = NULL;
611
612                 *tail = attr;
613                 tail = &attr->a_next;
614         }
615
616         return LDAP_SUCCESS;
617 }
618
619 #ifdef LDAP_SLAPI
620 static Slapi_PBlock *initAddPlugin( Backend *be, Connection *conn, Operation *op,
621         struct berval *dn, Entry *e, int manageDSAit )
622 {
623         Slapi_PBlock *pb;
624
625         pb = op->o_pb;
626
627         slapi_x_backend_set_pb( pb, be );
628         slapi_x_connection_set_pb( pb, conn );
629         slapi_x_operation_set_pb( pb, op );
630
631         slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn->bv_val );
632         slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
633         slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
634
635         return pb;
636 }
637
638 static int doPreAddPluginFNs( Backend *be, Slapi_PBlock *pb )
639 {
640         int rc;
641
642         rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_ADD_FN, pb );
643         if ( rc != 0 ) {
644                 /*
645                  * A preoperation plugin failure will abort the
646                  * entire operation.
647                  */
648 #ifdef NEW_LOGGING
649                 LDAP_LOG( OPERATION, INFO, "do_add: add preoperation plugin failed\n",
650                                 0, 0, 0);
651 #else
652                 Debug(LDAP_DEBUG_TRACE, "do_add: add preoperation plugin failed.\n",
653                                 0, 0, 0);
654                 if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0 )
655                         rc = LDAP_OTHER;
656 #endif
657         } else {
658                 rc = LDAP_SUCCESS;
659         }
660
661         return rc;
662 }
663
664 static void doPostAddPluginFNs( Backend *be, Slapi_PBlock *pb )
665 {
666         int rc;
667
668         rc = doPluginFNs( be, SLAPI_PLUGIN_POST_ADD_FN, pb );
669         if ( rc != 0 ) {
670 #ifdef NEW_LOGGING
671                 LDAP_LOG( OPERATION, INFO, "do_add: add postoperation plugin failed\n",
672                                 0, 0, 0);
673 #else
674                 Debug(LDAP_DEBUG_TRACE, "do_add: add preoperation plugin failed.\n",
675                                 0, 0, 0);
676 #endif
677         }
678 }
679 #endif /* LDAP_SLAPI */