3 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright (c) 1995 Regents of the University of Michigan.
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.
22 #include <ac/socket.h>
23 #include <ac/string.h>
39 struct berval dn = { 0, NULL };
43 Modifications *modlist = NULL;
44 Modifications **modtail = &modlist;
49 LDAPMod **modv = NULL;
50 Slapi_PBlock *pb = op->o_pb;
56 LDAP_LOG( OPERATION, ENTRY, "do_modify: enter\n", 0, 0, 0 );
58 Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
62 * Parse the modify request. It looks like this:
64 * ModifyRequest := [APPLICATION 6] SEQUENCE {
65 * name DistinguishedName,
66 * mods SEQUENCE OF SEQUENCE {
67 * operation ENUMERATED {
72 * modification SEQUENCE {
74 * values SET OF AttributeValue
80 if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) {
82 LDAP_LOG( OPERATION, ERR, "do_modify: ber_scanf failed\n", 0, 0, 0 );
84 Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 );
87 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
88 return SLAPD_DISCONNECT;
92 LDAP_LOG( OPERATION, ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
94 Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
98 /* collect modifications & save for later */
100 for ( tag = ber_first_element( op->o_ber, &len, &last );
102 tag = ber_next_element( op->o_ber, &len, last ) )
105 Modifications tmp, *mod;
107 tmp.sml_nvalues = NULL;
109 if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
110 &tmp.sml_type, &tmp.sml_values )
113 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding modlist error" );
114 rs->sr_err = SLAPD_DISCONNECT;
118 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
120 mod->sml_type = tmp.sml_type;
121 mod->sml_values = tmp.sml_values;
122 mod->sml_nvalues = NULL;
123 mod->sml_desc = NULL;
124 mod->sml_next = NULL;
129 if ( mod->sml_values == NULL ) {
131 LDAP_LOG( OPERATION, ERR,
132 "do_modify: modify/add operation (%ld) requires values\n",
135 Debug( LDAP_DEBUG_ANY,
136 "do_modify: modify/add operation (%ld) requires values\n",
140 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
141 "modify/add operation requires values" );
147 case LDAP_MOD_DELETE:
148 case LDAP_MOD_REPLACE:
151 case LDAP_MOD_INCREMENT:
152 if( op->o_protocol >= LDAP_VERSION3 ) {
154 if ( mod->sml_values == NULL ) {
156 LDAP_LOG( OPERATION, ERR, "do_modify: "
157 "modify/increment operation (%ld) requires value\n",
160 Debug( LDAP_DEBUG_ANY, "do_modify: "
161 "modify/increment operation (%ld) requires value\n",
165 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
166 "modify/increment operation requires value" );
170 if( mod->sml_values[1].bv_val ) {
172 LDAP_LOG( OPERATION, ERR, "do_modify: modify/increment "
173 "operation (%ld) requires single value\n",
176 Debug( LDAP_DEBUG_ANY, "do_modify: modify/increment "
177 "operation (%ld) requires single value\n",
181 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
182 "modify/increment operation requires single value" );
192 LDAP_LOG( OPERATION, ERR,
193 "do_modify: unrecognized modify operation (%ld)\n",
196 Debug( LDAP_DEBUG_ANY,
197 "do_modify: unrecognized modify operation (%ld)\n",
201 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
202 "unrecognized modify operation" );
207 modtail = &mod->sml_next;
211 if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
213 LDAP_LOG( OPERATION, ERR, "do_modify: get_ctrls failed\n", 0, 0, 0 );
215 Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
221 rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
223 if( rs->sr_err != LDAP_SUCCESS ) {
225 LDAP_LOG( OPERATION, INFO, "do_modify: conn %d invalid dn (%s)\n",
226 op->o_connid, dn.bv_val, 0 );
228 Debug( LDAP_DEBUG_ANY,
229 "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 );
231 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
235 if( op->o_req_ndn.bv_len == 0 ) {
237 LDAP_LOG( OPERATION, ERR,
238 "do_modify: attempt to modify root DSE.\n",0, 0, 0 );
240 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
243 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
244 "modify upon the root DSE not supported" );
247 } else if ( bvmatch( &op->o_req_ndn, &global_schemandn ) ) {
249 LDAP_LOG( OPERATION, ERR,
250 "do_modify: attempt to modify subschema subentry.\n" , 0, 0, 0 );
252 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
255 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
256 "modification of subschema subentry not supported" );
262 LDAP_LOG( OPERATION, DETAIL1, "do_modify: modifications:\n", 0, 0, 0 );
264 Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
267 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
269 LDAP_LOG( OPERATION, DETAIL1, "\t%s: %s\n",
270 tmp->sml_op == LDAP_MOD_ADD ? "add" :
271 (tmp->sml_op == LDAP_MOD_INCREMENT ? "increment" :
272 (tmp->sml_op == LDAP_MOD_DELETE ? "delete" :
273 "replace")), tmp->sml_type.bv_val, 0 );
275 if ( tmp->sml_values == NULL ) {
276 LDAP_LOG( OPERATION, DETAIL1, "\t\tno values", 0, 0, 0 );
277 } else if ( tmp->sml_values[0].bv_val == NULL ) {
278 LDAP_LOG( OPERATION, DETAIL1, "\t\tzero values", 0, 0, 0 );
279 } else if ( tmp->sml_values[1].bv_val == NULL ) {
280 LDAP_LOG( OPERATION, DETAIL1, "\t\tone value", 0, 0, 0 );
282 LDAP_LOG( OPERATION, DETAIL1, "\t\tmultiple values", 0, 0, 0 );
286 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
287 tmp->sml_op == LDAP_MOD_ADD ? "add" :
288 (tmp->sml_op == LDAP_MOD_INCREMENT ? "increment" :
289 (tmp->sml_op == LDAP_MOD_DELETE ? "delete" :
290 "replace")), tmp->sml_type.bv_val, 0 );
292 if ( tmp->sml_values == NULL ) {
293 Debug( LDAP_DEBUG_ARGS, "%s\n",
294 "\t\tno values", NULL, NULL );
295 } else if ( tmp->sml_values[0].bv_val == NULL ) {
296 Debug( LDAP_DEBUG_ARGS, "%s\n",
297 "\t\tzero values", NULL, NULL );
298 } else if ( tmp->sml_values[1].bv_val == NULL ) {
299 Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
300 "\t\tone value", (long) tmp->sml_values[0].bv_len, NULL );
302 Debug( LDAP_DEBUG_ARGS, "%s\n",
303 "\t\tmultiple values", NULL, NULL );
308 if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
309 char abuf[BUFSIZ/2], *ptr = abuf;
312 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD dn=\"%s\"\n",
313 op->o_connid, op->o_opid, dn.bv_val, 0, 0 );
315 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
316 if (len + 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
317 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
318 op->o_connid, op->o_opid, abuf, 0, 0 );
326 ptr = lutil_strcopy(ptr, tmp->sml_type.bv_val);
327 len += tmp->sml_type.bv_len;
330 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
331 op->o_connid, op->o_opid, abuf, 0, 0 );
334 #endif /* LDAP_DEBUG */
336 manageDSAit = get_manageDSAit( op );
339 * We could be serving multiple database backends. Select the
340 * appropriate one, or send a referral to our "referral server"
341 * if we don't hold it.
343 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 );
344 if ( op->o_bd == NULL ) {
345 rs->sr_ref = referral_rewrite( default_referral,
346 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
347 if (!rs->sr_ref) rs->sr_ref = default_referral;
349 if (rs->sr_ref != NULL ) {
350 rs->sr_err = LDAP_REFERRAL;
351 send_ldap_result( op, rs );
353 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
355 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
356 "referral missing" );
361 /* check restrictions */
362 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
363 send_ldap_result( op, rs );
367 /* check for referrals */
368 if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
372 /* check for modify/increment support */
373 if( increment && !SLAP_INCREMENT( op->o_bd ) ) {
374 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
375 "modify/increment not supported in context" );
378 #if defined( LDAP_SLAPI )
379 slapi_x_pblock_set_operation( pb, op );
380 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
381 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
382 modv = slapi_x_modifications2ldapmods( &modlist );
383 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
385 rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
386 if ( rs->sr_err < 0 ) {
388 * A preoperation plugin failure will abort the
392 LDAP_LOG( OPERATION, INFO, "do_modify: modify preoperation plugin "
393 "failed\n", 0, 0, 0 );
395 Debug(LDAP_DEBUG_TRACE, "do_modify: modify preoperation plugin failed.\n",
398 if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
399 rs->sr_err == LDAP_SUCCESS ) {
400 rs->sr_err = LDAP_OTHER;
402 slapi_x_free_ldapmods( modv );
408 * It's possible that the preoperation plugin changed the
409 * modification array, so we need to convert it back to
410 * a Modification list.
412 * Calling slapi_x_modifications2ldapmods() destroyed modlist so
413 * we don't need to free it.
415 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
416 modlist = slapi_x_ldapmods2modifications( modv );
419 * NB: it is valid for the plugin to return no modifications
420 * (for example, a plugin might store some attributes elsewhere
421 * and remove them from the modification list; if only those
422 * attribute types were included in the modification request,
423 * then slapi_x_ldapmods2modifications() above will return
426 * However, the post-operation plugin should still be
429 if ( modlist == NULL ) {
430 rs->sr_err = LDAP_SUCCESS;
431 send_ldap_result( op, rs );
433 #endif /* defined( LDAP_SLAPI ) */
436 * do the modify if 1 && (2 || 3)
437 * 1) there is a modify function implemented in this backend;
438 * 2) this backend is master for what it holds;
439 * 3) it's a replica and the dn supplied is the update_ndn.
441 if ( op->o_bd->be_modify ) {
442 /* do the update here */
443 int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
445 /* Multimaster slapd does not have to check for replicator dn
446 * because it accepts each modify request
448 #if defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
449 if ( !op->o_bd->syncinfo &&
450 ( !op->o_bd->be_update_ndn.bv_len || repl_user ))
451 #elif defined(LDAP_SYNCREPL) && defined(SLAPD_MULTIMASTER)
452 if ( !op->o_bd->syncinfo ) /* LDAP_SYNCREPL overrides MM */
453 #elif !defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
454 if ( !op->o_bd->be_update_ndn.bv_len || repl_user )
457 int update = op->o_bd->be_update_ndn.bv_len;
458 char textbuf[SLAP_TEXT_BUFLEN];
459 size_t textlen = sizeof textbuf;
461 rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
462 textbuf, textlen, NULL );
464 if( rs->sr_err != LDAP_SUCCESS ) {
465 send_ldap_result( op, rs );
470 for( modtail = &modlist;
472 modtail = &(*modtail)->sml_next )
477 rs->sr_err = slap_mods_opattrs( op, modlist, modtail,
478 &rs->sr_text, textbuf, textlen );
479 if( rs->sr_err != LDAP_SUCCESS ) {
480 send_ldap_result( op, rs );
485 op->orm_modlist = modlist;
486 if ( (op->o_bd->be_modify)( op, rs ) == 0
487 #ifdef SLAPD_MULTIMASTER
491 /* but we log only the ones not from a replicator user */
495 #if defined(LDAP_SYNCREPL) || !defined(SLAPD_MULTIMASTER)
496 /* send a referral */
498 BerVarray defref = NULL;
500 if ( op->o_bd->syncinfo ) {
501 defref = op->o_bd->syncinfo->provideruri_bv;
505 defref = op->o_bd->be_update_refs
506 ? op->o_bd->be_update_refs : default_referral;
508 if ( defref != NULL ) {
509 rs->sr_ref = referral_rewrite( defref,
511 LDAP_SCOPE_DEFAULT );
512 if (!rs->sr_ref) rs->sr_ref = defref;
513 rs->sr_err = LDAP_REFERRAL;
514 send_ldap_result( op, rs );
515 if (rs->sr_ref != defref) {
516 ber_bvarray_free( rs->sr_ref );
519 send_ldap_error( op, rs,
520 LDAP_UNWILLING_TO_PERFORM,
521 "referral missing" );
526 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
527 "operation not supported within namingContext" );
530 #if defined( LDAP_SLAPI )
531 } /* modlist != NULL */
533 if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) {
535 LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins "
536 "failed\n", 0, 0, 0 );
538 Debug(LDAP_DEBUG_TRACE, "do_modify: modify postoperation plugins "
539 "failed.\n", 0, 0, 0);
542 #endif /* defined( LDAP_SLAPI ) */
545 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
546 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
547 if ( modlist != NULL ) slap_mods_free( modlist );
548 #if defined( LDAP_SLAPI )
549 if ( modv != NULL ) slapi_x_free_ldapmods( modv );
555 * Do basic attribute type checking and syntax validation.
567 for( ; ml != NULL; ml = ml->sml_next ) {
568 AttributeDescription *ad = NULL;
570 /* convert to attribute description */
571 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
573 if( rc != LDAP_SUCCESS ) {
574 snprintf( textbuf, textlen, "%s: %s",
575 ml->sml_type.bv_val, *text );
582 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
583 && !slap_ad_is_binary( ad ))
585 /* attribute requires binary transfer */
586 snprintf( textbuf, textlen,
587 "%s: requires ;binary transfer",
588 ml->sml_type.bv_val );
590 return LDAP_UNDEFINED_TYPE;
593 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
594 && slap_ad_is_binary( ad ))
596 /* attribute requires binary transfer */
597 snprintf( textbuf, textlen,
598 "%s: disallows ;binary transfer",
599 ml->sml_type.bv_val );
601 return LDAP_UNDEFINED_TYPE;
604 if( slap_ad_is_tag_range( ad )) {
605 /* attribute requires binary transfer */
606 snprintf( textbuf, textlen,
607 "%s: inappropriate use of tag range option",
608 ml->sml_type.bv_val );
610 return LDAP_UNDEFINED_TYPE;
613 if (!update && is_at_no_user_mod( ad->ad_type )) {
614 /* user modification disallowed */
615 snprintf( textbuf, textlen,
616 "%s: no user modification allowed",
617 ml->sml_type.bv_val );
619 return LDAP_CONSTRAINT_VIOLATION;
622 if ( is_at_obsolete( ad->ad_type ) &&
623 (( ml->sml_op != LDAP_MOD_REPLACE &&
624 ml->sml_op != LDAP_MOD_DELETE ) ||
625 ml->sml_values != NULL ))
628 * attribute is obsolete,
629 * only allow replace/delete with no values
631 snprintf( textbuf, textlen,
632 "%s: attribute is obsolete",
633 ml->sml_type.bv_val );
635 return LDAP_CONSTRAINT_VIOLATION;
638 if ( ml->sml_op == LDAP_MOD_INCREMENT &&
639 #ifdef SLAPD_REAL_SYNTAX
640 !is_at_syntax( ad->ad_type, SLAPD_REAL_SYNTAX ) &&
642 !is_at_syntax( ad->ad_type, SLAPD_INTEGER_SYNTAX ) )
645 * attribute values must be INTEGER or REAL
647 snprintf( textbuf, textlen,
648 "%s: attribute syntax inappropriate for increment",
649 ml->sml_type.bv_val );
651 return LDAP_CONSTRAINT_VIOLATION;
657 if( ml->sml_values != NULL ) {
659 slap_syntax_validate_func *validate =
660 ad->ad_type->sat_syntax->ssyn_validate;
661 slap_syntax_transform_func *pretty =
662 ad->ad_type->sat_syntax->ssyn_pretty;
664 if( !pretty && !validate ) {
665 *text = "no validator for syntax";
666 snprintf( textbuf, textlen,
667 "%s: no validator for syntax %s",
669 ad->ad_type->sat_syntax->ssyn_oid );
671 return LDAP_INVALID_SYNTAX;
675 * check that each value is valid per syntax
676 * and pretty if appropriate
678 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
681 rc = pretty( ad->ad_type->sat_syntax,
682 &ml->sml_values[nvals], &pval, ctx );
684 rc = validate( ad->ad_type->sat_syntax,
685 &ml->sml_values[nvals] );
689 snprintf( textbuf, textlen,
690 "%s: value #%ld invalid per syntax",
691 ml->sml_type.bv_val, (long) nvals );
693 return LDAP_INVALID_SYNTAX;
697 ber_memfree_x( ml->sml_values[nvals].bv_val, ctx );
698 ml->sml_values[nvals] = pval;
703 * a rough single value check... an additional check is needed
704 * to catch add of single value to existing single valued attribute
706 if ((ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE)
707 && nvals > 1 && is_at_single_value( ad->ad_type ))
709 snprintf( textbuf, textlen,
710 "%s: multiple values provided",
711 ml->sml_type.bv_val );
713 return LDAP_CONSTRAINT_VIOLATION;
716 if( nvals && ad->ad_type->sat_equality &&
717 ad->ad_type->sat_equality->smr_normalize )
719 ml->sml_nvalues = ber_memalloc_x(
720 (nvals+1)*sizeof(struct berval), ctx );
722 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
723 rc = ad->ad_type->sat_equality->smr_normalize(
725 ad->ad_type->sat_syntax,
726 ad->ad_type->sat_equality,
727 &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
730 LDAP_LOG( OPERATION, DETAIL1,
731 "str2entry: NULL (ssyn_normalize %d)\n",
734 Debug( LDAP_DEBUG_ANY,
735 "<= str2entry NULL (ssyn_normalize %d)\n",
738 snprintf( textbuf, textlen,
739 "%s: value #%ld normalization failed",
740 ml->sml_type.bv_val, (long) nvals );
746 ml->sml_nvalues[nvals].bv_val = NULL;
747 ml->sml_nvalues[nvals].bv_len = 0;
755 int slap_mods_opattrs(
758 Modifications **modtail,
760 char *textbuf, size_t textlen )
762 struct berval name, timestamp, csn;
764 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
765 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
768 int mop = op->o_tag == LDAP_REQ_ADD
769 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
772 syncinfo_t *si = op->o_si;
775 assert( modtail != NULL );
776 assert( *modtail == NULL );
779 if ( SLAP_LASTMOD(op->o_bd) && ( !si || si->lastmod == LASTMOD_GEN ))
781 if ( SLAP_LASTMOD(op->o_bd) )
785 time_t now = slap_get_time();
787 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
788 ltm = gmtime( &now );
789 lutil_gentime( timebuf, sizeof(timebuf), ltm );
791 csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 );
792 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
795 timestamp.bv_val = timebuf;
796 timestamp.bv_len = strlen(timebuf);
798 if( op->o_dn.bv_len == 0 ) {
799 name.bv_val = SLAPD_ANONYMOUS;
800 name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
808 if( op->o_tag == LDAP_REQ_ADD ) {
809 struct berval tmpval;
811 if( global_schemacheck ) {
812 int rc = mods_structural_class( mods, &tmpval,
813 text, textbuf, textlen );
814 if( rc != LDAP_SUCCESS ) return rc;
816 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
818 mod->sml_type.bv_val = NULL;
819 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
821 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
822 ber_dupbv( &mod->sml_values[0], &tmpval );
823 mod->sml_values[1].bv_len = 0;
824 mod->sml_values[1].bv_val = NULL;
825 assert( mod->sml_values[0].bv_val );
827 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
828 ber_dupbv( &mod->sml_nvalues[0], &tmpval );
829 mod->sml_nvalues[1].bv_len = 0;
830 mod->sml_nvalues[1].bv_val = NULL;
831 assert( mod->sml_nvalues[0].bv_val );
833 modtail = &mod->sml_next;
837 if ( SLAP_LASTMOD(op->o_bd) && ( !si || si->lastmod == LASTMOD_GEN ))
839 if ( SLAP_LASTMOD(op->o_bd) )
842 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
847 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
848 tmpval.bv_val = uuidbuf;
850 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
852 mod->sml_type.bv_val = NULL;
853 mod->sml_desc = slap_schema.si_ad_entryUUID;
855 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
856 ber_dupbv( &mod->sml_values[0], &tmpval );
857 mod->sml_values[1].bv_len = 0;
858 mod->sml_values[1].bv_val = NULL;
859 assert( mod->sml_values[0].bv_val );
860 mod->sml_nvalues = NULL;
862 modtail = &mod->sml_next;
867 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
869 mod->sml_type.bv_val = NULL;
870 mod->sml_desc = slap_schema.si_ad_creatorsName;
871 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
872 ber_dupbv( &mod->sml_values[0], &name );
873 mod->sml_values[1].bv_len = 0;
874 mod->sml_values[1].bv_val = NULL;
875 assert( mod->sml_values[0].bv_val );
877 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
878 ber_dupbv( &mod->sml_nvalues[0], &nname );
879 mod->sml_nvalues[1].bv_len = 0;
880 mod->sml_nvalues[1].bv_val = NULL;
881 assert( mod->sml_nvalues[0].bv_val );
883 modtail = &mod->sml_next;
885 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
887 mod->sml_type.bv_val = NULL;
888 mod->sml_desc = slap_schema.si_ad_createTimestamp;
889 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
890 ber_dupbv( &mod->sml_values[0], ×tamp );
891 mod->sml_values[1].bv_len = 0;
892 mod->sml_values[1].bv_val = NULL;
893 assert( mod->sml_values[0].bv_val );
894 mod->sml_nvalues = NULL;
896 modtail = &mod->sml_next;
901 if ( SLAP_LASTMOD(op->o_bd) && ( !si || si->lastmod == LASTMOD_GEN ))
903 if ( SLAP_LASTMOD(op->o_bd) )
906 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
908 mod->sml_type.bv_val = NULL;
909 mod->sml_desc = slap_schema.si_ad_entryCSN;
910 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
911 ber_dupbv( &mod->sml_values[0], &csn );
912 mod->sml_values[1].bv_len = 0;
913 mod->sml_values[1].bv_val = NULL;
914 assert( mod->sml_values[0].bv_val );
915 mod->sml_nvalues = NULL;
917 modtail = &mod->sml_next;
919 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
921 mod->sml_type.bv_val = NULL;
922 mod->sml_desc = slap_schema.si_ad_modifiersName;
923 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
924 ber_dupbv( &mod->sml_values[0], &name );
925 mod->sml_values[1].bv_len = 0;
926 mod->sml_values[1].bv_val = NULL;
927 assert( mod->sml_values[0].bv_val );
929 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
930 ber_dupbv( &mod->sml_nvalues[0], &nname );
931 mod->sml_nvalues[1].bv_len = 0;
932 mod->sml_nvalues[1].bv_val = NULL;
933 assert( mod->sml_nvalues[0].bv_val );
935 modtail = &mod->sml_next;
937 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
939 mod->sml_type.bv_val = NULL;
940 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
941 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
942 ber_dupbv( &mod->sml_values[0], ×tamp );
943 mod->sml_values[1].bv_len = 0;
944 mod->sml_values[1].bv_val = NULL;
945 assert( mod->sml_values[0].bv_val );
946 mod->sml_nvalues = NULL;
948 modtail = &mod->sml_next;