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