]> git.sur5r.net Git - openldap/blob - servers/slapd/modify.c
Fix dnValidate
[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 = { 0, NULL };
38         struct berval ndn = { 0, 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 = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
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         if( ndn.bv_len == 0 ) {
196 #ifdef NEW_LOGGING
197                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
198                         "do_modify: attempt to modify root DSE.\n" ));
199 #else
200                 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
201 #endif
202
203                 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
204                         NULL, "modify upon the root DSE not supported", NULL, NULL );
205                 goto cleanup;
206
207 #if defined( SLAPD_SCHEMA_DN )
208         } else if ( strcasecmp( ndn.bv_val, SLAPD_SCHEMA_DN ) == 0 ) {
209 #ifdef NEW_LOGGING
210                 LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
211                         "do_modify: attempt to modify subschema subentry.\n" ));
212 #else
213                 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
214 #endif
215
216                 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
217                         NULL, "modification of subschema subentry not supported",
218                         NULL, NULL );
219                 goto cleanup;
220 #endif
221         }
222
223 #ifdef LDAP_DEBUG
224 #ifdef NEW_LOGGING
225         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
226                 "do_modify: modifications:\n" ));
227 #else
228         Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
229 #endif
230
231         for ( tmp = modlist; tmp != NULL; tmp = tmp->ml_next ) {
232 #ifdef NEW_LOGGING
233                 LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
234                         "\t%s:  %s\n", tmp->ml_op == LDAP_MOD_ADD ?
235                                 "add" : (tmp->ml_op == LDAP_MOD_DELETE ?
236                                         "delete" : "replace"), tmp->ml_type ));
237
238                 if ( tmp->ml_bvalues == NULL ) {
239                         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
240                            "\t\tno values" ));
241                 } else if ( tmp->ml_bvalues[0] == NULL ) {
242                         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
243                            "\t\tzero values" ));
244                 } else if ( tmp->ml_bvalues[1] == NULL ) {
245                         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
246                            "\t\tone value" ));
247                 } else {
248                         LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1,
249                            "\t\tmultiple values" ));
250                 }
251
252 #else
253                 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
254                         tmp->ml_op == LDAP_MOD_ADD
255                                 ? "add" : (tmp->ml_op == LDAP_MOD_DELETE
256                                         ? "delete" : "replace"), tmp->ml_type, 0 );
257
258                 if ( tmp->ml_bvalues == NULL ) {
259                         Debug( LDAP_DEBUG_ARGS, "%s\n",
260                            "\t\tno values", NULL, NULL );
261                 } else if ( tmp->ml_bvalues[0] == NULL ) {
262                         Debug( LDAP_DEBUG_ARGS, "%s\n",
263                            "\t\tzero values", NULL, NULL );
264                 } else if ( tmp->ml_bvalues[1] == NULL ) {
265                         Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
266                            "\t\tone value", (long) tmp->ml_bvalues[0]->bv_len, NULL );
267                 } else {
268                         Debug( LDAP_DEBUG_ARGS, "%s\n",
269                            "\t\tmultiple values", NULL, NULL );
270                 }
271 #endif
272         }
273 #endif
274
275         Statslog( LDAP_DEBUG_STATS, "conn=%ld op=%d MOD dn=\"%s\"\n",
276             op->o_connid, op->o_opid, dn.bv_val, 0, 0 );
277
278         manageDSAit = get_manageDSAit( op );
279
280         /*
281          * We could be serving multiple database backends.  Select the
282          * appropriate one, or send a referral to our "referral server"
283          * if we don't hold it.
284          */
285         if ( (be = select_backend( &ndn, manageDSAit, 0 )) == NULL ) {
286                 struct berval **ref = referral_rewrite( default_referral,
287                         NULL, &pdn, LDAP_SCOPE_DEFAULT );
288
289                 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
290                         NULL, NULL, ref ? ref : default_referral, NULL );
291
292                 ber_bvecfree( ref );
293                 goto cleanup;
294         }
295
296         /* check restrictions */
297         rc = backend_check_restrictions( be, conn, op, NULL, &text ) ;
298         if( rc != LDAP_SUCCESS ) {
299                 send_ldap_result( conn, op, rc,
300                         NULL, text, NULL, NULL );
301                 goto cleanup;
302         }
303
304         /* check for referrals */
305         rc = backend_check_referrals( be, conn, op, &pdn, &ndn );
306         if ( rc != LDAP_SUCCESS ) {
307                 goto cleanup;
308         }
309
310         /* deref suffix alias if appropriate */
311         suffix_alias( be, &ndn );
312
313         /*
314          * do the modify if 1 && (2 || 3)
315          * 1) there is a modify function implemented in this backend;
316          * 2) this backend is master for what it holds;
317          * 3) it's a replica and the dn supplied is the update_ndn.
318          */
319         if ( be->be_modify ) {
320                 /* do the update here */
321                 int repl_user = be_isupdate( be, &op->o_ndn );
322 #ifndef SLAPD_MULTIMASTER
323                 /* Multimaster slapd does not have to check for replicator dn
324                  * because it accepts each modify request
325                  */
326                 if ( !be->be_update_ndn.bv_len || repl_user )
327 #endif
328                 {
329                         int update = be->be_update_ndn.bv_len;
330                         const char *text;
331                         char textbuf[SLAP_TEXT_BUFLEN];
332                         size_t textlen = sizeof textbuf;
333
334                         rc = slap_modlist2mods( modlist, update, &mods, &text,
335                                 textbuf, textlen );
336
337                         if( rc != LDAP_SUCCESS ) {
338                                 send_ldap_result( conn, op, rc,
339                                         NULL, text, NULL, NULL );
340                                 goto cleanup;
341                         }
342
343                         if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
344                                 global_lastmod == ON)) && !repl_user )
345                         {
346                                 Modifications **modstail;
347                                 for( modstail = &mods;
348                                         *modstail != NULL;
349                                         modstail = &(*modstail)->sml_next )
350                                 {
351                                         /* empty */
352                                 }
353
354                                 rc = slap_mods_opattrs( op, mods, modstail, &text,
355                                         textbuf, textlen );
356                                 if( rc != LDAP_SUCCESS ) {
357                                         send_ldap_result( conn, op, rc,
358                                                 NULL, text,
359                                                 NULL, NULL );
360                                         goto cleanup;
361                                 }
362                         }
363
364                         if ( (*be->be_modify)( be, conn, op, &pdn, &ndn, mods ) == 0
365 #ifdef SLAPD_MULTIMASTER
366                                 && !repl_user
367 #endif
368                         ) {
369                                 /* but we log only the ones not from a replicator user */
370                                 replog( be, op, &pdn, &ndn, mods );
371                         }
372
373 #ifndef SLAPD_MULTIMASTER
374                 /* send a referral */
375                 } else {
376                         struct berval **defref = be->be_update_refs
377                                 ? be->be_update_refs : default_referral;
378                         struct berval **ref = referral_rewrite( defref,
379                                 NULL, &pdn, LDAP_SCOPE_DEFAULT );
380
381                         send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
382                                 ref ? ref : defref, NULL );
383
384                         ber_bvecfree( ref );
385 #endif
386                 }
387         } else {
388                 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
389                     NULL, "operation not supported within namingContext",
390                         NULL, NULL );
391         }
392
393 cleanup:
394         free( dn.bv_val );
395         free( pdn.bv_val );
396         free( ndn.bv_val );
397         if ( modlist != NULL )
398                 slap_modlist_free( modlist );
399         if ( mods != NULL )
400                 slap_mods_free( mods );
401         return rc;
402 }
403
404 /*
405  * convert a raw list of modifications to internal format
406  * Do basic attribute type checking and syntax validation.
407  */
408 int slap_modlist2mods(
409         LDAPModList *ml,
410         int update,
411         Modifications **mods,
412         const char **text,
413         char *textbuf,
414         size_t textlen )
415 {
416         int rc;
417         Modifications **modtail = mods;
418
419         for( ; ml != NULL; ml = ml->ml_next ) {
420                 Modifications *mod;
421                 AttributeDescription *ad = NULL;
422
423                 mod = (Modifications *)
424                         ch_calloc( 1, sizeof(Modifications) );
425
426                 /* copy the op */
427                 mod->sml_op = ml->ml_op;
428
429                 /* convert to attribute description */
430                 rc = slap_str2ad( ml->ml_type, &mod->sml_desc, text );
431
432                 if( rc != LDAP_SUCCESS ) {
433                         slap_mods_free( mod );
434                         snprintf( textbuf, textlen, "%s: %s",
435                                 ml->ml_type, *text );
436                         *text = textbuf;
437                         return rc;
438                 }
439
440                 ad = mod->sml_desc;
441
442                 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
443                         && !slap_ad_is_binary( ad ))
444                 {
445                         /* attribute requires binary transfer */
446                         slap_mods_free( mod );
447
448                         snprintf( textbuf, textlen,
449                                 "%s: requires ;binary transfer",
450                                 ml->ml_type );
451                         *text = textbuf;
452                         return LDAP_UNDEFINED_TYPE;
453                 }
454
455                 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
456                         && slap_ad_is_binary( ad ))
457                 {
458                         /* attribute requires binary transfer */
459                         slap_mods_free( mod );
460                         snprintf( textbuf, textlen,
461                                 "%s: disallows ;binary transfer",
462                                 ml->ml_type );
463                         *text = textbuf;
464                         return LDAP_UNDEFINED_TYPE;
465                 }
466
467                 if (!update && is_at_no_user_mod( ad->ad_type )) {
468                         /* user modification disallowed */
469                         slap_mods_free( mod );
470                         snprintf( textbuf, textlen,
471                                 "%s: no user modification allowed",
472                                 ml->ml_type );
473                         *text = textbuf;
474                         return LDAP_CONSTRAINT_VIOLATION;
475                 }
476
477                 if ( is_at_obsolete( ad->ad_type ) &&
478                         ( mod->sml_op == LDAP_MOD_ADD || ml->ml_bvalues != NULL ) )
479                 {
480                         /*
481                          * attribute is obsolete,
482                          * only allow replace/delete with no values
483                          */
484                         slap_mods_free( mod );
485                         snprintf( textbuf, textlen,
486                                 "%s: attribute is obsolete",
487                                 ml->ml_type );
488                         *text = textbuf;
489                         return LDAP_CONSTRAINT_VIOLATION;
490                 }
491
492                 /*
493                  * check values
494                  */
495                 if( ml->ml_bvalues != NULL ) {
496                         ber_len_t nvals;
497                         slap_syntax_validate_func *validate =
498                                 ad->ad_type->sat_syntax->ssyn_validate;
499                         slap_syntax_transform_func *pretty =
500                                 ad->ad_type->sat_syntax->ssyn_pretty;
501  
502                         if( !pretty && !validate ) {
503                                 slap_mods_free( mod );
504                                 *text = "no validator for syntax";
505                                 snprintf( textbuf, textlen,
506                                         "%s: no validator for syntax %s",
507                                         ml->ml_type,
508                                         ad->ad_type->sat_syntax->ssyn_oid );
509                                 *text = textbuf;
510                                 return LDAP_INVALID_SYNTAX;
511                         }
512
513                         /*
514                          * check that each value is valid per syntax
515                          *      and pretty if appropriate
516                          */
517                         for( nvals = 0; ml->ml_bvalues[nvals]; nvals++ ) {
518                                 struct berval pval;
519                                 if( pretty ) {
520                                         rc = pretty( ad->ad_type->sat_syntax,
521                                                 ml->ml_bvalues[nvals], &pval );
522                                 } else {
523                                         rc = validate( ad->ad_type->sat_syntax,
524                                                 ml->ml_bvalues[nvals] );
525                                 }
526
527                                 if( rc != 0 ) {
528                                         slap_mods_free( mod );
529                                         snprintf( textbuf, textlen,
530                                                 "%s: value #%ld invalid per syntax",
531                                                 ml->ml_type, (long) nvals );
532                                         *text = textbuf;
533                                         return LDAP_INVALID_SYNTAX;
534                                 }
535
536                                 if( pretty ) {
537                                         ber_memfree( ml->ml_bvalues[nvals]->bv_val );
538                                         *ml->ml_bvalues[nvals] = pval;
539                                 }
540                         }
541
542                         /*
543                          * a rough single value check... an additional check is needed
544                          * to catch add of single value to existing single valued attribute
545                          */
546                         if( ( mod->sml_op == LDAP_MOD_ADD || mod->sml_op == LDAP_MOD_REPLACE )
547                                 && nvals > 1 && is_at_single_value( ad->ad_type ))
548                         {
549                                 slap_mods_free( mod );
550                                 snprintf( textbuf, textlen,
551                                         "%s: multiple value provided",
552                                         ml->ml_type );
553                                 *text = textbuf;
554                                 return LDAP_CONSTRAINT_VIOLATION;
555                         }
556                 }
557
558                 mod->sml_bvalues = ml->ml_bvalues;
559                 ml->ml_values = NULL;
560
561                 *modtail = mod;
562                 modtail = &mod->sml_next;
563         }
564
565         return LDAP_SUCCESS;
566 }
567
568 int slap_mods_opattrs(
569         Operation *op,
570         Modifications *mods,
571         Modifications **modtail,
572         const char **text,
573         char *textbuf, size_t textlen )
574 {
575         struct berval name, timestamp, csn;
576         time_t now = slap_get_time();
577         char timebuf[22];
578         char csnbuf[64];
579         struct tm *ltm;
580         Modifications *mod;
581
582         int mop = op->o_tag == LDAP_REQ_ADD
583                 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
584
585         assert( modtail != NULL );
586         assert( *modtail == NULL );
587
588         ldap_pvt_thread_mutex_lock( &gmtime_mutex );
589         ltm = gmtime( &now );
590         strftime( timebuf, sizeof(timebuf), "%Y%m%d%H%M%SZ", ltm );
591
592         csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 );
593         ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
594         csn.bv_val = csnbuf;
595
596         timestamp.bv_val = timebuf;
597         timestamp.bv_len = strlen(timebuf);
598
599         if( op->o_dn.bv_len == 0 ) {
600                 name.bv_val = SLAPD_ANONYMOUS;
601                 name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
602         } else {
603                 name = op->o_dn;
604         }
605
606         if( op->o_tag == LDAP_REQ_ADD ) {
607                 struct berval tmpval;
608                 char uuidbuf[40];
609                 int rc;
610
611                 rc = mods_structural_class( mods, &tmpval, text, textbuf, textlen );
612                 if( rc != LDAP_SUCCESS ) {
613                         return rc;
614                 }
615                 if ( tmpval.bv_len ) {
616                         mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
617                         mod->sml_op = mop;
618                         mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
619                         mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
620                         mod->sml_bvalues[0] = ber_bvdup( &tmpval );
621                         mod->sml_bvalues[1] = NULL;
622                         assert( mod->sml_bvalues[0] );
623                         *modtail = mod;
624                         modtail = &mod->sml_next;
625                 }
626
627                 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
628                 tmpval.bv_val = uuidbuf;
629                 
630                 mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
631                 mod->sml_op = mop;
632                 mod->sml_desc = slap_schema.si_ad_entryUUID;
633                 mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
634                 mod->sml_bvalues[0] = ber_bvdup( &tmpval );
635                 mod->sml_bvalues[1] = NULL;
636                 assert( mod->sml_bvalues[0] );
637                 *modtail = mod;
638                 modtail = &mod->sml_next;
639
640                 mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
641                 mod->sml_op = mop;
642                 mod->sml_desc = slap_schema.si_ad_creatorsName;
643                 mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
644                 mod->sml_bvalues[0] = ber_bvdup( &name );
645                 mod->sml_bvalues[1] = NULL;
646                 assert( mod->sml_bvalues[0] );
647                 *modtail = mod;
648                 modtail = &mod->sml_next;
649
650                 mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
651                 mod->sml_op = mop;
652                 mod->sml_desc = slap_schema.si_ad_createTimestamp;
653                 mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof( struct berval * ) );
654                 mod->sml_bvalues[0] = ber_bvdup( &timestamp );
655                 mod->sml_bvalues[1] = NULL;
656                 assert( mod->sml_bvalues[0] );
657                 *modtail = mod;
658                 modtail = &mod->sml_next;
659         }
660
661         mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
662         mod->sml_op = mop;
663         mod->sml_desc = slap_schema.si_ad_entryCSN;
664         mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof(struct berval *) );
665         mod->sml_bvalues[0] = ber_bvdup( &csn );
666         mod->sml_bvalues[1] = NULL;
667         assert( mod->sml_bvalues[0] );
668         *modtail = mod;
669         modtail = &mod->sml_next;
670
671         mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
672         mod->sml_op = mop;
673         mod->sml_desc = slap_schema.si_ad_modifiersName;
674         mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof(struct berval *) );
675         mod->sml_bvalues[0] = ber_bvdup( &name );
676         mod->sml_bvalues[1] = NULL;
677         assert( mod->sml_bvalues[0] );
678         *modtail = mod;
679         modtail = &mod->sml_next;
680
681         mod = (Modifications *) ch_calloc( 1, sizeof( Modifications ) );
682         mod->sml_op = mop;
683         mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
684         mod->sml_bvalues = (struct berval **) malloc( 2 * sizeof(struct berval *) );
685         mod->sml_bvalues[0] = ber_bvdup( &timestamp );
686         mod->sml_bvalues[1] = NULL;
687         assert( mod->sml_bvalues[0] );
688         *modtail = mod;
689         modtail = &mod->sml_next;
690
691         return LDAP_SUCCESS;
692 }
693