]> git.sur5r.net Git - openldap/blob - servers/slapd/add.c
Remove FIXME stuff (ITS#2243)
[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, *mod;
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         if ( mod->sml_bvalues[ cnt ].bv_val == NULL ) {
205                 /*
206                  * Get attribute type(s) and attribute value(s) of our rdn,
207                  */
208                 if ( ldap_bv2rdn( &e->e_name, &rdn, (char **)&text,
209                         LDAP_DN_FORMAT_LDAP ) )
210                 {
211                         send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX,
212                                 NULL, "unknown type(s) used in RDN",
213                                 NULL, NULL );
214                         goto done;
215                 }
216
217                 /* Check for RDN attrs in entry */
218                 for ( cnt = 0; rdn[ 0 ][ cnt ]; cnt++ ) {
219                         AttributeDescription    *desc = NULL;
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
335         manageDSAit = get_manageDSAit( op );
336
337         /*
338          * We could be serving multiple database backends.  Select the
339          * appropriate one, or send a referral to our "referral server"
340          * if we don't hold it.
341          */
342         be = select_backend( &e->e_nname, manageDSAit, 0 );
343         if ( be == NULL ) {
344                 BerVarray ref = referral_rewrite( default_referral,
345                         NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
346
347                 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
348                         NULL, NULL, ref ? ref : default_referral, NULL );
349
350                 if ( ref ) ber_bvarray_free( ref );
351                 goto done;
352         }
353
354         /* check restrictions */
355         rc = backend_check_restrictions( be, conn, op, NULL, &text ) ;
356         if( rc != LDAP_SUCCESS ) {
357                 send_ldap_result( conn, op, rc,
358                         NULL, text, NULL, NULL );
359                 goto done;
360         }
361
362         /* check for referrals */
363         rc = backend_check_referrals( be, conn, op, &e->e_name, &e->e_nname );
364         if ( rc != LDAP_SUCCESS ) {
365                 goto done;
366         }
367
368 #ifdef LDAP_SLAPI
369         pb = initAddPlugin( be, conn, op, &dn, e, manageDSAit );
370 #endif /* LDAP_SLAPI */
371
372         /*
373          * do the add if 1 && (2 || 3)
374          * 1) there is an add function implemented in this backend;
375          * 2) this backend is master for what it holds;
376          * 3) it's a replica and the dn supplied is the updatedn.
377          */
378         if ( be->be_add ) {
379                 /* do the update here */
380                 int repl_user = be_isupdate(be, &op->o_ndn );
381 #ifndef SLAPD_MULTIMASTER
382                 if ( !be->be_update_ndn.bv_len || repl_user )
383 #endif
384                 {
385                         int update = be->be_update_ndn.bv_len;
386                         char textbuf[SLAP_TEXT_BUFLEN];
387                         size_t textlen = sizeof textbuf;
388
389                         rc = slap_mods_check( modlist, update, &text,
390                                 textbuf, textlen );
391
392                         if( rc != LDAP_SUCCESS ) {
393                                 send_ldap_result( conn, op, rc,
394                                         NULL, text, NULL, NULL );
395                                 goto done;
396                         }
397
398                         if ( !repl_user ) {
399                                 for( modtail = &modlist;
400                                         *modtail != NULL;
401                                         modtail = &(*modtail)->sml_next )
402                                 {
403                                         assert( (*modtail)->sml_op == LDAP_MOD_ADD );
404                                         assert( (*modtail)->sml_desc != NULL );
405                                 }
406                                 rc = slap_mods_opattrs( be, op, modlist, modtail, &text,
407                                         textbuf, textlen );
408                                 if( rc != LDAP_SUCCESS ) {
409                                         send_ldap_result( conn, op, rc,
410                                                 NULL, text, NULL, NULL );
411                                         goto done;
412                                 }
413                         }
414
415                         rc = slap_mods2entry( modlist, &e, repl_user, &text,
416                                 textbuf, textlen );
417                         if( rc != LDAP_SUCCESS ) {
418                                 send_ldap_result( conn, op, rc,
419                                         NULL, text, NULL, NULL );
420                                 goto done;
421                         }
422
423 #ifdef LDAP_SLAPI
424                         /*
425                          * Call the preoperation plugin here, because the entry
426                          * will actually contain something.
427                          */
428                         rc = doPreAddPluginFNs( be, pb );
429                         if ( rc != LDAP_SUCCESS ) {
430                                 /* plugin will have sent result */
431                                 goto done;
432                         }
433 #endif /* LDAP_SLAPI */
434
435                         if ( (*be->be_add)( be, conn, op, e ) == 0 ) {
436 #ifdef SLAPD_MULTIMASTER
437                                 if ( !repl_user )
438 #endif
439                                 {
440                                         replog( be, op, &e->e_name, &e->e_nname, e );
441                                 }
442                                 be_entry_release_w( be, conn, op, e );
443                                 e = NULL;
444                         }
445
446 #ifndef SLAPD_MULTIMASTER
447                 } else {
448                         BerVarray defref;
449                         BerVarray ref;
450 #ifdef LDAP_SLAPI
451                         /*
452                          * SLAPI_ADD_ENTRY will be empty, but this may be acceptable
453                          * on replicas (for now, it involves the minimum code intrusion).
454                          */
455                         rc = doPreAddPluginFNs( be, pb );
456                         if ( rc != LDAP_SUCCESS ) {
457                                 /* plugin will have sent result */
458                                 goto done;
459                         }
460 #endif /* LDAP_SLAPI */
461
462                         defref = be->be_update_refs
463                                 ? be->be_update_refs : default_referral;
464                         ref = referral_rewrite( defref,
465                                 NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
466
467                         send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
468                                 ref ? ref : defref, NULL );
469
470                         if ( ref ) ber_bvarray_free( ref );
471 #endif /* SLAPD_MULTIMASTER */
472                 }
473         } else {
474             rc = doPreAddPluginFNs( be, pb );
475             if ( rc != LDAP_SUCCESS ) {
476                 /* plugin will have sent result */
477                 goto done;
478             }
479 #ifdef NEW_LOGGING
480             LDAP_LOG( OPERATION, INFO, 
481                        "do_add: conn %d  no backend support\n", conn->c_connid, 0, 0 );
482 #else
483             Debug( LDAP_DEBUG_ARGS, "    do_add: no backend support\n", 0, 0, 0 );
484 #endif
485             send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
486                               NULL, "operation not supported within namingContext", NULL, NULL );
487         }
488
489 #ifdef LDAP_SLAPI
490         doPostAddPluginFNs( be, pb );
491 #endif /* LDAP_SLAPI */
492
493 done:
494         if( modlist != NULL ) {
495                 slap_mods_free( modlist );
496         }
497         if( e != NULL ) {
498                 entry_free( e );
499         }
500
501         return rc;
502 }
503
504 int
505 slap_mods2entry(
506         Modifications *mods,
507         Entry **e,
508         int repl_user,
509         const char **text,
510         char *textbuf, size_t textlen )
511 {
512         Attribute **tail = &(*e)->e_attrs;
513         assert( *tail == NULL );
514
515         *text = textbuf;
516
517         for( ; mods != NULL; mods = mods->sml_next ) {
518                 Attribute *attr;
519
520                 assert( mods->sml_op == LDAP_MOD_ADD );
521                 assert( mods->sml_desc != NULL );
522
523                 attr = attr_find( (*e)->e_attrs, mods->sml_desc );
524
525                 if( attr != NULL ) {
526 #define SLURPD_FRIENDLY
527 #ifdef SLURPD_FRIENDLY
528                         ber_len_t i,j;
529
530                         if( !repl_user ) {
531                                 snprintf( textbuf, textlen,
532                                         "attribute '%s' provided more than once",
533                                         mods->sml_desc->ad_cname.bv_val );
534                                 return LDAP_TYPE_OR_VALUE_EXISTS;
535                         }
536
537                         for( i=0; attr->a_vals[i].bv_val; i++ ) {
538                                 /* count them */
539                         }
540                         for( j=0; mods->sml_bvalues[j].bv_val; j++ ) {
541                                 /* count them */
542                         }
543                         j++;    /* NULL */
544                         
545                         attr->a_vals = ch_realloc( attr->a_vals,
546                                 sizeof( struct berval ) * (i+j) );
547
548                         /* should check for duplicates */
549
550                         AC_MEMCPY( &attr->a_vals[i], mods->sml_bvalues,
551                                 sizeof( struct berval ) * j );
552
553                         /* trim the mods array */
554                         ch_free( mods->sml_bvalues );
555                         mods->sml_bvalues = NULL;
556
557                         continue;
558 #else
559                         snprintf( textbuf, textlen,
560                                 "attribute '%s' provided more than once",
561                                 mods->sml_desc->ad_cname.bv_val );
562                         return LDAP_TYPE_OR_VALUE_EXISTS;
563 #endif
564                 }
565
566                 if( mods->sml_bvalues[1].bv_val != NULL ) {
567                         /* check for duplicates */
568                         int             i, j;
569                         MatchingRule *mr = mods->sml_desc->ad_type->sat_equality;
570
571                         /* check if the values we're adding already exist */
572                         if( mr == NULL || !mr->smr_match ) {
573                                 for ( i = 0; mods->sml_bvalues[i].bv_val != NULL; i++ ) {
574                                         /* test asserted values against themselves */
575                                         for( j = 0; j < i; j++ ) {
576                                                 if ( bvmatch( &mods->sml_bvalues[i],
577                                                         &mods->sml_bvalues[j] ) ) {
578                                                         /* value exists already */
579                                                         snprintf( textbuf, textlen,
580                                                                 "%s: value #%d provided more than once",
581                                                                 mods->sml_desc->ad_cname.bv_val, j );
582                                                         return LDAP_TYPE_OR_VALUE_EXISTS;
583                                                 }
584                                         }
585                                 }
586
587                         } else {
588                                 int             rc;
589                                 const char      *text = NULL;
590                                 char            textbuf[ SLAP_TEXT_BUFLEN ]  = { '\0' };
591                                 
592                                 rc = modify_check_duplicates( mods->sml_desc, mr,
593                                                 NULL, mods->sml_bvalues, 0,
594                                                 &text, textbuf, sizeof( textbuf ) );
595
596                                 if ( rc != LDAP_SUCCESS ) {
597                                         return rc;
598                                 }
599                         }
600                 }
601
602                 attr = ch_calloc( 1, sizeof(Attribute) );
603
604                 /* move ad to attr structure */
605                 attr->a_desc = mods->sml_desc;
606                 mods->sml_desc = NULL;
607
608                 /* move values to attr structure */
609                 /*      should check for duplicates */
610                 attr->a_vals = mods->sml_bvalues;
611                 mods->sml_bvalues = NULL;
612
613                 *tail = attr;
614                 tail = &attr->a_next;
615         }
616
617         return LDAP_SUCCESS;
618 }
619
620 #ifdef LDAP_SLAPI
621 static Slapi_PBlock *initAddPlugin( Backend *be, Connection *conn, Operation *op,
622         struct berval *dn, Entry *e, int manageDSAit )
623 {
624         Slapi_PBlock *pb;
625
626         pb = op->o_pb;
627
628         slapi_x_backend_set_pb( pb, be );
629         slapi_x_connection_set_pb( pb, conn );
630         slapi_x_operation_set_pb( pb, op );
631
632         slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn->bv_val );
633         slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
634         slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
635
636         return pb;
637 }
638
639 static int doPreAddPluginFNs( Backend *be, Slapi_PBlock *pb )
640 {
641         int rc;
642
643         rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_ADD_FN, pb );
644         if ( rc != 0 ) {
645                 /*
646                  * A preoperation plugin failure will abort the
647                  * entire operation.
648                  */
649 #ifdef NEW_LOGGING
650                 LDAP_LOG( OPERATION, INFO, "do_add: add preoperation plugin failed\n",
651                                 0, 0, 0);
652 #else
653                 Debug(LDAP_DEBUG_TRACE, "do_add: add preoperation plugin failed.\n",
654                                 0, 0, 0);
655                 if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0 )
656                         rc = LDAP_OTHER;
657 #endif
658         } else {
659                 rc = LDAP_SUCCESS;
660         }
661
662         return rc;
663 }
664
665 static void doPostAddPluginFNs( Backend *be, Slapi_PBlock *pb )
666 {
667         int rc;
668
669         rc = doPluginFNs( be, SLAPI_PLUGIN_POST_ADD_FN, pb );
670         if ( rc != 0 ) {
671 #ifdef NEW_LOGGING
672                 LDAP_LOG( OPERATION, INFO, "do_add: add postoperation plugin failed\n",
673                                 0, 0, 0);
674 #else
675                 Debug(LDAP_DEBUG_TRACE, "do_add: add preoperation plugin failed.\n",
676                                 0, 0, 0);
677 #endif
678         }
679 }
680 #endif /* LDAP_SLAPI */