]> git.sur5r.net Git - openldap/blob - servers/slapd/modify.c
a04ba300121faa0d9ed8515e762c3a6da29415d1
[openldap] / servers / slapd / modify.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2000 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
22 #include <ac/socket.h>
23 #include <ac/string.h>
24 #include <ac/time.h>
25
26 #include "lutil.h"
27
28 #include "ldap_pvt.h"
29 #include "slap.h"
30
31 int
32 do_modify(
33     Connection  *conn,
34     Operation   *op )
35 {
36         char            *dn, *ndn = NULL;
37         char            *last;
38         ber_tag_t       tag;
39         ber_len_t       len;
40         LDAPModList     *modlist = NULL;
41         LDAPModList     **modtail = &modlist;
42 #ifdef LDAP_DEBUG
43         LDAPModList *tmp;
44 #endif
45         Modifications *mods = NULL;
46         Backend         *be;
47         int rc;
48         const char      *text;
49         int manageDSAit;
50
51 #ifdef NEW_LOGGING
52         LDAP_LOG(( "operation", LDAP_LEVEL_ENTRY,
53                    "do_modify: enter\n" ));
54 #else
55         Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
56 #endif
57
58         /*
59          * Parse the modify request.  It looks like this:
60          *
61          *      ModifyRequest := [APPLICATION 6] SEQUENCE {
62          *              name    DistinguishedName,
63          *              mods    SEQUENCE OF SEQUENCE {
64          *                      operation       ENUMERATED {
65          *                              add     (0),
66          *                              delete  (1),
67          *                              replace (2)
68          *                      },
69          *                      modification    SEQUENCE {
70          *                              type    AttributeType,
71          *                              values  SET OF AttributeValue
72          *                      }
73          *              }
74          *      }
75          */
76
77         if ( ber_scanf( op->o_ber, "{a" /*}*/, &dn ) == LBER_ERROR ) {
78 #ifdef NEW_LOGGING
79                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
80                            "do_modify: ber_scanf failed\n" ));
81 #else
82                 Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 );
83 #endif
84
85                 send_ldap_disconnect( conn, op,
86                         LDAP_PROTOCOL_ERROR, "decoding error" );
87                 return SLAPD_DISCONNECT;
88         }
89
90 #ifdef NEW_LOGGING
91         LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
92                    "do_modify: dn (%s)\n", dn ));
93 #else
94         Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn, 0, 0 );
95 #endif
96
97
98         /* collect modifications & save for later */
99
100         for ( tag = ber_first_element( op->o_ber, &len, &last );
101             tag != LBER_DEFAULT;
102             tag = ber_next_element( op->o_ber, &len, last ) )
103         {
104                 ber_int_t mop;
105
106                 (*modtail) = (LDAPModList *) ch_calloc( 1, sizeof(LDAPModList) );
107
108                 if ( ber_scanf( op->o_ber, "{i{a[V]}}", &mop,
109                     &(*modtail)->ml_type, &(*modtail)->ml_bvalues )
110                     == LBER_ERROR )
111                 {
112                         send_ldap_disconnect( conn, op,
113                                 LDAP_PROTOCOL_ERROR, "decoding modlist error" );
114                         rc = SLAPD_DISCONNECT;
115                         goto cleanup;
116                 }
117
118                 switch( mop ) {
119                 case LDAP_MOD_ADD:
120                         if ( (*modtail)->ml_bvalues == NULL ) {
121 #ifdef NEW_LOGGING
122                                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
123                                            "do_modify: modify/add operation (%ld) requires values\n",
124                                            (long)mop ));
125 #else
126                                 Debug( LDAP_DEBUG_ANY,
127                                         "do_modify: modify/add operation (%ld) requires values\n",
128                                         (long) mop, 0, 0 );
129 #endif
130
131                                 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
132                                         NULL, "modify/add operation requires values",
133                                         NULL, NULL );
134                                 rc = LDAP_PROTOCOL_ERROR;
135                                 goto cleanup;
136                         }
137
138                         /* fall through */
139
140                 case LDAP_MOD_DELETE:
141                 case LDAP_MOD_REPLACE:
142                         break;
143
144                 default: {
145 #ifdef NEW_LOGGING
146                                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
147                                            "do_modify: invalid modify operation (%ld)\n",
148                                            (long)mop ));
149 #else
150                                 Debug( LDAP_DEBUG_ANY,
151                                         "do_modify: invalid modify operation (%ld)\n",
152                                         (long) mop, 0, 0 );
153 #endif
154
155                                 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
156                                         NULL, "unrecognized modify operation", NULL, NULL );
157                                 rc = LDAP_PROTOCOL_ERROR;
158                                 goto cleanup;
159                         }
160                 }
161
162                 (*modtail)->ml_op = mop;
163                 modtail = &(*modtail)->ml_next;
164         }
165         *modtail = NULL;
166
167         if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
168 #ifdef NEW_LOGGING
169                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
170                            "do_modify: get_ctrls failed\n" ));
171 #else
172                 Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
173 #endif
174
175                 goto cleanup;
176         }
177
178         ndn = ch_strdup( dn );
179
180         if(     dn_normalize( ndn ) == NULL ) {
181 #ifdef NEW_LOGGING
182                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
183                            "do_modify:  invalid dn (%s)\n", dn ));
184 #else
185                 Debug( LDAP_DEBUG_ANY, "do_modify: invalid dn (%s)\n", dn, 0, 0 );
186 #endif
187
188                 send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
189                     "invalid DN", NULL, NULL );
190                 goto cleanup;
191         }
192
193         if( *ndn == '\0' ) {
194 #ifdef NEW_LOGGING
195                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
196                            "do_modify: attempt to modify root DSE.\n" ));
197 #else
198                 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
199 #endif
200
201                 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
202                         NULL, "modify upon the root DSE not supported", NULL, NULL );
203                 goto cleanup;
204
205 #if defined( SLAPD_SCHEMA_DN )
206         } else if ( strcasecmp( ndn, SLAPD_SCHEMA_DN ) == 0 ) {
207 #ifdef NEW_LOGGING
208                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
209                         "do_modify: attempt to modify subschema subentry.\n" ));
210 #else
211                 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
212 #endif
213
214                 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
215                         NULL, "modification of subschema subentry not supported",
216                         NULL, NULL );
217                 goto cleanup;
218 #endif
219         }
220
221 #ifdef LDAP_DEBUG
222 #ifdef NEW_LOGGING
223         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
224                 "do_modify: modifications:\n" ));
225 #else
226         Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
227 #endif
228
229         for ( tmp = modlist; tmp != NULL; tmp = tmp->ml_next ) {
230 #ifdef NEW_LOGGING
231                 LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
232                            "\t%s:  %s\n", tmp->ml_op == LDAP_MOD_ADD ?
233                            "add" : (tmp->ml_op == LDAP_MOD_DELETE ?
234                                     "delete" : "replace"), tmp->ml_type ));
235
236                 if ( tmp->ml_bvalues == NULL ) {
237                         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
238                            "\t\tno values" ));
239                 } else if ( tmp->ml_bvalues[0] == NULL ) {
240                         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
241                            "\t\tzero values" ));
242                 } else if ( tmp->ml_bvalues[1] == NULL ) {
243                         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
244                            "\t\tone value" ));
245                 } else {
246                         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
247                            "\t\tmultiple values" ));
248                 }
249
250 #else
251                 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
252                         tmp->ml_op == LDAP_MOD_ADD
253                                 ? "add" : (tmp->ml_op == LDAP_MOD_DELETE
254                                         ? "delete" : "replace"), tmp->ml_type, 0 );
255
256                 if ( tmp->ml_bvalues == NULL ) {
257                         Debug( LDAP_DEBUG_ARGS, "%s\n",
258                            "\t\tno values", NULL, NULL );
259                 } else if ( tmp->ml_bvalues[0] == NULL ) {
260                         Debug( LDAP_DEBUG_ARGS, "%s\n",
261                            "\t\tzero values", NULL, NULL );
262                 } else if ( tmp->ml_bvalues[1] == NULL ) {
263                         Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
264                            "\t\tone value", (long) tmp->ml_bvalues[0]->bv_len, NULL );
265                 } else {
266                         Debug( LDAP_DEBUG_ARGS, "%s\n",
267                            "\t\tmultiple values", NULL, NULL );
268                 }
269 #endif
270         }
271 #endif
272
273         Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d MOD dn=\"%s\"\n",
274             op->o_connid, op->o_opid, dn, 0, 0 );
275
276         manageDSAit = get_manageDSAit( op );
277
278         /*
279          * We could be serving multiple database backends.  Select the
280          * appropriate one, or send a referral to our "referral server"
281          * if we don't hold it.
282          */
283         if ( (be = select_backend( ndn, manageDSAit, 0 )) == NULL ) {
284                 struct berval **ref = referral_rewrite( default_referral,
285                         NULL, dn, LDAP_SCOPE_DEFAULT );
286
287                 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
288                         NULL, NULL, ref ? ref : default_referral, NULL );
289
290                 ber_bvecfree( ref );
291                 goto cleanup;
292         }
293
294         /* check restrictions */
295         rc = backend_check_restrictions( be, conn, op, NULL, &text ) ;
296         if( rc != LDAP_SUCCESS ) {
297                 send_ldap_result( conn, op, rc,
298                         NULL, text, NULL, NULL );
299                 goto cleanup;
300         }
301
302         /* check for referrals */
303         rc = backend_check_referrals( be, conn, op, dn, ndn );
304         if ( rc != LDAP_SUCCESS ) {
305                 goto cleanup;
306         }
307
308         /* deref suffix alias if appropriate */
309         ndn = suffix_alias( be, ndn );
310
311         /*
312          * do the modify if 1 && (2 || 3)
313          * 1) there is a modify function implemented in this backend;
314          * 2) this backend is master for what it holds;
315          * 3) it's a replica and the dn supplied is the update_ndn.
316          */
317         if ( be->be_modify ) {
318                 /* do the update here */
319                 int repl_user = be_isupdate( be, op->o_ndn );
320 #ifndef SLAPD_MULTIMASTER
321                 /* Multimaster slapd does not have to check for replicator dn
322                  * because it accepts each modify request
323                  */
324                 if ( be->be_update_ndn == NULL || repl_user )
325 #endif
326                 {
327                         int update = be->be_update_ndn != NULL;
328                         const char *text;
329                         char textbuf[SLAP_TEXT_BUFLEN];
330                         size_t textlen = sizeof textbuf;
331
332                         rc = slap_modlist2mods( modlist, update, &mods, &text,
333                                 textbuf, textlen );
334
335                         if( rc != LDAP_SUCCESS ) {
336                                 send_ldap_result( conn, op, rc,
337                                         NULL, text, NULL, NULL );
338                                 goto cleanup;
339                         }
340
341                         if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
342                                 global_lastmod == ON)) && !repl_user )
343                         {
344                                 Modifications **modstail;
345                                 for( modstail = &mods;
346                                         *modstail != NULL;
347                                         modstail = &(*modstail)->sml_next )
348                                 {
349                                         /* empty */
350                                 }
351
352                                 rc = slap_mods_opattrs( op, mods, modstail, &text,
353                                         textbuf, textlen );
354                                 if( rc != LDAP_SUCCESS ) {
355                                         send_ldap_result( conn, op, rc,
356                                                 NULL, text,
357                                                 NULL, NULL );
358                                         goto cleanup;
359                                 }
360                         }
361
362                         if ( (*be->be_modify)( be, conn, op, dn, ndn, mods ) == 0 
363 #ifdef SLAPD_MULTIMASTER
364                                 && !repl_user
365 #endif
366                         ) {
367                                 /* but we log only the ones not from a replicator user */
368                                 replog( be, op, dn, ndn, mods );
369                         }
370
371 #ifndef SLAPD_MULTIMASTER
372                 /* send a referral */
373                 } else {
374                         struct berval **defref = be->be_update_refs
375                                 ? be->be_update_refs : default_referral;
376                         struct berval **ref = referral_rewrite( defref,
377                                 NULL, dn, LDAP_SCOPE_DEFAULT );
378
379                         send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
380                                 ref ? ref : defref, NULL );
381
382                         ber_bvecfree( ref );
383 #endif
384                 }
385         } else {
386                 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
387                     NULL, "operation not supported within namingContext", NULL, NULL );
388         }
389
390 cleanup:
391         free( dn );
392         if( ndn != NULL ) free( ndn );
393         if ( modlist != NULL )
394                 slap_modlist_free( modlist );
395         if ( mods != NULL )
396                 slap_mods_free( mods );
397         return rc;
398 }
399
400 /*
401  * convert a raw list of modifications to internal format
402  * Do basic attribute type checking and syntax validation.
403  */
404 int slap_modlist2mods(
405         LDAPModList *ml,
406         int update,
407         Modifications **mods,
408         const char **text,
409         char *textbuf,
410         size_t textlen )
411 {
412         int rc;
413         Modifications **modtail = mods;
414
415         for( ; ml != NULL; ml = ml->ml_next ) {
416                 Modifications *mod;
417                 AttributeDescription *ad = NULL;
418
419                 mod = (Modifications *)
420                         ch_calloc( 1, sizeof(Modifications) );
421
422                 /* copy the op */
423                 mod->sml_op = ml->ml_op;
424
425                 /* convert to attribute description */
426                 rc = slap_str2ad( ml->ml_type, &mod->sml_desc, text );
427
428                 if( rc != LDAP_SUCCESS ) {
429                         slap_mods_free( mod );
430                         snprintf( textbuf, textlen, "%s: %s",
431                                 ml->ml_type, *text );
432                         *text = textbuf;
433                         return rc;
434                 }
435
436                 ad = mod->sml_desc;
437
438                 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
439                         && !slap_ad_is_binary( ad ))
440                 {
441                         /* attribute requires binary transfer */
442                         slap_mods_free( mod );
443
444                         snprintf( textbuf, textlen,
445                                 "%s: requires ;binary transfer",
446                                 ml->ml_type );
447                         *text = textbuf;
448                         return LDAP_UNDEFINED_TYPE;
449                 }
450
451                 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
452                         && slap_ad_is_binary( ad ))
453                 {
454                         /* attribute requires binary transfer */
455                         slap_mods_free( mod );
456                         snprintf( textbuf, textlen,
457                                 "%s: disallows ;binary transfer",
458                                 ml->ml_type );
459                         *text = textbuf;
460                         return LDAP_UNDEFINED_TYPE;
461                 }
462
463                 if (!update && is_at_no_user_mod( ad->ad_type )) {
464                         /* user modification disallowed */
465                         slap_mods_free( mod );
466                         snprintf( textbuf, textlen,
467                                 "%s: no user modification allowed",
468                                 ml->ml_type );
469                         *text = textbuf;
470                         return LDAP_CONSTRAINT_VIOLATION;
471                 }
472
473                 if ( is_at_obsolete( ad->ad_type ) &&
474                         ( mod->sml_op == LDAP_MOD_ADD || ml->ml_bvalues != NULL ) )
475                 {
476                         /*
477                          * attribute is obsolete,
478                          * only allow replace/delete with no values
479                          */
480                         slap_mods_free( mod );
481                         snprintf( textbuf, textlen,
482                                 "%s: attribute is obsolete",
483                                 ml->ml_type );
484                         *text = textbuf;
485                         return LDAP_CONSTRAINT_VIOLATION;
486                 }
487
488                 /*
489                  * check values
490                  */
491                 if( ml->ml_bvalues != NULL ) {
492                         ber_len_t nvals;
493                         slap_syntax_validate_func *validate =
494                                 ad->ad_type->sat_syntax->ssyn_validate;
495                         slap_syntax_transform_func *pretty =
496                                 ad->ad_type->sat_syntax->ssyn_pretty;
497  
498                         if( !pretty && !validate ) {
499                                 slap_mods_free( mod );
500                                 *text = "no validator for syntax";
501                                 snprintf( textbuf, textlen,
502                                         "%s: no validator for syntax %s",
503                                         ml->ml_type,
504                                         ad->ad_type->sat_syntax->ssyn_oid );
505                                 *text = textbuf;
506                                 return LDAP_INVALID_SYNTAX;
507                         }
508
509                         /*
510                          * check that each value is valid per syntax
511                          *      and pretty if appropriate
512                          */
513                         for( nvals = 0; ml->ml_bvalues[nvals]; nvals++ ) {
514                                 struct berval *pval;
515                                 if( pretty ) {
516                                         rc = pretty( ad->ad_type->sat_syntax,
517                                                 ml->ml_bvalues[nvals], &pval );
518                                 } else {
519                                         rc = validate( ad->ad_type->sat_syntax,
520                                                 ml->ml_bvalues[nvals] );
521                                 }
522
523                                 if( rc != 0 ) {
524                                         slap_mods_free( mod );
525                                         snprintf( textbuf, textlen,
526                                                 "%s: value #%ld invalid per syntax",
527                                                 ml->ml_type, (long) nvals );
528                                         *text = textbuf;
529                                         return LDAP_INVALID_SYNTAX;
530                                 }
531
532                                 if( pretty ) {
533                                         ber_memfree( ml->ml_bvalues[nvals]->bv_val );
534                                         *ml->ml_bvalues[nvals] = *pval;
535                                         free( pval );
536                                 }
537                         }
538
539                         /*
540                          * a rough single value check... an additional check is needed
541                          * to catch add of single value to existing single valued attribute
542                          */
543                         if( ( mod->sml_op == LDAP_MOD_ADD || mod->sml_op == LDAP_MOD_REPLACE )
544                                 && nvals > 1 && is_at_single_value( ad->ad_type ))
545                         {
546                                 slap_mods_free( mod );
547                                 snprintf( textbuf, textlen,
548                                         "%s: multiple value provided",
549                                         ml->ml_type );
550                                 *text = textbuf;
551                                 return LDAP_CONSTRAINT_VIOLATION;
552                         }
553                 }
554
555                 mod->sml_bvalues = ml->ml_bvalues;
556                 ml->ml_values = NULL;
557
558                 *modtail = mod;
559                 modtail = &mod->sml_next;
560         }
561
562         return LDAP_SUCCESS;
563 }
564
565 int slap_mods_opattrs(
566         Operation *op,
567         Modifications *mods,
568         Modifications **modtail,
569         const char **text,
570         char *textbuf, size_t textlen )
571 {
572         struct berval name, timestamp, csn;
573         time_t now = slap_get_time();
574         char timebuf[22];
575         char csnbuf[64];
576         struct tm *ltm;
577         Modifications *mod;
578
579         int mop = op->o_tag == LDAP_REQ_ADD
580                 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
581
582         assert( modtail != NULL );
583         assert( *modtail == NULL );
584
585         ldap_pvt_thread_mutex_lock( &gmtime_mutex );
586         ltm = gmtime( &now );
587         strftime( timebuf, sizeof(timebuf), "%Y%m%d%H%M%SZ", ltm );
588
589         csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 );
590         ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
591         csn.bv_val = csnbuf;
592
593         timestamp.bv_val = timebuf;
594         timestamp.bv_len = strlen(timebuf);
595
596         if( op->o_dn == NULL || op->o_dn[0] == '\0' ) {
597                 name.bv_val = SLAPD_ANONYMOUS;
598                 name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
599         } else {
600                 name.bv_val = op->o_dn;
601                 name.bv_len = strlen( op->o_dn );
602         }
603
604         if( op->o_tag == LDAP_REQ_ADD ) {
605                 struct berval tmpval;
606                 char uuidbuf[40];
607                 int rc;
608
609                 rc = mods_structural_class( mods, &tmpval, text, textbuf, textlen );
610                 if( rc != LDAP_SUCCESS ) {
611                         return rc;
612                 }
613                 if ( tmpval.bv_len ) {
614                         mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
615                         mod->sml_op = mop;
616                         mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
617                         mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
618                         mod->sml_bvalues[0] = ber_bvdup( &tmpval );
619                         mod->sml_bvalues[1] = NULL;
620                         assert( mod->sml_bvalues[0] );
621                         *modtail = mod;
622                         modtail = &mod->sml_next;
623                 }
624
625                 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
626                 tmpval.bv_val = uuidbuf;
627                 
628                 mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
629                 mod->sml_op = mop;
630                 mod->sml_desc = slap_schema.si_ad_entryUUID;
631                 mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
632                 mod->sml_bvalues[0] = ber_bvdup( &tmpval );
633                 mod->sml_bvalues[1] = NULL;
634                 assert( mod->sml_bvalues[0] );
635                 *modtail = mod;
636                 modtail = &mod->sml_next;
637
638                 mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
639                 mod->sml_op = mop;
640                 mod->sml_desc = slap_schema.si_ad_creatorsName;
641                 mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
642                 mod->sml_bvalues[0] = ber_bvdup( &name );
643                 mod->sml_bvalues[1] = NULL;
644                 assert( mod->sml_bvalues[0] );
645                 *modtail = mod;
646                 modtail = &mod->sml_next;
647
648                 mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
649                 mod->sml_op = mop;
650                 mod->sml_desc = slap_schema.si_ad_createTimestamp;
651                 mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
652                 mod->sml_bvalues[0] = ber_bvdup( &timestamp );
653                 mod->sml_bvalues[1] = NULL;
654                 assert( mod->sml_bvalues[0] );
655                 *modtail = mod;
656                 modtail = &mod->sml_next;
657         }
658
659         mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
660         mod->sml_op = mop;
661         mod->sml_desc = slap_schema.si_ad_entryCSN;
662         mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof(struct berval *) );
663         mod->sml_bvalues[0] = ber_bvdup( &csn );
664         mod->sml_bvalues[1] = NULL;
665         assert( mod->sml_bvalues[0] );
666         *modtail = mod;
667         modtail = &mod->sml_next;
668
669         mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
670         mod->sml_op = mop;
671         mod->sml_desc = slap_schema.si_ad_modifiersName;
672         mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof(struct berval *) );
673         mod->sml_bvalues[0] = ber_bvdup( &name );
674         mod->sml_bvalues[1] = NULL;
675         assert( mod->sml_bvalues[0] );
676         *modtail = mod;
677         modtail = &mod->sml_next;
678
679         mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
680         mod->sml_op = mop;
681         mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
682         mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof(struct berval *) );
683         mod->sml_bvalues[0] = ber_bvdup( &timestamp );
684         mod->sml_bvalues[1] = NULL;
685         assert( mod->sml_bvalues[0] );
686         *modtail = mod;
687         modtail = &mod->sml_next;
688
689         return LDAP_SUCCESS;
690 }
691