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;
55 LDAP_LOG( OPERATION, ENTRY, "do_modify: enter\n", 0, 0, 0 );
57 Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
61 * Parse the modify request. It looks like this:
63 * ModifyRequest := [APPLICATION 6] SEQUENCE {
64 * name DistinguishedName,
65 * mods SEQUENCE OF SEQUENCE {
66 * operation ENUMERATED {
71 * modification SEQUENCE {
73 * values SET OF AttributeValue
79 if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) {
81 LDAP_LOG( OPERATION, ERR, "do_modify: ber_scanf failed\n", 0, 0, 0 );
83 Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 );
86 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
87 return SLAPD_DISCONNECT;
91 LDAP_LOG( OPERATION, ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
93 Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
97 /* collect modifications & save for later */
99 for ( tag = ber_first_element( op->o_ber, &len, &last );
101 tag = ber_next_element( op->o_ber, &len, last ) )
104 Modifications tmp, *mod;
106 tmp.sml_nvalues = NULL;
108 if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
109 &tmp.sml_type, &tmp.sml_values )
112 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding modlist error" );
113 rs->sr_err = SLAPD_DISCONNECT;
117 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
119 mod->sml_type = tmp.sml_type;
120 mod->sml_values = tmp.sml_values;
121 mod->sml_nvalues = NULL;
122 mod->sml_desc = NULL;
123 mod->sml_next = NULL;
128 if ( mod->sml_values == NULL ) {
130 LDAP_LOG( OPERATION, ERR,
131 "do_modify: modify/add operation (%ld) requires values\n",
134 Debug( LDAP_DEBUG_ANY,
135 "do_modify: modify/add operation (%ld) requires values\n",
139 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
140 "modify/add operation requires values" );
146 case LDAP_MOD_DELETE:
147 case LDAP_MOD_REPLACE:
150 case LDAP_MOD_INCREMENT:
151 if( op->o_protocol >= LDAP_VERSION3 ) {
153 if ( mod->sml_values == NULL ) {
155 LDAP_LOG( OPERATION, ERR, "do_modify: "
156 "modify/increment operation (%ld) requires value\n",
159 Debug( LDAP_DEBUG_ANY, "do_modify: "
160 "modify/increment operation (%ld) requires value\n",
164 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
165 "modify/increment operation requires value" );
169 if( mod->sml_values[1].bv_val ) {
171 LDAP_LOG( OPERATION, ERR, "do_modify: modify/increment "
172 "operation (%ld) requires single value\n",
175 Debug( LDAP_DEBUG_ANY, "do_modify: modify/increment "
176 "operation (%ld) requires single value\n",
180 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
181 "modify/increment operation requires single value" );
191 LDAP_LOG( OPERATION, ERR,
192 "do_modify: unrecognized modify operation (%ld)\n",
195 Debug( LDAP_DEBUG_ANY,
196 "do_modify: unrecognized modify operation (%ld)\n",
200 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
201 "unrecognized modify operation" );
206 modtail = &mod->sml_next;
210 if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
212 LDAP_LOG( OPERATION, ERR, "do_modify: get_ctrls failed\n", 0, 0, 0 );
214 Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
220 rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
222 if( rs->sr_err != LDAP_SUCCESS ) {
224 LDAP_LOG( OPERATION, INFO, "do_modify: conn %d invalid dn (%s)\n",
225 op->o_connid, dn.bv_val, 0 );
227 Debug( LDAP_DEBUG_ANY,
228 "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 );
230 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
234 if( op->o_req_ndn.bv_len == 0 ) {
236 LDAP_LOG( OPERATION, ERR,
237 "do_modify: attempt to modify root DSE.\n",0, 0, 0 );
239 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
242 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
243 "modify upon the root DSE not supported" );
246 } else if ( bvmatch( &op->o_req_ndn, &global_schemandn ) ) {
248 LDAP_LOG( OPERATION, ERR,
249 "do_modify: attempt to modify subschema subentry.\n" , 0, 0, 0 );
251 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
254 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
255 "modification of subschema subentry not supported" );
261 LDAP_LOG( OPERATION, DETAIL1, "do_modify: modifications:\n", 0, 0, 0 );
263 Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
266 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
268 LDAP_LOG( OPERATION, DETAIL1, "\t%s: %s\n",
269 tmp->sml_op == LDAP_MOD_ADD ? "add" :
270 (tmp->sml_op == LDAP_MOD_INCREMENT ? "increment" :
271 (tmp->sml_op == LDAP_MOD_DELETE ? "delete" :
272 "replace")), tmp->sml_type.bv_val, 0 );
274 if ( tmp->sml_values == NULL ) {
275 LDAP_LOG( OPERATION, DETAIL1, "\t\tno values", 0, 0, 0 );
276 } else if ( tmp->sml_values[0].bv_val == NULL ) {
277 LDAP_LOG( OPERATION, DETAIL1, "\t\tzero values", 0, 0, 0 );
278 } else if ( tmp->sml_values[1].bv_val == NULL ) {
279 LDAP_LOG( OPERATION, DETAIL1, "\t\tone value", 0, 0, 0 );
281 LDAP_LOG( OPERATION, DETAIL1, "\t\tmultiple values", 0, 0, 0 );
285 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
286 tmp->sml_op == LDAP_MOD_ADD ? "add" :
287 (tmp->sml_op == LDAP_MOD_INCREMENT ? "increment" :
288 (tmp->sml_op == LDAP_MOD_DELETE ? "delete" :
289 "replace")), tmp->sml_type.bv_val, 0 );
291 if ( tmp->sml_values == NULL ) {
292 Debug( LDAP_DEBUG_ARGS, "%s\n",
293 "\t\tno values", NULL, NULL );
294 } else if ( tmp->sml_values[0].bv_val == NULL ) {
295 Debug( LDAP_DEBUG_ARGS, "%s\n",
296 "\t\tzero values", NULL, NULL );
297 } else if ( tmp->sml_values[1].bv_val == NULL ) {
298 Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
299 "\t\tone value", (long) tmp->sml_values[0].bv_len, NULL );
301 Debug( LDAP_DEBUG_ARGS, "%s\n",
302 "\t\tmultiple values", NULL, NULL );
307 if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
308 char abuf[BUFSIZ/2], *ptr = abuf;
311 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD dn=\"%s\"\n",
312 op->o_connid, op->o_opid, dn.bv_val, 0, 0 );
314 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
315 if (len + 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
316 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
317 op->o_connid, op->o_opid, abuf, 0, 0 );
322 if( 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
323 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
324 op->o_connid, op->o_opid, tmp->sml_type.bv_val, 0, 0 );
332 ptr = lutil_strcopy(ptr, tmp->sml_type.bv_val);
333 len += tmp->sml_type.bv_len;
336 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
337 op->o_connid, op->o_opid, abuf, 0, 0 );
340 #endif /* LDAP_DEBUG */
342 manageDSAit = get_manageDSAit( op );
345 * We could be serving multiple database backends. Select the
346 * appropriate one, or send a referral to our "referral server"
347 * if we don't hold it.
349 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 );
350 if ( op->o_bd == NULL ) {
351 rs->sr_ref = referral_rewrite( default_referral,
352 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
353 if (!rs->sr_ref) rs->sr_ref = default_referral;
355 if (rs->sr_ref != NULL ) {
356 rs->sr_err = LDAP_REFERRAL;
357 send_ldap_result( op, rs );
359 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
361 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
362 "referral missing" );
367 /* check restrictions */
368 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
369 send_ldap_result( op, rs );
373 /* check for referrals */
374 if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
378 /* check for modify/increment support */
379 if( increment && !SLAP_INCREMENT( op->o_bd ) ) {
380 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
381 "modify/increment not supported in context" );
384 #if defined( LDAP_SLAPI )
387 slapi_x_pblock_set_operation( pb, op );
388 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
389 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
390 modv = slapi_x_modifications2ldapmods( &modlist );
391 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
393 rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
394 if ( rs->sr_err < 0 ) {
396 * A preoperation plugin failure will abort the
400 LDAP_LOG( OPERATION, INFO, "do_modify: modify preoperation plugin "
401 "failed\n", 0, 0, 0 );
403 Debug(LDAP_DEBUG_TRACE, "do_modify: modify preoperation plugin failed.\n",
406 if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
407 rs->sr_err == LDAP_SUCCESS ) {
408 rs->sr_err = LDAP_OTHER;
410 slapi_x_free_ldapmods( modv );
416 * It's possible that the preoperation plugin changed the
417 * modification array, so we need to convert it back to
418 * a Modification list.
420 * Calling slapi_x_modifications2ldapmods() destroyed modlist so
421 * we don't need to free it.
423 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
424 modlist = slapi_x_ldapmods2modifications( modv );
428 * NB: it is valid for the plugin to return no modifications
429 * (for example, a plugin might store some attributes elsewhere
430 * and remove them from the modification list; if only those
431 * attribute types were included in the modification request,
432 * then slapi_x_ldapmods2modifications() above will return
435 * However, the post-operation plugin should still be
438 if ( modlist == NULL ) {
439 rs->sr_err = LDAP_SUCCESS;
440 send_ldap_result( op, rs );
442 #endif /* defined( LDAP_SLAPI ) */
445 * do the modify if 1 && (2 || 3)
446 * 1) there is a modify function implemented in this backend;
447 * 2) this backend is master for what it holds;
448 * 3) it's a replica and the dn supplied is the update_ndn.
450 if ( op->o_bd->be_modify ) {
451 /* do the update here */
452 int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
454 /* Multimaster slapd does not have to check for replicator dn
455 * because it accepts each modify request
457 #ifndef SLAPD_MULTIMASTER
458 if ( !op->o_bd->be_syncinfo &&
459 ( !op->o_bd->be_update_ndn.bv_len || repl_user ))
461 if ( !op->o_bd->be_syncinfo )
464 int update = op->o_bd->be_update_ndn.bv_len;
465 char textbuf[SLAP_TEXT_BUFLEN];
466 size_t textlen = sizeof textbuf;
468 rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
469 textbuf, textlen, NULL );
471 if( rs->sr_err != LDAP_SUCCESS ) {
472 send_ldap_result( op, rs );
477 for( modtail = &modlist;
479 modtail = &(*modtail)->sml_next )
484 rs->sr_err = slap_mods_opattrs( op, modlist, modtail,
485 &rs->sr_text, textbuf, textlen );
486 if( rs->sr_err != LDAP_SUCCESS ) {
487 send_ldap_result( op, rs );
492 op->orm_modlist = modlist;
493 if ( (op->o_bd->be_modify)( op, rs ) == 0
494 #ifdef SLAPD_MULTIMASTER
498 /* but we log only the ones not from a replicator user */
502 #ifndef SLAPD_MULTIMASTER
503 /* send a referral */
505 BerVarray defref = NULL;
506 if ( op->o_bd->be_syncinfo ) {
507 defref = op->o_bd->be_syncinfo->si_provideruri_bv;
509 defref = op->o_bd->be_update_refs
510 ? op->o_bd->be_update_refs : default_referral;
512 if ( defref != NULL ) {
513 rs->sr_ref = referral_rewrite( defref,
515 LDAP_SCOPE_DEFAULT );
516 if (!rs->sr_ref) rs->sr_ref = defref;
517 rs->sr_err = LDAP_REFERRAL;
518 send_ldap_result( op, rs );
519 if (rs->sr_ref != defref) {
520 ber_bvarray_free( rs->sr_ref );
523 send_ldap_error( op, rs,
524 LDAP_UNWILLING_TO_PERFORM,
525 "referral missing" );
530 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
531 "operation not supported within namingContext" );
534 #if defined( LDAP_SLAPI )
535 } /* modlist != NULL */
537 if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) {
539 LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins "
540 "failed\n", 0, 0, 0 );
542 Debug(LDAP_DEBUG_TRACE, "do_modify: modify postoperation plugins "
543 "failed.\n", 0, 0, 0);
546 #endif /* defined( LDAP_SLAPI ) */
550 slap_graduate_commit_csn( op );
552 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
553 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
554 if ( modlist != NULL ) slap_mods_free( modlist );
555 #if defined( LDAP_SLAPI )
556 if ( modv != NULL ) slapi_x_free_ldapmods( modv );
562 * Do basic attribute type checking and syntax validation.
574 for( ; ml != NULL; ml = ml->sml_next ) {
575 AttributeDescription *ad = NULL;
577 /* convert to attribute description */
578 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
580 if( rc != LDAP_SUCCESS ) {
581 snprintf( textbuf, textlen, "%s: %s",
582 ml->sml_type.bv_val, *text );
589 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
590 && !slap_ad_is_binary( ad ))
592 /* attribute requires binary transfer */
593 snprintf( textbuf, textlen,
594 "%s: requires ;binary transfer",
595 ml->sml_type.bv_val );
597 return LDAP_UNDEFINED_TYPE;
600 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
601 && slap_ad_is_binary( ad ))
603 /* attribute requires binary transfer */
604 snprintf( textbuf, textlen,
605 "%s: disallows ;binary transfer",
606 ml->sml_type.bv_val );
608 return LDAP_UNDEFINED_TYPE;
611 if( slap_ad_is_tag_range( ad )) {
612 /* attribute requires binary transfer */
613 snprintf( textbuf, textlen,
614 "%s: inappropriate use of tag range option",
615 ml->sml_type.bv_val );
617 return LDAP_UNDEFINED_TYPE;
620 if (!update && is_at_no_user_mod( ad->ad_type )) {
621 /* user modification disallowed */
622 snprintf( textbuf, textlen,
623 "%s: no user modification allowed",
624 ml->sml_type.bv_val );
626 return LDAP_CONSTRAINT_VIOLATION;
629 if ( is_at_obsolete( ad->ad_type ) &&
630 (( ml->sml_op != LDAP_MOD_REPLACE &&
631 ml->sml_op != LDAP_MOD_DELETE ) ||
632 ml->sml_values != NULL ))
635 * attribute is obsolete,
636 * only allow replace/delete with no values
638 snprintf( textbuf, textlen,
639 "%s: attribute is obsolete",
640 ml->sml_type.bv_val );
642 return LDAP_CONSTRAINT_VIOLATION;
645 if ( ml->sml_op == LDAP_MOD_INCREMENT &&
646 #ifdef SLAPD_REAL_SYNTAX
647 !is_at_syntax( ad->ad_type, SLAPD_REAL_SYNTAX ) &&
649 !is_at_syntax( ad->ad_type, SLAPD_INTEGER_SYNTAX ) )
652 * attribute values must be INTEGER or REAL
654 snprintf( textbuf, textlen,
655 "%s: attribute syntax inappropriate for increment",
656 ml->sml_type.bv_val );
658 return LDAP_CONSTRAINT_VIOLATION;
664 if( ml->sml_values != NULL ) {
666 slap_syntax_validate_func *validate =
667 ad->ad_type->sat_syntax->ssyn_validate;
668 slap_syntax_transform_func *pretty =
669 ad->ad_type->sat_syntax->ssyn_pretty;
671 if( !pretty && !validate ) {
672 *text = "no validator for syntax";
673 snprintf( textbuf, textlen,
674 "%s: no validator for syntax %s",
676 ad->ad_type->sat_syntax->ssyn_oid );
678 return LDAP_INVALID_SYNTAX;
682 * check that each value is valid per syntax
683 * and pretty if appropriate
685 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
688 rc = pretty( ad->ad_type->sat_syntax,
689 &ml->sml_values[nvals], &pval, ctx );
691 rc = validate( ad->ad_type->sat_syntax,
692 &ml->sml_values[nvals] );
696 snprintf( textbuf, textlen,
697 "%s: value #%ld invalid per syntax",
698 ml->sml_type.bv_val, (long) nvals );
700 return LDAP_INVALID_SYNTAX;
704 ber_memfree_x( ml->sml_values[nvals].bv_val, ctx );
705 ml->sml_values[nvals] = pval;
710 * a rough single value check... an additional check is needed
711 * to catch add of single value to existing single valued attribute
713 if ((ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE)
714 && nvals > 1 && is_at_single_value( ad->ad_type ))
716 snprintf( textbuf, textlen,
717 "%s: multiple values provided",
718 ml->sml_type.bv_val );
720 return LDAP_CONSTRAINT_VIOLATION;
723 /* if the type has a normalizer, generate the
724 * normalized values. otherwise leave them NULL.
726 * this is different from the rule for attributes
727 * in an entry - in an attribute list, the normalized
728 * value is set equal to the non-normalized value
729 * when there is no normalizer.
731 if( nvals && ad->ad_type->sat_equality &&
732 ad->ad_type->sat_equality->smr_normalize )
734 ml->sml_nvalues = ber_memalloc_x(
735 (nvals+1)*sizeof(struct berval), ctx );
737 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
738 rc = ad->ad_type->sat_equality->smr_normalize(
739 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
740 ad->ad_type->sat_syntax,
741 ad->ad_type->sat_equality,
742 &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
745 LDAP_LOG( OPERATION, DETAIL1,
746 "str2entry: NULL (ssyn_normalize %d)\n",
749 Debug( LDAP_DEBUG_ANY,
750 "<= str2entry NULL (ssyn_normalize %d)\n",
753 snprintf( textbuf, textlen,
754 "%s: value #%ld normalization failed",
755 ml->sml_type.bv_val, (long) nvals );
761 ml->sml_nvalues[nvals].bv_val = NULL;
762 ml->sml_nvalues[nvals].bv_len = 0;
770 int slap_mods_opattrs(
773 Modifications **modtail,
775 char *textbuf, size_t textlen )
777 struct berval name, timestamp, csn;
779 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
780 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
783 int mop = op->o_tag == LDAP_REQ_ADD
784 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
786 assert( modtail != NULL );
787 assert( *modtail == NULL );
789 if ( SLAP_LASTMOD( op->o_bd )) {
791 time_t now = slap_get_time();
793 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
794 ltm = gmtime( &now );
795 lutil_gentime( timebuf, sizeof(timebuf), ltm );
797 slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 );
799 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
801 timestamp.bv_val = timebuf;
802 timestamp.bv_len = strlen(timebuf);
804 if( op->o_dn.bv_len == 0 ) {
805 name.bv_val = SLAPD_ANONYMOUS;
806 name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
814 if( op->o_tag == LDAP_REQ_ADD ) {
815 struct berval tmpval;
817 if( global_schemacheck ) {
818 int rc = mods_structural_class( mods, &tmpval,
819 text, textbuf, textlen );
820 if( rc != LDAP_SUCCESS ) return rc;
822 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
824 mod->sml_type.bv_val = NULL;
825 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
827 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
828 ber_dupbv( &mod->sml_values[0], &tmpval );
829 mod->sml_values[1].bv_len = 0;
830 mod->sml_values[1].bv_val = NULL;
831 assert( mod->sml_values[0].bv_val );
833 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
834 ber_dupbv( &mod->sml_nvalues[0], &tmpval );
835 mod->sml_nvalues[1].bv_len = 0;
836 mod->sml_nvalues[1].bv_val = NULL;
837 assert( mod->sml_nvalues[0].bv_val );
839 modtail = &mod->sml_next;
842 if ( SLAP_LASTMOD( op->o_bd )) {
843 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
845 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
846 tmpval.bv_val = uuidbuf;
848 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
850 mod->sml_type.bv_val = NULL;
851 mod->sml_desc = slap_schema.si_ad_entryUUID;
853 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
854 ber_dupbv( &mod->sml_values[0], &tmpval );
855 mod->sml_values[1].bv_len = 0;
856 mod->sml_values[1].bv_val = NULL;
857 assert( mod->sml_values[0].bv_val );
859 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
860 (*mod->sml_desc->ad_type->sat_equality->smr_normalize)(
861 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
862 mod->sml_desc->ad_type->sat_syntax,
863 mod->sml_desc->ad_type->sat_equality,
864 mod->sml_values, mod->sml_nvalues, NULL );
865 mod->sml_nvalues[1].bv_len = 0;
866 mod->sml_nvalues[1].bv_val = NULL;
868 modtail = &mod->sml_next;
870 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
872 mod->sml_type.bv_val = NULL;
873 mod->sml_desc = slap_schema.si_ad_creatorsName;
875 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
876 ber_dupbv( &mod->sml_values[0], &name );
877 mod->sml_values[1].bv_len = 0;
878 mod->sml_values[1].bv_val = NULL;
879 assert( mod->sml_values[0].bv_val );
881 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
882 ber_dupbv( &mod->sml_nvalues[0], &nname );
883 mod->sml_nvalues[1].bv_len = 0;
884 mod->sml_nvalues[1].bv_val = NULL;
885 assert( mod->sml_nvalues[0].bv_val );
887 modtail = &mod->sml_next;
889 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
891 mod->sml_type.bv_val = NULL;
892 mod->sml_desc = slap_schema.si_ad_createTimestamp;
894 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
895 ber_dupbv( &mod->sml_values[0], ×tamp );
896 mod->sml_values[1].bv_len = 0;
897 mod->sml_values[1].bv_val = NULL;
898 assert( mod->sml_values[0].bv_val );
899 mod->sml_nvalues = NULL;
901 modtail = &mod->sml_next;
905 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;