]> git.sur5r.net Git - openldap/blob - servers/slapd/add.c
ff1e30555061411c3ada3db5529a88ca30aa8505
[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                         if ( !global_add_rdn_values ) {
250                         /* bail out */
251                         send_ldap_result( conn, op, 
252                                 rc = LDAP_NO_SUCH_ATTRIBUTE,
253                                 NULL,
254                                 "RDN attribute value assertion not present in entry", 
255                                 NULL, NULL );
256                         goto done;
257
258                         } else {
259                         struct berval   bv;
260         
261                         /* add attribute type and value to modlist */
262                         mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
263                 
264                         mod->sml_op = LDAP_MOD_ADD;
265                         mod->sml_next = NULL;
266                         mod->sml_desc = NULL;
267
268                         ber_dupbv( &mod->sml_type,
269                                         &rdn[ 0 ][ cnt ]->la_attr );
270
271                         mod->sml_bvalues = NULL;
272                         ber_dupbv( &bv, &rdn[ 0 ][ cnt ]->la_value );
273                         ber_bvarray_add( &mod->sml_bvalues, &bv );
274
275                         *modtail = mod;
276                         modtail = &mod->sml_next;
277                         continue;
278                         }
279                 }
280
281                 mr = desc->ad_type->sat_equality;
282                 if (mr == NULL || !mr->smr_match ) {
283                         /* bail out */
284                         send_ldap_result( conn, op, 
285                                         rc = LDAP_INVALID_SYNTAX,
286                                         NULL,
287                                         "attribute in RDN lacks matching rule", 
288                                         NULL, NULL );
289                         goto done;
290                 }
291
292                 for (i = 0; mod->sml_bvalues[ i ].bv_val; i++) {
293                         int             match = 0;
294                         
295                         rc = value_match(&match, desc, mr,
296                                         SLAP_MR_VALUE_SYNTAX_MATCH,
297                                         &mod->sml_bvalues[ i ],
298                                         &rdn[ 0 ][ cnt ]->la_value, &text);
299
300                         if ( rc != LDAP_SUCCESS ) {
301                                 send_ldap_result( conn, op, rc,
302                                                 NULL, text, NULL, NULL);
303                                 goto done;
304                         }
305
306                         if (match == 0) {
307                                 break;
308                         }
309                 }
310
311                 /* not found? */
312                 if (mod->sml_bvalues[ i ].bv_val == NULL) {
313                         if ( !global_add_rdn_values ) {
314                         /* bailout */
315                         send_ldap_result( conn, op, 
316                                         rc = LDAP_NO_SUCH_ATTRIBUTE,
317                                         NULL,
318                                         "value in RDN not listed in entry", 
319                                         NULL, NULL );
320                         goto done;
321
322                         } else {
323                         struct berval   bv;
324
325                         /* add attribute type and value to modlist */
326                         ber_dupbv( &bv, &rdn[ 0 ][ cnt ]->la_value );
327                         ber_bvarray_add( &mod->sml_bvalues, &bv );
328                         continue;
329                         }
330                 }
331         }
332
333         manageDSAit = get_manageDSAit( op );
334
335         /*
336          * We could be serving multiple database backends.  Select the
337          * appropriate one, or send a referral to our "referral server"
338          * if we don't hold it.
339          */
340         be = select_backend( &e->e_nname, manageDSAit, 0 );
341         if ( be == NULL ) {
342                 BerVarray ref = referral_rewrite( default_referral,
343                         NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
344
345                 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
346                         NULL, NULL, ref ? ref : default_referral, NULL );
347
348                 if ( ref ) ber_bvarray_free( ref );
349                 goto done;
350         }
351
352         /* check restrictions */
353         rc = backend_check_restrictions( be, conn, op, NULL, &text ) ;
354         if( rc != LDAP_SUCCESS ) {
355                 send_ldap_result( conn, op, rc,
356                         NULL, text, NULL, NULL );
357                 goto done;
358         }
359
360         /* check for referrals */
361         rc = backend_check_referrals( be, conn, op, &e->e_name, &e->e_nname );
362         if ( rc != LDAP_SUCCESS ) {
363                 goto done;
364         }
365
366 #ifdef LDAP_SLAPI
367         pb = initAddPlugin( be, conn, op, &dn, e, manageDSAit );
368 #endif /* LDAP_SLAPI */
369
370         /*
371          * do the add if 1 && (2 || 3)
372          * 1) there is an add function implemented in this backend;
373          * 2) this backend is master for what it holds;
374          * 3) it's a replica and the dn supplied is the updatedn.
375          */
376         if ( be->be_add ) {
377                 /* do the update here */
378                 int repl_user = be_isupdate(be, &op->o_ndn );
379 #ifndef SLAPD_MULTIMASTER
380                 if ( !be->be_update_ndn.bv_len || repl_user )
381 #endif
382                 {
383                         int update = be->be_update_ndn.bv_len;
384                         char textbuf[SLAP_TEXT_BUFLEN];
385                         size_t textlen = sizeof textbuf;
386
387                         rc = slap_mods_check( modlist, update, &text,
388                                 textbuf, textlen );
389
390                         if( rc != LDAP_SUCCESS ) {
391                                 send_ldap_result( conn, op, rc,
392                                         NULL, text, NULL, NULL );
393                                 goto done;
394                         }
395
396                         if ( !repl_user ) {
397                                 for( modtail = &modlist;
398                                         *modtail != NULL;
399                                         modtail = &(*modtail)->sml_next )
400                                 {
401                                         assert( (*modtail)->sml_op == LDAP_MOD_ADD );
402                                         assert( (*modtail)->sml_desc != NULL );
403                                 }
404                                 rc = slap_mods_opattrs( be, op, modlist, modtail, &text,
405                                         textbuf, textlen );
406                                 if( rc != LDAP_SUCCESS ) {
407                                         send_ldap_result( conn, op, rc,
408                                                 NULL, text, NULL, NULL );
409                                         goto done;
410                                 }
411                         }
412
413                         rc = slap_mods2entry( modlist, &e, repl_user, &text,
414                                 textbuf, textlen );
415                         if( rc != LDAP_SUCCESS ) {
416                                 send_ldap_result( conn, op, rc,
417                                         NULL, text, NULL, NULL );
418                                 goto done;
419                         }
420
421 #ifdef LDAP_SLAPI
422                         /*
423                          * Call the preoperation plugin here, because the entry
424                          * will actually contain something.
425                          */
426                         rc = doPreAddPluginFNs( be, pb );
427                         if ( rc != LDAP_SUCCESS ) {
428                                 /* plugin will have sent result */
429                                 goto done;
430                         }
431 #endif /* LDAP_SLAPI */
432
433                         if ( (*be->be_add)( be, conn, op, e ) == 0 ) {
434 #ifdef SLAPD_MULTIMASTER
435                                 if ( !repl_user )
436 #endif
437                                 {
438                                         replog( be, op, &e->e_name, &e->e_nname, e );
439                                 }
440                                 be_entry_release_w( be, conn, op, e );
441                                 e = NULL;
442                         }
443
444 #ifndef SLAPD_MULTIMASTER
445                 } else {
446                         BerVarray defref;
447                         BerVarray ref;
448 #ifdef LDAP_SLAPI
449                         /*
450                          * SLAPI_ADD_ENTRY will be empty, but this may be acceptable
451                          * on replicas (for now, it involves the minimum code intrusion).
452                          */
453                         rc = doPreAddPluginFNs( be, pb );
454                         if ( rc != LDAP_SUCCESS ) {
455                                 /* plugin will have sent result */
456                                 goto done;
457                         }
458 #endif /* LDAP_SLAPI */
459
460                         defref = be->be_update_refs
461                                 ? be->be_update_refs : default_referral;
462                         ref = referral_rewrite( defref,
463                                 NULL, &e->e_name, LDAP_SCOPE_DEFAULT );
464
465                         send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
466                                 ref ? ref : defref, NULL );
467
468                         if ( ref ) ber_bvarray_free( ref );
469 #endif /* SLAPD_MULTIMASTER */
470                 }
471         } else {
472 #ifdef LDAP_SLAPI
473             rc = doPreAddPluginFNs( be, pb );
474             if ( rc != LDAP_SUCCESS ) {
475                 /* plugin will have sent result */
476                 goto done;
477             }
478 #endif
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 */