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;
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:
152 LDAP_LOG( OPERATION, ERR,
153 "do_modify: invalid modify operation (%ld)\n",
156 Debug( LDAP_DEBUG_ANY,
157 "do_modify: invalid modify operation (%ld)\n",
161 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
162 "unrecognized modify operation" );
167 modtail = &mod->sml_next;
171 if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
173 LDAP_LOG( OPERATION, ERR, "do_modify: get_ctrls failed\n", 0, 0, 0 );
175 Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
181 rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
183 if( rs->sr_err != LDAP_SUCCESS ) {
185 LDAP_LOG( OPERATION, INFO, "do_modify: conn %d invalid dn (%s)\n",
186 op->o_connid, dn.bv_val, 0 );
188 Debug( LDAP_DEBUG_ANY,
189 "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 );
191 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
195 if( op->o_req_ndn.bv_len == 0 ) {
197 LDAP_LOG( OPERATION, ERR,
198 "do_modify: attempt to modify root DSE.\n",0, 0, 0 );
200 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
203 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
204 "modify upon the root DSE not supported" );
207 } else if ( bvmatch( &op->o_req_ndn, &global_schemandn ) ) {
209 LDAP_LOG( OPERATION, ERR,
210 "do_modify: attempt to modify subschema subentry.\n" , 0, 0, 0 );
212 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
215 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
216 "modification of subschema subentry not supported" );
222 LDAP_LOG( OPERATION, DETAIL1, "do_modify: modifications:\n", 0, 0, 0 );
224 Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
227 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
229 LDAP_LOG( OPERATION, DETAIL1, "\t%s: %s\n",
230 tmp->sml_op == LDAP_MOD_ADD ?
231 "add" : (tmp->sml_op == LDAP_MOD_DELETE ?
232 "delete" : "replace"), tmp->sml_type.bv_val, 0 );
234 if ( tmp->sml_values == NULL ) {
235 LDAP_LOG( OPERATION, DETAIL1, "\t\tno values", 0, 0, 0 );
236 } else if ( tmp->sml_values[0].bv_val == NULL ) {
237 LDAP_LOG( OPERATION, DETAIL1, "\t\tzero values", 0, 0, 0 );
238 } else if ( tmp->sml_values[1].bv_val == NULL ) {
239 LDAP_LOG( OPERATION, DETAIL1, "\t\tone value", 0, 0, 0 );
241 LDAP_LOG( OPERATION, DETAIL1, "\t\tmultiple values", 0, 0, 0 );
245 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
246 tmp->sml_op == LDAP_MOD_ADD
247 ? "add" : (tmp->sml_op == LDAP_MOD_DELETE
248 ? "delete" : "replace"), tmp->sml_type.bv_val, 0 );
250 if ( tmp->sml_values == NULL ) {
251 Debug( LDAP_DEBUG_ARGS, "%s\n",
252 "\t\tno values", NULL, NULL );
253 } else if ( tmp->sml_values[0].bv_val == NULL ) {
254 Debug( LDAP_DEBUG_ARGS, "%s\n",
255 "\t\tzero values", NULL, NULL );
256 } else if ( tmp->sml_values[1].bv_val == NULL ) {
257 Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
258 "\t\tone value", (long) tmp->sml_values[0].bv_len, NULL );
260 Debug( LDAP_DEBUG_ARGS, "%s\n",
261 "\t\tmultiple values", NULL, NULL );
266 if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
267 char abuf[BUFSIZ/2], *ptr = abuf;
270 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD dn=\"%s\"\n",
271 op->o_connid, op->o_opid, dn.bv_val, 0, 0 );
273 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
274 if (len + 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
275 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
276 op->o_connid, op->o_opid, abuf, 0, 0 );
284 ptr = lutil_strcopy(ptr, tmp->sml_type.bv_val);
285 len += tmp->sml_type.bv_len;
288 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
289 op->o_connid, op->o_opid, abuf, 0, 0 );
292 #endif /* LDAP_DEBUG */
294 manageDSAit = get_manageDSAit( op );
297 * We could be serving multiple database backends. Select the
298 * appropriate one, or send a referral to our "referral server"
299 * if we don't hold it.
301 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 );
302 if ( op->o_bd == NULL ) {
303 rs->sr_ref = referral_rewrite( default_referral,
304 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
305 if (!rs->sr_ref) rs->sr_ref = default_referral;
307 if (rs->sr_ref != NULL ) {
308 rs->sr_err = LDAP_REFERRAL;
309 send_ldap_result( op, rs );
311 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
313 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
314 "referral missing" );
319 /* check restrictions */
320 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
321 send_ldap_result( op, rs );
325 /* check for referrals */
326 if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
330 #if defined( LDAP_SLAPI )
331 slapi_x_pblock_set_operation( pb, op );
332 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
333 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
334 modv = slapi_x_modifications2ldapmods( &modlist );
335 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
337 rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
338 if ( rs->sr_err < 0 ) {
340 * A preoperation plugin failure will abort the
344 LDAP_LOG( OPERATION, INFO, "do_modify: modify preoperation plugin "
345 "failed\n", 0, 0, 0 );
347 Debug(LDAP_DEBUG_TRACE, "do_modify: modify preoperation plugin failed.\n",
350 if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0) {
351 rs->sr_err = LDAP_OTHER;
353 slapi_x_free_ldapmods( modv );
359 * It's possible that the preoperation plugin changed the
360 * modification array, so we need to convert it back to
361 * a Modification list.
363 * Calling slapi_x_modifications2ldapmods() destroyed modlist so
364 * we don't need to free it.
366 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
367 modlist = slapi_x_ldapmods2modifications( modv );
370 * NB: it is valid for the plugin to return no modifications
371 * (for example, a plugin might store some attributes elsewhere
372 * and remove them from the modification list; if only those
373 * attribute types were included in the modification request,
374 * then slapi_x_ldapmods2modifications() above will return
377 if ( modlist == NULL ) {
378 rs->sr_err = LDAP_SUCCESS;
379 send_ldap_result( op, rs );
382 #endif /* defined( LDAP_SLAPI ) */
385 * do the modify if 1 && (2 || 3)
386 * 1) there is a modify function implemented in this backend;
387 * 2) this backend is master for what it holds;
388 * 3) it's a replica and the dn supplied is the update_ndn.
390 if ( op->o_bd->be_modify ) {
391 /* do the update here */
392 int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
393 #ifndef SLAPD_MULTIMASTER
394 /* Multimaster slapd does not have to check for replicator dn
395 * because it accepts each modify request
397 if ( !op->o_bd->be_update_ndn.bv_len || repl_user )
400 int update = op->o_bd->be_update_ndn.bv_len;
401 char textbuf[SLAP_TEXT_BUFLEN];
402 size_t textlen = sizeof textbuf;
404 rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
405 textbuf, textlen, NULL );
407 if( rs->sr_err != LDAP_SUCCESS ) {
408 send_ldap_result( op, rs );
413 for( modtail = &modlist;
415 modtail = &(*modtail)->sml_next )
420 rs->sr_err = slap_mods_opattrs( op, modlist, modtail,
421 &rs->sr_text, textbuf, textlen );
422 if( rs->sr_err != LDAP_SUCCESS ) {
423 send_ldap_result( op, rs );
428 op->orm_modlist = modlist;
429 if ( (op->o_bd->be_modify)( op, rs ) == 0
430 #ifdef SLAPD_MULTIMASTER
434 /* but we log only the ones not from a replicator user */
438 #ifndef SLAPD_MULTIMASTER
439 /* send a referral */
441 BerVarray defref = op->o_bd->be_update_refs
442 ? op->o_bd->be_update_refs : default_referral;
443 if ( defref != NULL ) {
444 rs->sr_ref = referral_rewrite( defref,
446 LDAP_SCOPE_DEFAULT );
447 if (!rs->sr_ref) rs->sr_ref = defref;
448 rs->sr_err = LDAP_REFERRAL;
449 send_ldap_result( op, rs );
450 if (rs->sr_ref != defref) {
451 ber_bvarray_free( rs->sr_ref );
454 send_ldap_error( op, rs,
455 LDAP_UNWILLING_TO_PERFORM,
456 "referral missing" );
461 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
462 "operation not supported within namingContext" );
465 #if defined( LDAP_SLAPI )
466 if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) {
468 LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins "
469 "failed\n", 0, 0, 0 );
471 Debug(LDAP_DEBUG_TRACE, "do_modify: modify postoperation plugins "
472 "failed.\n", 0, 0, 0);
475 #endif /* defined( LDAP_SLAPI ) */
478 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
479 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
480 if ( modlist != NULL ) slap_mods_free( modlist );
481 #if defined( LDAP_SLAPI )
482 if ( modv != NULL ) slapi_x_free_ldapmods( modv );
488 * Do basic attribute type checking and syntax validation.
500 for( ; ml != NULL; ml = ml->sml_next ) {
501 AttributeDescription *ad = NULL;
503 /* convert to attribute description */
504 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
506 if( rc != LDAP_SUCCESS ) {
507 snprintf( textbuf, textlen, "%s: %s",
508 ml->sml_type.bv_val, *text );
515 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
516 && !slap_ad_is_binary( ad ))
518 /* attribute requires binary transfer */
519 snprintf( textbuf, textlen,
520 "%s: requires ;binary transfer",
521 ml->sml_type.bv_val );
523 return LDAP_UNDEFINED_TYPE;
526 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
527 && slap_ad_is_binary( ad ))
529 /* attribute requires binary transfer */
530 snprintf( textbuf, textlen,
531 "%s: disallows ;binary transfer",
532 ml->sml_type.bv_val );
534 return LDAP_UNDEFINED_TYPE;
537 if( slap_ad_is_tag_range( ad )) {
538 /* attribute requires binary transfer */
539 snprintf( textbuf, textlen,
540 "%s: inappropriate use of tag range option",
541 ml->sml_type.bv_val );
543 return LDAP_UNDEFINED_TYPE;
546 if (!update && is_at_no_user_mod( ad->ad_type )) {
547 /* user modification disallowed */
548 snprintf( textbuf, textlen,
549 "%s: no user modification allowed",
550 ml->sml_type.bv_val );
552 return LDAP_CONSTRAINT_VIOLATION;
555 if ( is_at_obsolete( ad->ad_type ) &&
556 ( ml->sml_op == LDAP_MOD_ADD || ml->sml_values != NULL ) )
559 * attribute is obsolete,
560 * only allow replace/delete with no values
562 snprintf( textbuf, textlen,
563 "%s: attribute is obsolete",
564 ml->sml_type.bv_val );
566 return LDAP_CONSTRAINT_VIOLATION;
572 if( ml->sml_values != NULL ) {
574 slap_syntax_validate_func *validate =
575 ad->ad_type->sat_syntax->ssyn_validate;
576 slap_syntax_transform_func *pretty =
577 ad->ad_type->sat_syntax->ssyn_pretty;
579 if( !pretty && !validate ) {
580 *text = "no validator for syntax";
581 snprintf( textbuf, textlen,
582 "%s: no validator for syntax %s",
584 ad->ad_type->sat_syntax->ssyn_oid );
586 return LDAP_INVALID_SYNTAX;
590 * check that each value is valid per syntax
591 * and pretty if appropriate
593 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
596 rc = pretty( ad->ad_type->sat_syntax,
597 &ml->sml_values[nvals], &pval, ctx );
599 rc = validate( ad->ad_type->sat_syntax,
600 &ml->sml_values[nvals] );
604 snprintf( textbuf, textlen,
605 "%s: value #%ld invalid per syntax",
606 ml->sml_type.bv_val, (long) nvals );
608 return LDAP_INVALID_SYNTAX;
612 ber_memfree_x( ml->sml_values[nvals].bv_val, ctx );
613 ml->sml_values[nvals] = pval;
618 * a rough single value check... an additional check is needed
619 * to catch add of single value to existing single valued attribute
621 if ((ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE)
622 && nvals > 1 && is_at_single_value( ad->ad_type ))
624 snprintf( textbuf, textlen,
625 "%s: multiple values provided",
626 ml->sml_type.bv_val );
628 return LDAP_CONSTRAINT_VIOLATION;
631 if( nvals && ad->ad_type->sat_equality &&
632 ad->ad_type->sat_equality->smr_normalize )
634 ml->sml_nvalues = ber_memalloc_x(
635 (nvals+1)*sizeof(struct berval), ctx );
637 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
638 rc = ad->ad_type->sat_equality->smr_normalize(
640 ad->ad_type->sat_syntax,
641 ad->ad_type->sat_equality,
642 &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
645 LDAP_LOG( OPERATION, DETAIL1,
646 "str2entry: NULL (ssyn_normalize %d)\n",
649 Debug( LDAP_DEBUG_ANY,
650 "<= str2entry NULL (ssyn_normalize %d)\n",
653 snprintf( textbuf, textlen,
654 "%s: value #%ld normalization failed",
655 ml->sml_type.bv_val, (long) nvals );
661 ml->sml_nvalues[nvals].bv_val = NULL;
662 ml->sml_nvalues[nvals].bv_len = 0;
672 int slap_mods_opattrs(
675 Modifications **modtail,
677 char *textbuf, size_t textlen )
679 struct berval name, timestamp, csn;
681 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
682 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
685 int mop = op->o_tag == LDAP_REQ_ADD
686 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
688 assert( modtail != NULL );
689 assert( *modtail == NULL );
691 if( SLAP_LASTMOD(op->o_bd) ) {
693 time_t now = slap_get_time();
695 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
696 ltm = gmtime( &now );
697 lutil_gentime( timebuf, sizeof(timebuf), ltm );
699 csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 );
700 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
703 timestamp.bv_val = timebuf;
704 timestamp.bv_len = strlen(timebuf);
706 if( op->o_dn.bv_len == 0 ) {
707 name.bv_val = SLAPD_ANONYMOUS;
708 name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
716 if( op->o_tag == LDAP_REQ_ADD ) {
717 struct berval tmpval;
719 if( global_schemacheck ) {
720 int rc = mods_structural_class( mods, &tmpval,
721 text, textbuf, textlen );
722 if( rc != LDAP_SUCCESS ) {
726 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
728 mod->sml_type.bv_val = NULL;
729 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
731 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
732 ber_dupbv( &mod->sml_values[0], &tmpval );
733 mod->sml_values[1].bv_len = 0;
734 mod->sml_values[1].bv_val = NULL;
735 assert( mod->sml_values[0].bv_val );
737 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
738 ber_dupbv( &mod->sml_nvalues[0], &tmpval );
739 mod->sml_nvalues[1].bv_len = 0;
740 mod->sml_nvalues[1].bv_val = NULL;
741 assert( mod->sml_nvalues[0].bv_val );
743 modtail = &mod->sml_next;
746 if( SLAP_LASTMOD(op->o_bd) ) {
747 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
749 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
750 tmpval.bv_val = uuidbuf;
752 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
754 mod->sml_type.bv_val = NULL;
755 mod->sml_desc = slap_schema.si_ad_entryUUID;
757 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
758 ber_dupbv( &mod->sml_values[0], &tmpval );
759 mod->sml_values[1].bv_len = 0;
760 mod->sml_values[1].bv_val = NULL;
761 assert( mod->sml_values[0].bv_val );
762 mod->sml_nvalues = NULL;
764 modtail = &mod->sml_next;
766 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
768 mod->sml_type.bv_val = NULL;
769 mod->sml_desc = slap_schema.si_ad_creatorsName;
770 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
771 ber_dupbv( &mod->sml_values[0], &name );
772 mod->sml_values[1].bv_len = 0;
773 mod->sml_values[1].bv_val = NULL;
774 assert( mod->sml_values[0].bv_val );
776 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
777 ber_dupbv( &mod->sml_nvalues[0], &nname );
778 mod->sml_nvalues[1].bv_len = 0;
779 mod->sml_nvalues[1].bv_val = NULL;
780 assert( mod->sml_nvalues[0].bv_val );
782 modtail = &mod->sml_next;
784 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
786 mod->sml_type.bv_val = NULL;
787 mod->sml_desc = slap_schema.si_ad_createTimestamp;
788 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
789 ber_dupbv( &mod->sml_values[0], ×tamp );
790 mod->sml_values[1].bv_len = 0;
791 mod->sml_values[1].bv_val = NULL;
792 assert( mod->sml_values[0].bv_val );
793 mod->sml_nvalues = NULL;
795 modtail = &mod->sml_next;
799 if( SLAP_LASTMOD(op->o_bd) ) {
800 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
802 mod->sml_type.bv_val = NULL;
803 mod->sml_desc = slap_schema.si_ad_entryCSN;
804 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
805 ber_dupbv( &mod->sml_values[0], &csn );
806 mod->sml_values[1].bv_len = 0;
807 mod->sml_values[1].bv_val = NULL;
808 assert( mod->sml_values[0].bv_val );
809 mod->sml_nvalues = NULL;
811 modtail = &mod->sml_next;
813 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
815 mod->sml_type.bv_val = NULL;
816 mod->sml_desc = slap_schema.si_ad_modifiersName;
817 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
818 ber_dupbv( &mod->sml_values[0], &name );
819 mod->sml_values[1].bv_len = 0;
820 mod->sml_values[1].bv_val = NULL;
821 assert( mod->sml_values[0].bv_val );
823 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
824 ber_dupbv( &mod->sml_nvalues[0], &nname );
825 mod->sml_nvalues[1].bv_len = 0;
826 mod->sml_nvalues[1].bv_val = NULL;
827 assert( mod->sml_nvalues[0].bv_val );
829 modtail = &mod->sml_next;
831 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
833 mod->sml_type.bv_val = NULL;
834 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
835 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
836 ber_dupbv( &mod->sml_values[0], ×tamp );
837 mod->sml_values[1].bv_len = 0;
838 mod->sml_values[1].bv_val = NULL;
839 assert( mod->sml_values[0].bv_val );
840 mod->sml_nvalues = NULL;
842 modtail = &mod->sml_next;