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