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