]> git.sur5r.net Git - openldap/blob - servers/slapd/add.c
Fallout from ITS#4986 - remove unused param of select_backend()
[openldap] / servers / slapd / add.c
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1998-2007 The OpenLDAP Foundation.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted only as authorized by the OpenLDAP
9  * Public License.
10  *
11  * A copy of this license is available in the file LICENSE in the
12  * top-level directory of the distribution or, alternatively, at
13  * <http://www.OpenLDAP.org/license.html>.
14  */
15 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms are permitted
19  * provided that this notice is preserved and that due credit is given
20  * to the University of Michigan at Ann Arbor. The name of the University
21  * may not be used to endorse or promote products derived from this
22  * software without specific prior written permission. This software
23  * is provided ``as is'' without express or implied warranty.
24  */
25
26 #include "portable.h"
27
28 #include <stdio.h>
29 #include <ac/string.h>
30 #include <ac/time.h>
31 #include <ac/socket.h>
32
33 #include "lutil.h"
34 #include "slap.h"
35
36 int
37 do_add( Operation *op, SlapReply *rs )
38 {
39         BerElement      *ber = op->o_ber;
40         char            *last;
41         struct berval   dn = BER_BVNULL;
42         ber_len_t       len;
43         ber_tag_t       tag;
44         Modifications   *modlist = NULL;
45         Modifications   **modtail = &modlist;
46         Modifications   tmp;
47         char            textbuf[ SLAP_TEXT_BUFLEN ];
48         size_t          textlen = sizeof( textbuf );
49         int             rc = 0;
50         int             freevals = 1;
51
52         Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 );
53         /*
54          * Parse the add request.  It looks like this:
55          *
56          *      AddRequest := [APPLICATION 14] SEQUENCE {
57          *              name    DistinguishedName,
58          *              attrs   SEQUENCE OF SEQUENCE {
59          *                      type    AttributeType,
60          *                      values  SET OF AttributeValue
61          *              }
62          *      }
63          */
64
65         /* get the name */
66         if ( ber_scanf( ber, "{m", /*}*/ &dn ) == LBER_ERROR ) {
67                 Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
68                 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
69                 return SLAPD_DISCONNECT;
70         }
71
72         op->ora_e = entry_alloc();
73
74         rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
75                 op->o_tmpmemctx );
76
77         if ( rs->sr_err != LDAP_SUCCESS ) {
78                 Debug( LDAP_DEBUG_ANY, "do_add: invalid dn (%s)\n", dn.bv_val, 0, 0 );
79                 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
80                 goto done;
81         }
82
83         ber_dupbv( &op->ora_e->e_name, &op->o_req_dn );
84         ber_dupbv( &op->ora_e->e_nname, &op->o_req_ndn );
85
86         Debug( LDAP_DEBUG_ARGS, "do_add: dn (%s)\n", op->ora_e->e_dn, 0, 0 );
87
88         /* get the attrs */
89         for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
90             tag = ber_next_element( ber, &len, last ) )
91         {
92                 Modifications *mod;
93                 ber_tag_t rtag;
94
95                 tmp.sml_nvalues = NULL;
96
97                 rtag = ber_scanf( ber, "{m{W}}", &tmp.sml_type, &tmp.sml_values );
98
99                 if ( rtag == LBER_ERROR ) {
100                         Debug( LDAP_DEBUG_ANY, "do_add: decoding error\n", 0, 0, 0 );
101                         send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
102                         rs->sr_err = SLAPD_DISCONNECT;
103                         goto done;
104                 }
105
106                 if ( tmp.sml_values == NULL ) {
107                         Debug( LDAP_DEBUG_ANY, "no values for type %s\n",
108                                 tmp.sml_type.bv_val, 0, 0 );
109                         send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
110                                 "no values for attribute type" );
111                         goto done;
112                 }
113
114                 mod  = (Modifications *) ch_malloc( sizeof(Modifications) );
115                 mod->sml_op = LDAP_MOD_ADD;
116                 mod->sml_flags = 0;
117                 mod->sml_next = NULL;
118                 mod->sml_desc = NULL;
119                 mod->sml_type = tmp.sml_type;
120                 mod->sml_values = tmp.sml_values;
121                 mod->sml_nvalues = NULL;
122
123                 *modtail = mod;
124                 modtail = &mod->sml_next;
125         }
126
127         if ( ber_scanf( ber, /*{*/ "}") == LBER_ERROR ) {
128                 Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
129                 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
130                 rs->sr_err = SLAPD_DISCONNECT;
131                 goto done;
132         }
133
134         if ( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
135                 Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
136                 goto done;
137         } 
138
139         if ( modlist == NULL ) {
140                 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
141                         "no attributes provided" );
142                 goto done;
143         }
144
145         Statslog( LDAP_DEBUG_STATS, "%s ADD dn=\"%s\"\n",
146             op->o_log_prefix, op->ora_e->e_name.bv_val, 0, 0, 0 );
147
148         if ( dn_match( &op->ora_e->e_nname, &slap_empty_bv ) ) {
149                 /* protocolError may be a more appropriate error */
150                 send_ldap_error( op, rs, LDAP_ALREADY_EXISTS,
151                         "root DSE already exists" );
152                 goto done;
153
154         } else if ( dn_match( &op->ora_e->e_nname, &frontendDB->be_schemandn ) ) {
155                 send_ldap_error( op, rs, LDAP_ALREADY_EXISTS,
156                         "subschema subentry already exists" );
157                 goto done;
158         }
159
160         rs->sr_err = slap_mods_check( op, modlist, &rs->sr_text,
161                 textbuf, textlen, NULL );
162
163         if ( rs->sr_err != LDAP_SUCCESS ) {
164                 send_ldap_result( op, rs );
165                 goto done;
166         }
167
168         /* temporary; remove if not invoking backend function */
169         op->ora_modlist = modlist;
170
171         /* call this so global overlays/SLAPI have access to ora_e */
172         rs->sr_err = slap_mods2entry( op->ora_modlist, &op->ora_e,
173                 1, 0, &rs->sr_text, textbuf, textlen );
174         if ( rs->sr_err != LDAP_SUCCESS ) {
175                 send_ldap_result( op, rs );
176                 goto done;
177         }
178
179         freevals = 0;
180
181         op->o_bd = frontendDB;
182         rc = frontendDB->be_add( op, rs );
183
184 #ifdef LDAP_X_TXN
185         if ( rc == LDAP_X_TXN_SPECIFY_OKAY ) {
186                 /* skip cleanup */
187                 return rc;
188         } else
189 #endif
190         if ( rc == 0 ) {
191                 if ( op->ora_e != NULL && op->o_private != NULL ) {
192                         BackendDB       *bd = op->o_bd;
193
194                         op->o_bd = (BackendDB *)op->o_private;
195                         op->o_private = NULL;
196
197                         be_entry_release_w( op, op->ora_e );
198
199                         op->ora_e = NULL;
200                         op->o_bd = bd;
201                         op->o_private = NULL;
202                 }
203         }
204
205 done:;
206         if ( modlist != NULL ) {
207                 /* in case of error, free the values as well */
208                 slap_mods_free( modlist, freevals );
209         }
210
211         if ( op->ora_e != NULL ) {
212                 entry_free( op->ora_e );
213         }
214         op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
215         op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
216
217         return rc;
218 }
219
220 int
221 fe_op_add( Operation *op, SlapReply *rs )
222 {
223         Modifications   **modtail = &op->ora_modlist;
224         int             rc = 0;
225         BackendDB       *op_be, *bd = op->o_bd;
226         char            textbuf[ SLAP_TEXT_BUFLEN ];
227         size_t          textlen = sizeof( textbuf );
228
229         /*
230          * We could be serving multiple database backends.  Select the
231          * appropriate one, or send a referral to our "referral server"
232          * if we don't hold it.
233          */
234         op->o_bd = select_backend( &op->ora_e->e_nname, 1 );
235         if ( op->o_bd == NULL ) {
236                 op->o_bd = bd;
237                 rs->sr_ref = referral_rewrite( default_referral,
238                         NULL, &op->ora_e->e_name, LDAP_SCOPE_DEFAULT );
239                 if ( !rs->sr_ref ) rs->sr_ref = default_referral;
240                 if ( rs->sr_ref ) {
241                         rs->sr_err = LDAP_REFERRAL;
242                         send_ldap_result( op, rs );
243
244                         if ( rs->sr_ref != default_referral ) {
245                                 ber_bvarray_free( rs->sr_ref );
246                         }
247                 } else {
248                         send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
249                                 "no global superior knowledge" );
250                 }
251                 goto done;
252         }
253
254         /* If we've got a glued backend, check the real backend */
255         op_be = op->o_bd;
256         if ( SLAP_GLUE_INSTANCE( op->o_bd )) {
257                 op->o_bd = select_backend( &op->ora_e->e_nname, 0 );
258         }
259
260         /* check restrictions */
261         if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
262                 send_ldap_result( op, rs );
263                 goto done;
264         }
265
266         /* check for referrals */
267         if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
268                 goto done;
269         }
270
271         rs->sr_err = slap_mods_obsolete_check( op, op->ora_modlist,
272                 &rs->sr_text, textbuf, textlen );
273
274         if ( rs->sr_err != LDAP_SUCCESS ) {
275                 send_ldap_result( op, rs );
276                 goto done;
277         }
278
279         /*
280          * do the add if 1 && (2 || 3)
281          * 1) there is an add function implemented in this backend;
282          * 2) this backend is master for what it holds;
283          * 3) it's a replica and the dn supplied is the updatedn.
284          */
285         if ( op->o_bd->be_add ) {
286                 /* do the update here */
287                 int repl_user = be_isupdate( op );
288                 if ( !SLAP_SINGLE_SHADOW(op->o_bd) || repl_user ) {
289                         int             update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
290
291                         op->o_bd = op_be;
292
293                         if ( !update ) {
294                                 rs->sr_err = slap_mods_no_user_mod_check( op, op->ora_modlist,
295                                         &rs->sr_text, textbuf, textlen );
296
297                                 if ( rs->sr_err != LDAP_SUCCESS ) {
298                                         send_ldap_result( op, rs );
299                                         goto done;
300                                 }
301                         }
302
303                         if ( !repl_user ) {
304                                 /* go to the last mod */
305                                 for ( modtail = &op->ora_modlist;
306                                                 *modtail != NULL;
307                                                 modtail = &(*modtail)->sml_next )
308                                 {
309                                         assert( (*modtail)->sml_op == LDAP_MOD_ADD );
310                                         assert( (*modtail)->sml_desc != NULL );
311                                 }
312
313
314                                 /* check for unmodifiable attributes */
315                                 rs->sr_err = slap_mods_no_repl_user_mod_check( op,
316                                         op->ora_modlist, &rs->sr_text, textbuf, textlen );
317                                 if ( rs->sr_err != LDAP_SUCCESS ) {
318                                         send_ldap_result( op, rs );
319                                         goto done;
320                                 }
321                         }
322
323                         rc = op->o_bd->be_add( op, rs );
324                         if ( rc == LDAP_SUCCESS ) {
325                                 /* NOTE: be_entry_release_w() is
326                                  * called by do_add(), so that global
327                                  * overlays on the way back can
328                                  * at least read the entry */
329                                 op->o_private = op->o_bd;
330                         }
331
332                 } else {
333                         BerVarray defref = NULL;
334
335                         defref = op->o_bd->be_update_refs
336                                 ? op->o_bd->be_update_refs : default_referral;
337
338                         if ( defref != NULL ) {
339                                 rs->sr_ref = referral_rewrite( defref,
340                                         NULL, &op->ora_e->e_name, LDAP_SCOPE_DEFAULT );
341                                 if ( rs->sr_ref == NULL ) rs->sr_ref = defref;
342                                 rs->sr_err = LDAP_REFERRAL;
343                                 if (!rs->sr_ref) rs->sr_ref = default_referral;
344                                 send_ldap_result( op, rs );
345
346                                 if ( rs->sr_ref != default_referral ) {
347                                         ber_bvarray_free( rs->sr_ref );
348                                 }
349                         } else {
350                                 send_ldap_error( op, rs,
351                                         LDAP_UNWILLING_TO_PERFORM,
352                                         "shadow context; no update referral" );
353                         }
354                 }
355         } else {
356                 Debug( LDAP_DEBUG_ARGS, "do_add: no backend support\n", 0, 0, 0 );
357                 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
358                         "operation not supported within namingContext" );
359         }
360
361 done:;
362         op->o_bd = bd;
363         return rc;
364 }
365
366 int
367 slap_mods2entry(
368         Modifications *mods,
369         Entry **e,
370         int initial,
371         int dup,
372         const char **text,
373         char *textbuf, size_t textlen )
374 {
375         Attribute **tail;
376
377         if ( initial ) {
378                 assert( (*e)->e_attrs == NULL );
379         }
380
381         for ( tail = &(*e)->e_attrs; *tail != NULL; tail = &(*tail)->a_next )
382                 ;
383
384         *text = textbuf;
385
386         for( ; mods != NULL; mods = mods->sml_next ) {
387                 Attribute *attr;
388
389                 assert( mods->sml_desc != NULL );
390
391                 attr = attr_find( (*e)->e_attrs, mods->sml_desc );
392
393                 if( attr != NULL ) {
394 #define SLURPD_FRIENDLY
395 #ifdef SLURPD_FRIENDLY
396                         ber_len_t i,j;
397
398                         if ( !initial ) {
399                                 /*      
400                                  * This check allows overlays to override operational
401                                  * attributes by setting them directly in the entry.
402                                  * We assume slap_mods_no_user_mod_check() was called
403                                  * with the user modifications.
404                                  */
405                                 *text = NULL;
406                                 return LDAP_SUCCESS;
407                         }
408
409                         for( i=0; attr->a_vals[i].bv_val; i++ ) {
410                                 /* count them */
411                         }
412                         for( j=0; mods->sml_values[j].bv_val; j++ ) {
413                                 /* count them */
414                         }
415                         j++;    /* NULL */
416                         
417                         attr->a_vals = ch_realloc( attr->a_vals,
418                                 sizeof( struct berval ) * (i+j) );
419
420                         /* checked for duplicates in slap_mods_check */
421
422                         if ( dup ) {
423                                 for ( j = 0; mods->sml_values[j].bv_val; j++ ) {
424                                         ber_dupbv( &attr->a_vals[i+j], &mods->sml_values[j] );
425                                 }
426                                 BER_BVZERO( &attr->a_vals[i+j] );
427                                 j++;
428                         } else {
429                                 AC_MEMCPY( &attr->a_vals[i], mods->sml_values,
430                                         sizeof( struct berval ) * j );
431                         }
432
433                         if( mods->sml_nvalues ) {
434                                 attr->a_nvals = ch_realloc( attr->a_nvals,
435                                         sizeof( struct berval ) * (i+j) );
436                                 if ( dup ) {
437                                         for ( j = 0; mods->sml_nvalues[j].bv_val; j++ ) {
438                                                 ber_dupbv( &attr->a_nvals[i+j], &mods->sml_nvalues[j] );
439                                         }
440                                         BER_BVZERO( &attr->a_nvals[i+j] );      
441                                 } else {
442                                         AC_MEMCPY( &attr->a_nvals[i], mods->sml_nvalues,
443                                                 sizeof( struct berval ) * j );
444                                 }
445                         } else {
446                                 attr->a_nvals = attr->a_vals;
447                         }
448
449                         continue;
450 #else
451                         snprintf( textbuf, textlen,
452                                 "attribute '%s' provided more than once",
453                                 mods->sml_desc->ad_cname.bv_val );
454                         *text = textbuf;
455                         return LDAP_TYPE_OR_VALUE_EXISTS;
456 #endif
457                 }
458
459                 attr = attr_alloc( mods->sml_desc );
460
461                 /* move values to attr structure */
462                 if ( dup ) { 
463                         int i;
464                         for ( i = 0; mods->sml_values[i].bv_val; i++ ) /* EMPTY */;
465                         attr->a_vals = (BerVarray) ch_calloc( i+1, sizeof( BerValue ));
466                         for ( i = 0; mods->sml_values[i].bv_val; i++ ) {
467                                 ber_dupbv( &attr->a_vals[i], &mods->sml_values[i] );
468                         }
469                         BER_BVZERO( &attr->a_vals[i] );
470                 } else {
471                         attr->a_vals = mods->sml_values;
472                 }
473
474                 if ( mods->sml_nvalues ) {
475                         if ( dup ) {
476                                 int i;
477                                 for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) /* EMPTY */;
478                                 attr->a_nvals = (BerVarray) ch_calloc( i+1, sizeof( BerValue ));
479                                 for ( i = 0; mods->sml_nvalues[i].bv_val; i++ ) {
480                                         ber_dupbv( &attr->a_nvals[i], &mods->sml_nvalues[i] );
481                                 }
482                                 BER_BVZERO( &attr->a_nvals[i] );
483                         } else {
484                                 attr->a_nvals = mods->sml_nvalues;
485                         }
486                 } else {
487                         attr->a_nvals = attr->a_vals;
488                 }
489
490                 *tail = attr;
491                 tail = &attr->a_next;
492         }
493
494         *text = NULL;
495
496         return LDAP_SUCCESS;
497 }
498
499 int
500 slap_entry2mods(
501         Entry *e,
502         Modifications **mods,
503         const char **text,
504         char *textbuf, size_t textlen )
505 {
506         Modifications   *modhead = NULL;
507         Modifications   *mod;
508         Modifications   **modtail = &modhead;
509         Attribute               *a_new;
510         AttributeDescription    *a_new_desc;
511         int                             i, count;
512
513         a_new = e->e_attrs;
514
515         while ( a_new != NULL ) {
516                 a_new_desc = a_new->a_desc;
517                 mod = (Modifications *) malloc( sizeof( Modifications ));
518                 
519                 mod->sml_op = LDAP_MOD_REPLACE;
520                 mod->sml_flags = 0;
521
522                 mod->sml_type = a_new_desc->ad_cname;
523
524                 for ( count = 0; a_new->a_vals[count].bv_val; count++ ) /* EMPTY */;
525
526                 mod->sml_values = (struct berval*) malloc(
527                         (count+1) * sizeof( struct berval) );
528
529                 /* see slap_mods_check() comments...
530                  * if a_vals == a_nvals, there is no normalizer.
531                  * in this case, mod->sml_nvalues must be left NULL.
532                  */
533                 if ( a_new->a_vals != a_new->a_nvals ) {
534                         mod->sml_nvalues = (struct berval*) malloc(
535                                 (count+1) * sizeof( struct berval) );
536                 } else {
537                         mod->sml_nvalues = NULL;
538                 }
539
540                 for ( i = 0; i < count; i++ ) {
541                         ber_dupbv(mod->sml_values+i, a_new->a_vals+i); 
542                         if ( mod->sml_nvalues ) {
543                                 ber_dupbv( mod->sml_nvalues+i, a_new->a_nvals+i ); 
544                         } 
545                 }
546
547                 mod->sml_values[count].bv_val = NULL; 
548                 mod->sml_values[count].bv_len = 0; 
549
550                 if ( mod->sml_nvalues ) {
551                         mod->sml_nvalues[count].bv_val = NULL; 
552                         mod->sml_nvalues[count].bv_len = 0; 
553                 }
554
555                 mod->sml_desc = a_new_desc;
556                 mod->sml_next =NULL;
557                 *modtail = mod;
558                 modtail = &mod->sml_next;
559                 a_new = a_new->a_next; 
560         }
561
562         *mods = modhead;
563
564         return LDAP_SUCCESS;
565 }
566
567 int slap_add_opattrs(
568         Operation *op,
569         const char **text,
570         char *textbuf,
571         size_t textlen,
572         int manage_ctxcsn )
573 {
574         struct berval name, timestamp, csn = BER_BVNULL;
575         struct berval nname, tmp;
576         char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
577         char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
578         Attribute *a;
579
580         if ( SLAP_LASTMOD( op->o_bd ) ) {
581                 char *ptr;
582                 int gotcsn = 0;
583
584                 timestamp.bv_val = timebuf;
585                 a = attr_find( op->ora_e->e_attrs, slap_schema.si_ad_entryCSN );
586                 if ( a ) {
587                         gotcsn = 1;
588                         csn = a->a_vals[0];
589                 }
590                 if ( BER_BVISEMPTY( &op->o_csn )) {
591                         if ( !gotcsn ) {
592                                 csn.bv_val = csnbuf;
593                                 csn.bv_len = sizeof(csnbuf);
594                                 slap_get_csn( op, &csn, manage_ctxcsn );
595                         } else {
596                                 if ( manage_ctxcsn )
597                                         slap_queue_csn( op, &csn );
598                         }
599                 } else {
600                         csn = op->o_csn;
601                 }
602                 ptr = ber_bvchr( &csn, '#' );
603                 if ( ptr ) {
604                         timestamp.bv_len = STRLENOF("YYYYMMDDHHMMSSZ");
605                         AC_MEMCPY( timebuf, csn.bv_val, timestamp.bv_len );
606                         timebuf[timestamp.bv_len-1] = 'Z';
607                         timebuf[timestamp.bv_len] = '\0';
608                 } else {
609                         time_t now = slap_get_time();
610
611                         timestamp.bv_len = sizeof(timebuf);
612
613                         slap_timestamp( &now, &timestamp );
614                 }
615
616                 if ( BER_BVISEMPTY( &op->o_dn ) ) {
617                         BER_BVSTR( &name, SLAPD_ANONYMOUS );
618                         nname = name;
619                 } else {
620                         name = op->o_dn;
621                         nname = op->o_ndn;
622                 }
623
624                 a = attr_find( op->ora_e->e_attrs,
625                         slap_schema.si_ad_entryUUID );
626                 if ( !a ) {
627                         char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
628
629                         tmp.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
630                         tmp.bv_val = uuidbuf;
631                         
632                         attr_merge_normalize_one( op->ora_e,
633                                 slap_schema.si_ad_entryUUID, &tmp, op->o_tmpmemctx );
634                 }
635
636                 a = attr_find( op->ora_e->e_attrs,
637                         slap_schema.si_ad_creatorsName );
638                 if ( !a ) {
639                         attr_merge_one( op->ora_e,
640                                 slap_schema.si_ad_creatorsName, &name, &nname );
641                 }
642
643                 a = attr_find( op->ora_e->e_attrs,
644                         slap_schema.si_ad_createTimestamp );
645                 if ( !a ) {
646                         attr_merge_one( op->ora_e,
647                                 slap_schema.si_ad_createTimestamp, &timestamp, NULL );
648                 }
649
650                 if ( !gotcsn ) {
651                         attr_merge_one( op->ora_e,
652                                 slap_schema.si_ad_entryCSN, &csn, NULL );
653                 }
654
655                 a = attr_find( op->ora_e->e_attrs,
656                         slap_schema.si_ad_modifiersName );
657                 if ( !a ) {
658                         attr_merge_one( op->ora_e,
659                                 slap_schema.si_ad_modifiersName, &name, &nname );
660                 }
661
662                 a = attr_find( op->ora_e->e_attrs,
663                         slap_schema.si_ad_modifyTimestamp );
664                 if ( !a ) {
665                         attr_merge_one( op->ora_e,
666                                 slap_schema.si_ad_modifyTimestamp, &timestamp, NULL );
667                 }
668         }
669
670         return LDAP_SUCCESS;
671 }