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 );
323 if( 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
324 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
325 op->o_connid, op->o_opid, tmp->sml_type.bv_val, 0, 0 );
333 ptr = lutil_strcopy(ptr, tmp->sml_type.bv_val);
334 len += tmp->sml_type.bv_len;
337 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
338 op->o_connid, op->o_opid, abuf, 0, 0 );
341 #endif /* LDAP_DEBUG */
343 manageDSAit = get_manageDSAit( op );
346 * We could be serving multiple database backends. Select the
347 * appropriate one, or send a referral to our "referral server"
348 * if we don't hold it.
350 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 );
351 if ( op->o_bd == NULL ) {
352 rs->sr_ref = referral_rewrite( default_referral,
353 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
354 if (!rs->sr_ref) rs->sr_ref = default_referral;
356 if (rs->sr_ref != NULL ) {
357 rs->sr_err = LDAP_REFERRAL;
358 send_ldap_result( op, rs );
360 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
362 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
363 "referral missing" );
368 /* check restrictions */
369 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
370 send_ldap_result( op, rs );
374 /* check for referrals */
375 if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
379 /* check for modify/increment support */
380 if( increment && !SLAP_INCREMENT( op->o_bd ) ) {
381 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
382 "modify/increment not supported in context" );
385 #if defined( LDAP_SLAPI )
386 slapi_x_pblock_set_operation( pb, op );
387 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
388 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
389 modv = slapi_x_modifications2ldapmods( &modlist );
390 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
392 rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
393 if ( rs->sr_err < 0 ) {
395 * A preoperation plugin failure will abort the
399 LDAP_LOG( OPERATION, INFO, "do_modify: modify preoperation plugin "
400 "failed\n", 0, 0, 0 );
402 Debug(LDAP_DEBUG_TRACE, "do_modify: modify preoperation plugin failed.\n",
405 if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
406 rs->sr_err == LDAP_SUCCESS ) {
407 rs->sr_err = LDAP_OTHER;
409 slapi_x_free_ldapmods( modv );
415 * It's possible that the preoperation plugin changed the
416 * modification array, so we need to convert it back to
417 * a Modification list.
419 * Calling slapi_x_modifications2ldapmods() destroyed modlist so
420 * we don't need to free it.
422 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
423 modlist = slapi_x_ldapmods2modifications( modv );
426 * NB: it is valid for the plugin to return no modifications
427 * (for example, a plugin might store some attributes elsewhere
428 * and remove them from the modification list; if only those
429 * attribute types were included in the modification request,
430 * then slapi_x_ldapmods2modifications() above will return
433 * However, the post-operation plugin should still be
436 if ( modlist == NULL ) {
437 rs->sr_err = LDAP_SUCCESS;
438 send_ldap_result( op, rs );
440 #endif /* defined( LDAP_SLAPI ) */
443 * do the modify if 1 && (2 || 3)
444 * 1) there is a modify function implemented in this backend;
445 * 2) this backend is master for what it holds;
446 * 3) it's a replica and the dn supplied is the update_ndn.
448 if ( op->o_bd->be_modify ) {
449 /* do the update here */
450 int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
452 /* Multimaster slapd does not have to check for replicator dn
453 * because it accepts each modify request
455 #ifndef SLAPD_MULTIMASTER
456 if ( !op->o_bd->be_syncinfo &&
457 ( !op->o_bd->be_update_ndn.bv_len || repl_user ))
459 if ( !op->o_bd->be_syncinfo )
462 int update = op->o_bd->be_update_ndn.bv_len;
463 char textbuf[SLAP_TEXT_BUFLEN];
464 size_t textlen = sizeof textbuf;
466 rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
467 textbuf, textlen, NULL );
469 if( rs->sr_err != LDAP_SUCCESS ) {
470 send_ldap_result( op, rs );
475 for( modtail = &modlist;
477 modtail = &(*modtail)->sml_next )
482 rs->sr_err = slap_mods_opattrs( op, modlist, modtail,
483 &rs->sr_text, textbuf, textlen );
484 if( rs->sr_err != LDAP_SUCCESS ) {
485 send_ldap_result( op, rs );
490 op->orm_modlist = modlist;
491 if ( (op->o_bd->be_modify)( op, rs ) == 0
492 #ifdef SLAPD_MULTIMASTER
496 /* but we log only the ones not from a replicator user */
500 #ifndef SLAPD_MULTIMASTER
501 /* send a referral */
503 BerVarray defref = NULL;
504 if ( op->o_bd->be_syncinfo ) {
505 defref = op->o_bd->be_syncinfo->si_provideruri_bv;
507 defref = op->o_bd->be_update_refs
508 ? op->o_bd->be_update_refs : default_referral;
510 if ( defref != NULL ) {
511 rs->sr_ref = referral_rewrite( defref,
513 LDAP_SCOPE_DEFAULT );
514 if (!rs->sr_ref) rs->sr_ref = defref;
515 rs->sr_err = LDAP_REFERRAL;
516 send_ldap_result( op, rs );
517 if (rs->sr_ref != defref) {
518 ber_bvarray_free( rs->sr_ref );
521 send_ldap_error( op, rs,
522 LDAP_UNWILLING_TO_PERFORM,
523 "referral missing" );
528 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
529 "operation not supported within namingContext" );
532 #if defined( LDAP_SLAPI )
533 } /* modlist != NULL */
535 if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) {
537 LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins "
538 "failed\n", 0, 0, 0 );
540 Debug(LDAP_DEBUG_TRACE, "do_modify: modify postoperation plugins "
541 "failed.\n", 0, 0, 0);
544 #endif /* defined( LDAP_SLAPI ) */
548 slap_graduate_commit_csn( op );
550 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
551 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
552 if ( modlist != NULL ) slap_mods_free( modlist );
553 #if defined( LDAP_SLAPI )
554 if ( modv != NULL ) slapi_x_free_ldapmods( modv );
560 * Do basic attribute type checking and syntax validation.
572 for( ; ml != NULL; ml = ml->sml_next ) {
573 AttributeDescription *ad = NULL;
575 /* convert to attribute description */
576 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
578 if( rc != LDAP_SUCCESS ) {
579 snprintf( textbuf, textlen, "%s: %s",
580 ml->sml_type.bv_val, *text );
587 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
588 && !slap_ad_is_binary( ad ))
590 /* attribute requires binary transfer */
591 snprintf( textbuf, textlen,
592 "%s: requires ;binary transfer",
593 ml->sml_type.bv_val );
595 return LDAP_UNDEFINED_TYPE;
598 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
599 && slap_ad_is_binary( ad ))
601 /* attribute requires binary transfer */
602 snprintf( textbuf, textlen,
603 "%s: disallows ;binary transfer",
604 ml->sml_type.bv_val );
606 return LDAP_UNDEFINED_TYPE;
609 if( slap_ad_is_tag_range( ad )) {
610 /* attribute requires binary transfer */
611 snprintf( textbuf, textlen,
612 "%s: inappropriate use of tag range option",
613 ml->sml_type.bv_val );
615 return LDAP_UNDEFINED_TYPE;
618 if (!update && is_at_no_user_mod( ad->ad_type )) {
619 /* user modification disallowed */
620 snprintf( textbuf, textlen,
621 "%s: no user modification allowed",
622 ml->sml_type.bv_val );
624 return LDAP_CONSTRAINT_VIOLATION;
627 if ( is_at_obsolete( ad->ad_type ) &&
628 (( ml->sml_op != LDAP_MOD_REPLACE &&
629 ml->sml_op != LDAP_MOD_DELETE ) ||
630 ml->sml_values != NULL ))
633 * attribute is obsolete,
634 * only allow replace/delete with no values
636 snprintf( textbuf, textlen,
637 "%s: attribute is obsolete",
638 ml->sml_type.bv_val );
640 return LDAP_CONSTRAINT_VIOLATION;
643 if ( ml->sml_op == LDAP_MOD_INCREMENT &&
644 #ifdef SLAPD_REAL_SYNTAX
645 !is_at_syntax( ad->ad_type, SLAPD_REAL_SYNTAX ) &&
647 !is_at_syntax( ad->ad_type, SLAPD_INTEGER_SYNTAX ) )
650 * attribute values must be INTEGER or REAL
652 snprintf( textbuf, textlen,
653 "%s: attribute syntax inappropriate for increment",
654 ml->sml_type.bv_val );
656 return LDAP_CONSTRAINT_VIOLATION;
662 if( ml->sml_values != NULL ) {
664 slap_syntax_validate_func *validate =
665 ad->ad_type->sat_syntax->ssyn_validate;
666 slap_syntax_transform_func *pretty =
667 ad->ad_type->sat_syntax->ssyn_pretty;
669 if( !pretty && !validate ) {
670 *text = "no validator for syntax";
671 snprintf( textbuf, textlen,
672 "%s: no validator for syntax %s",
674 ad->ad_type->sat_syntax->ssyn_oid );
676 return LDAP_INVALID_SYNTAX;
680 * check that each value is valid per syntax
681 * and pretty if appropriate
683 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
686 rc = pretty( ad->ad_type->sat_syntax,
687 &ml->sml_values[nvals], &pval, ctx );
689 rc = validate( ad->ad_type->sat_syntax,
690 &ml->sml_values[nvals] );
694 snprintf( textbuf, textlen,
695 "%s: value #%ld invalid per syntax",
696 ml->sml_type.bv_val, (long) nvals );
698 return LDAP_INVALID_SYNTAX;
702 ber_memfree_x( ml->sml_values[nvals].bv_val, ctx );
703 ml->sml_values[nvals] = pval;
708 * a rough single value check... an additional check is needed
709 * to catch add of single value to existing single valued attribute
711 if ((ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE)
712 && nvals > 1 && is_at_single_value( ad->ad_type ))
714 snprintf( textbuf, textlen,
715 "%s: multiple values provided",
716 ml->sml_type.bv_val );
718 return LDAP_CONSTRAINT_VIOLATION;
721 /* if the type has a normalizer, generate the
722 * normalized values. otherwise leave them NULL.
724 * this is different from the rule for attributes
725 * in an entry - in an attribute list, the normalized
726 * value is set equal to the non-normalized value
727 * when there is no normalizer.
729 if( nvals && ad->ad_type->sat_equality &&
730 ad->ad_type->sat_equality->smr_normalize )
732 ml->sml_nvalues = ber_memalloc_x(
733 (nvals+1)*sizeof(struct berval), ctx );
735 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
736 rc = ad->ad_type->sat_equality->smr_normalize(
737 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
738 ad->ad_type->sat_syntax,
739 ad->ad_type->sat_equality,
740 &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
743 LDAP_LOG( OPERATION, DETAIL1,
744 "str2entry: NULL (ssyn_normalize %d)\n",
747 Debug( LDAP_DEBUG_ANY,
748 "<= str2entry NULL (ssyn_normalize %d)\n",
751 snprintf( textbuf, textlen,
752 "%s: value #%ld normalization failed",
753 ml->sml_type.bv_val, (long) nvals );
759 ml->sml_nvalues[nvals].bv_val = NULL;
760 ml->sml_nvalues[nvals].bv_len = 0;
768 int slap_mods_opattrs(
771 Modifications **modtail,
773 char *textbuf, size_t textlen )
775 struct berval name, timestamp, csn;
777 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
778 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
781 int mop = op->o_tag == LDAP_REQ_ADD
782 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
784 assert( modtail != NULL );
785 assert( *modtail == NULL );
787 if ( SLAP_LASTMOD( op->o_bd )) {
789 time_t now = slap_get_time();
791 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
792 ltm = gmtime( &now );
793 lutil_gentime( timebuf, sizeof(timebuf), ltm );
795 slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 );
797 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
799 timestamp.bv_val = timebuf;
800 timestamp.bv_len = strlen(timebuf);
802 if( op->o_dn.bv_len == 0 ) {
803 name.bv_val = SLAPD_ANONYMOUS;
804 name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
812 if( op->o_tag == LDAP_REQ_ADD ) {
813 struct berval tmpval;
815 if( global_schemacheck ) {
816 int rc = mods_structural_class( mods, &tmpval,
817 text, textbuf, textlen );
818 if( rc != LDAP_SUCCESS ) return rc;
820 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
822 mod->sml_type.bv_val = NULL;
823 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
825 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
826 ber_dupbv( &mod->sml_values[0], &tmpval );
827 mod->sml_values[1].bv_len = 0;
828 mod->sml_values[1].bv_val = NULL;
829 assert( mod->sml_values[0].bv_val );
831 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
832 ber_dupbv( &mod->sml_nvalues[0], &tmpval );
833 mod->sml_nvalues[1].bv_len = 0;
834 mod->sml_nvalues[1].bv_val = NULL;
835 assert( mod->sml_nvalues[0].bv_val );
837 modtail = &mod->sml_next;
840 if ( SLAP_LASTMOD( op->o_bd )) {
841 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
843 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
844 tmpval.bv_val = uuidbuf;
846 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
848 mod->sml_type.bv_val = NULL;
849 mod->sml_desc = slap_schema.si_ad_entryUUID;
851 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
852 ber_dupbv( &mod->sml_values[0], &tmpval );
853 mod->sml_values[1].bv_len = 0;
854 mod->sml_values[1].bv_val = NULL;
855 assert( mod->sml_values[0].bv_val );
856 mod->sml_nvalues = NULL;
858 modtail = &mod->sml_next;
860 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
862 mod->sml_type.bv_val = NULL;
863 mod->sml_desc = slap_schema.si_ad_creatorsName;
864 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
865 ber_dupbv( &mod->sml_values[0], &name );
866 mod->sml_values[1].bv_len = 0;
867 mod->sml_values[1].bv_val = NULL;
868 assert( mod->sml_values[0].bv_val );
870 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
871 ber_dupbv( &mod->sml_nvalues[0], &nname );
872 mod->sml_nvalues[1].bv_len = 0;
873 mod->sml_nvalues[1].bv_val = NULL;
874 assert( mod->sml_nvalues[0].bv_val );
876 modtail = &mod->sml_next;
878 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
880 mod->sml_type.bv_val = NULL;
881 mod->sml_desc = slap_schema.si_ad_createTimestamp;
882 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
883 ber_dupbv( &mod->sml_values[0], ×tamp );
884 mod->sml_values[1].bv_len = 0;
885 mod->sml_values[1].bv_val = NULL;
886 assert( mod->sml_values[0].bv_val );
887 mod->sml_nvalues = NULL;
889 modtail = &mod->sml_next;
893 if ( SLAP_LASTMOD( op->o_bd )) {
894 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
896 mod->sml_type.bv_val = NULL;
897 mod->sml_desc = slap_schema.si_ad_entryCSN;
898 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
899 ber_dupbv( &mod->sml_values[0], &csn );
900 mod->sml_values[1].bv_len = 0;
901 mod->sml_values[1].bv_val = NULL;
902 assert( mod->sml_values[0].bv_val );
903 mod->sml_nvalues = NULL;
905 modtail = &mod->sml_next;
907 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
909 mod->sml_type.bv_val = NULL;
910 mod->sml_desc = slap_schema.si_ad_modifiersName;
911 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
912 ber_dupbv( &mod->sml_values[0], &name );
913 mod->sml_values[1].bv_len = 0;
914 mod->sml_values[1].bv_val = NULL;
915 assert( mod->sml_values[0].bv_val );
917 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
918 ber_dupbv( &mod->sml_nvalues[0], &nname );
919 mod->sml_nvalues[1].bv_len = 0;
920 mod->sml_nvalues[1].bv_val = NULL;
921 assert( mod->sml_nvalues[0].bv_val );
923 modtail = &mod->sml_next;
925 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
927 mod->sml_type.bv_val = NULL;
928 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
929 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
930 ber_dupbv( &mod->sml_values[0], ×tamp );
931 mod->sml_values[1].bv_len = 0;
932 mod->sml_values[1].bv_val = NULL;
933 assert( mod->sml_values[0].bv_val );
934 mod->sml_nvalues = NULL;
936 modtail = &mod->sml_next;