2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2005 The OpenLDAP Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted only as authorized by the OpenLDAP
11 * A copy of this license is available in the file LICENSE in the
12 * top-level directory of the distribution or, alternatively, at
13 * <http://www.OpenLDAP.org/license.html>.
15 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
16 * All rights reserved.
18 * Redistribution and use in source and binary forms are permitted
19 * provided that this notice is preserved and that due credit is given
20 * to the University of Michigan at Ann Arbor. The name of the University
21 * may not be used to endorse or promote products derived from this
22 * software without specific prior written permission. This software
23 * is provided ``as is'' without express or implied warranty.
30 #include <ac/socket.h>
31 #include <ac/string.h>
36 #include "slapi/slapi.h"
46 struct berval dn = BER_BVNULL;
50 Modifications *modlist = NULL;
51 Modifications **modtail = &modlist;
53 char textbuf[ SLAP_TEXT_BUFLEN ];
54 size_t textlen = sizeof( textbuf );
56 Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
59 * Parse the modify request. It looks like this:
61 * ModifyRequest := [APPLICATION 6] SEQUENCE {
62 * name DistinguishedName,
63 * mods SEQUENCE OF SEQUENCE {
64 * operation ENUMERATED {
69 * modification SEQUENCE {
71 * values SET OF AttributeValue
77 if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) {
78 Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 );
80 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
81 return SLAPD_DISCONNECT;
84 Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
86 /* collect modifications & save for later */
87 for ( tag = ber_first_element( op->o_ber, &len, &last );
89 tag = ber_next_element( op->o_ber, &len, last ) )
92 Modifications tmp, *mod;
94 tmp.sml_nvalues = NULL;
96 if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
97 &tmp.sml_type, &tmp.sml_values ) == LBER_ERROR )
99 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR,
100 "decoding modlist error" );
101 rs->sr_err = SLAPD_DISCONNECT;
105 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
107 mod->sml_type = tmp.sml_type;
108 mod->sml_values = tmp.sml_values;
109 mod->sml_nvalues = NULL;
110 mod->sml_desc = NULL;
111 mod->sml_next = NULL;
116 if ( mod->sml_values == NULL ) {
117 Debug( LDAP_DEBUG_ANY,
118 "do_modify: modify/add operation (%ld) requires values\n",
121 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
122 "modify/add operation requires values" );
128 case LDAP_MOD_DELETE:
129 case LDAP_MOD_REPLACE:
132 case LDAP_MOD_INCREMENT:
133 if( op->o_protocol >= LDAP_VERSION3 ) {
135 if ( mod->sml_values == NULL ) {
136 Debug( LDAP_DEBUG_ANY, "do_modify: "
137 "modify/increment operation (%ld) requires value\n",
140 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
141 "modify/increment operation requires value" );
145 if( mod->sml_values[1].bv_val ) {
146 Debug( LDAP_DEBUG_ANY, "do_modify: modify/increment "
147 "operation (%ld) requires single value\n",
150 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
151 "modify/increment operation requires single value" );
160 Debug( LDAP_DEBUG_ANY,
161 "do_modify: unrecognized modify operation (%ld)\n",
164 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
165 "unrecognized modify operation" );
170 modtail = &mod->sml_next;
174 if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
175 Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
180 rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
182 if( rs->sr_err != LDAP_SUCCESS ) {
183 Debug( LDAP_DEBUG_ANY,
184 "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 );
185 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
189 rs->sr_err = slap_mods_check( modlist, &rs->sr_text,
190 textbuf, textlen, NULL );
192 if ( rs->sr_err != LDAP_SUCCESS ) {
193 send_ldap_result( op, rs );
197 /* FIXME: needs review */
198 op->orm_modlist = modlist;
199 op->orm_increment = increment;
201 op->o_bd = frontendDB;
202 rs->sr_err = frontendDB->be_modify( op, rs );
205 slap_graduate_commit_csn( op );
207 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
208 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
209 if ( op->orm_modlist != NULL ) slap_mods_free( op->orm_modlist );
215 fe_op_modify( Operation *op, SlapReply *rs )
221 Modifications *modlist = op->orm_modlist;
222 Modifications **modtail = &modlist;
224 LDAPMod **modv = NULL;
226 int increment = op->orm_increment;
230 if( op->o_req_ndn.bv_len == 0 ) {
231 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
233 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
234 "modify upon the root DSE not supported" );
237 } else if ( bvmatch( &op->o_req_ndn, &frontendDB->be_schemandn ) ) {
238 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
240 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
241 "modification of subschema subentry not supported" );
246 Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
248 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
249 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
250 tmp->sml_op == LDAP_MOD_ADD ? "add" :
251 (tmp->sml_op == LDAP_MOD_INCREMENT ? "increment" :
252 (tmp->sml_op == LDAP_MOD_DELETE ? "delete" :
253 "replace")), tmp->sml_type.bv_val, 0 );
255 if ( tmp->sml_values == NULL ) {
256 Debug( LDAP_DEBUG_ARGS, "%s\n",
257 "\t\tno values", NULL, NULL );
258 } else if ( tmp->sml_values[0].bv_val == NULL ) {
259 Debug( LDAP_DEBUG_ARGS, "%s\n",
260 "\t\tzero values", NULL, NULL );
261 } else if ( tmp->sml_values[1].bv_val == NULL ) {
262 Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
263 "\t\tone value", (long) tmp->sml_values[0].bv_len, NULL );
265 Debug( LDAP_DEBUG_ARGS, "%s\n",
266 "\t\tmultiple values", NULL, NULL );
270 if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
271 char abuf[BUFSIZ/2], *ptr = abuf;
274 Statslog( LDAP_DEBUG_STATS, "%s MOD dn=\"%s\"\n",
275 op->o_log_prefix, op->o_req_dn.bv_val, 0, 0, 0 );
277 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
278 if (len + 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
279 Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n",
280 op->o_log_prefix, abuf, 0, 0, 0 );
285 if( 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
286 Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n",
287 op->o_log_prefix, tmp->sml_type.bv_val, 0, 0, 0 );
295 ptr = lutil_strcopy(ptr, tmp->sml_type.bv_val);
296 len += tmp->sml_type.bv_len;
299 Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n",
300 op->o_log_prefix, abuf, 0, 0, 0 );
303 #endif /* LDAP_DEBUG */
305 manageDSAit = get_manageDSAit( op );
308 * We could be serving multiple database backends. Select the
309 * appropriate one, or send a referral to our "referral server"
310 * if we don't hold it.
312 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 1 );
313 if ( op->o_bd == NULL ) {
314 rs->sr_ref = referral_rewrite( default_referral,
315 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
316 if (!rs->sr_ref) rs->sr_ref = default_referral;
318 if (rs->sr_ref != NULL ) {
319 rs->sr_err = LDAP_REFERRAL;
320 op->o_bd = frontendDB;
321 send_ldap_result( op, rs );
324 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
326 op->o_bd = frontendDB;
327 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
328 "no global superior knowledge" );
334 /* If we've got a glued backend, check the real backend */
336 if ( SLAP_GLUE_INSTANCE( op->o_bd )) {
337 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 );
340 /* check restrictions */
341 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
342 send_ldap_result( op, rs );
346 /* check for referrals */
347 if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
351 /* check for modify/increment support */
352 if( increment && !SLAP_INCREMENT( op->o_bd ) ) {
353 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
354 "modify/increment not supported in context" );
357 #if defined( LDAP_SLAPI )
360 slapi_int_pblock_set_operation( pb, op );
361 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)op->o_req_dn.bv_val );
362 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
363 modv = slapi_int_modifications2ldapmods( &modlist );
364 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
366 rs->sr_err = slapi_int_call_plugins( op->o_bd,
367 SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
370 * It's possible that the preoperation plugin changed the
371 * modification array, so we need to convert it back to
372 * a Modification list.
374 * Calling slapi_int_modifications2ldapmods() destroyed modlist so
375 * we don't need to free it.
377 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
378 modlist = slapi_int_ldapmods2modifications( modv );
380 if ( rs->sr_err < 0 ) {
382 * A preoperation plugin failure will abort the
385 Debug(LDAP_DEBUG_TRACE,
386 "do_modify: modify preoperation plugin failed.\n",
388 if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE,
389 (void *)&rs->sr_err ) != 0 ) || rs->sr_err == LDAP_SUCCESS )
391 rs->sr_err = LDAP_OTHER;
393 slapi_int_free_ldapmods( modv );
400 * NB: it is valid for the plugin to return no modifications
401 * (for example, a plugin might store some attributes elsewhere
402 * and remove them from the modification list; if only those
403 * attribute types were included in the modification request,
404 * then slapi_int_ldapmods2modifications() above will return
407 * However, the post-operation plugin should still be
410 #endif /* defined( LDAP_SLAPI ) */
413 * do the modify if 1 && (2 || 3)
414 * 1) there is a modify function implemented in this backend;
415 * 2) this backend is master for what it holds;
416 * 3) it's a replica and the dn supplied is the update_ndn.
418 if ( op->o_bd->be_modify ) {
419 /* do the update here */
420 int repl_user = be_isupdate( op );
422 /* Multimaster slapd does not have to check for replicator dn
423 * because it accepts each modify request
425 #ifndef SLAPD_MULTIMASTER
426 if ( !SLAP_SHADOW(op->o_bd) || repl_user )
429 int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
430 char textbuf[ SLAP_TEXT_BUFLEN ];
431 size_t textlen = sizeof( textbuf );
432 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
437 rs->sr_err = slap_mods_no_update_check( modlist,
438 &rs->sr_text, textbuf, textlen );
439 if ( rs->sr_err != LDAP_SUCCESS ) {
440 send_ldap_result( op, rs );
446 for( modtail = &modlist;
448 modtail = &(*modtail)->sml_next )
453 rs->sr_err = slap_mods_opattrs( op, modlist, modtail,
454 &rs->sr_text, textbuf, textlen, 1 );
455 if( rs->sr_err != LDAP_SUCCESS ) {
456 send_ldap_result( op, rs );
461 op->orm_modlist = modlist;
462 #ifdef SLAPD_MULTIMASTER
466 /* but multimaster slapd logs only the ones
467 * not from a replicator user */
468 cb.sc_next = op->o_callback;
469 op->o_callback = &cb;
471 op->o_bd->be_modify( op, rs );
473 #ifndef SLAPD_MULTIMASTER
474 /* send a referral */
476 BerVarray defref = op->o_bd->be_update_refs
477 ? op->o_bd->be_update_refs : default_referral;
478 if ( defref != NULL ) {
479 rs->sr_ref = referral_rewrite( defref,
481 LDAP_SCOPE_DEFAULT );
482 if ( rs->sr_ref == NULL ) {
483 /* FIXME: must duplicate, because
484 * overlays may muck with it */
487 rs->sr_err = LDAP_REFERRAL;
488 send_ldap_result( op, rs );
489 if ( rs->sr_ref != defref ) {
490 ber_bvarray_free( rs->sr_ref );
494 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
495 "shadow context; no update referral" );
500 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
501 "operation not supported within namingContext" );
504 #if defined( LDAP_SLAPI )
505 if ( pb != NULL && slapi_int_call_plugins( op->o_bd,
506 SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 )
508 Debug(LDAP_DEBUG_TRACE,
509 "do_modify: modify postoperation plugins failed.\n", 0, 0, 0);
511 #endif /* defined( LDAP_SLAPI ) */
514 #if defined( LDAP_SLAPI )
515 if ( modv != NULL ) slapi_int_free_ldapmods( modv );
522 * Do non-update constraint checking.
525 slap_mods_no_update_check(
531 for ( ; ml != NULL; ml = ml->sml_next ) {
532 if ( is_at_no_user_mod( ml->sml_desc->ad_type ) ) {
533 /* user modification disallowed */
534 snprintf( textbuf, textlen,
535 "%s: no user modification allowed",
536 ml->sml_type.bv_val );
538 return LDAP_CONSTRAINT_VIOLATION;
546 * Do basic attribute type checking and syntax validation.
557 for( ; ml != NULL; ml = ml->sml_next ) {
558 AttributeDescription *ad = NULL;
560 /* convert to attribute description */
561 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
563 if( rc != LDAP_SUCCESS ) {
564 snprintf( textbuf, textlen, "%s: %s",
565 ml->sml_type.bv_val, *text );
572 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
573 && !slap_ad_is_binary( ad ))
575 /* attribute requires binary transfer */
576 snprintf( textbuf, textlen,
577 "%s: requires ;binary transfer",
578 ml->sml_type.bv_val );
580 return LDAP_UNDEFINED_TYPE;
583 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
584 && slap_ad_is_binary( ad ))
586 /* attribute does not require binary transfer */
587 snprintf( textbuf, textlen,
588 "%s: disallows ;binary transfer",
589 ml->sml_type.bv_val );
591 return LDAP_UNDEFINED_TYPE;
594 if( slap_ad_is_tag_range( ad )) {
595 /* attribute requires binary transfer */
596 snprintf( textbuf, textlen,
597 "%s: inappropriate use of tag range option",
598 ml->sml_type.bv_val );
600 return LDAP_UNDEFINED_TYPE;
604 /* moved to slap_mods_no_update_check() */
605 if (!update && is_at_no_user_mod( ad->ad_type )) {
606 /* user modification disallowed */
607 snprintf( textbuf, textlen,
608 "%s: no user modification allowed",
609 ml->sml_type.bv_val );
611 return LDAP_CONSTRAINT_VIOLATION;
615 if ( is_at_obsolete( ad->ad_type ) &&
616 (( ml->sml_op != LDAP_MOD_REPLACE &&
617 ml->sml_op != LDAP_MOD_DELETE ) ||
618 ml->sml_values != NULL ))
621 * attribute is obsolete,
622 * only allow replace/delete with no values
624 snprintf( textbuf, textlen,
625 "%s: attribute is obsolete",
626 ml->sml_type.bv_val );
628 return LDAP_CONSTRAINT_VIOLATION;
631 if ( ml->sml_op == LDAP_MOD_INCREMENT &&
632 #ifdef SLAPD_REAL_SYNTAX
633 !is_at_syntax( ad->ad_type, SLAPD_REAL_SYNTAX ) &&
635 !is_at_syntax( ad->ad_type, SLAPD_INTEGER_SYNTAX ) )
638 * attribute values must be INTEGER or REAL
640 snprintf( textbuf, textlen,
641 "%s: attribute syntax inappropriate for increment",
642 ml->sml_type.bv_val );
644 return LDAP_CONSTRAINT_VIOLATION;
650 if( ml->sml_values != NULL ) {
652 slap_syntax_validate_func *validate =
653 ad->ad_type->sat_syntax->ssyn_validate;
654 slap_syntax_transform_func *pretty =
655 ad->ad_type->sat_syntax->ssyn_pretty;
657 if( !pretty && !validate ) {
658 *text = "no validator for syntax";
659 snprintf( textbuf, textlen,
660 "%s: no validator for syntax %s",
662 ad->ad_type->sat_syntax->ssyn_oid );
664 return LDAP_INVALID_SYNTAX;
668 * check that each value is valid per syntax
669 * and pretty if appropriate
671 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
674 rc = pretty( ad->ad_type->sat_syntax,
675 &ml->sml_values[nvals], &pval, ctx );
677 rc = validate( ad->ad_type->sat_syntax,
678 &ml->sml_values[nvals] );
682 snprintf( textbuf, textlen,
683 "%s: value #%ld invalid per syntax",
684 ml->sml_type.bv_val, (long) nvals );
686 return LDAP_INVALID_SYNTAX;
690 ber_memfree_x( ml->sml_values[nvals].bv_val, ctx );
691 ml->sml_values[nvals] = pval;
696 * a rough single value check... an additional check is needed
697 * to catch add of single value to existing single valued attribute
699 if ((ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE)
700 && nvals > 1 && is_at_single_value( ad->ad_type ))
702 snprintf( textbuf, textlen,
703 "%s: multiple values provided",
704 ml->sml_type.bv_val );
706 return LDAP_CONSTRAINT_VIOLATION;
709 /* if the type has a normalizer, generate the
710 * normalized values. otherwise leave them NULL.
712 * this is different from the rule for attributes
713 * in an entry - in an attribute list, the normalized
714 * value is set equal to the non-normalized value
715 * when there is no normalizer.
717 if( nvals && ad->ad_type->sat_equality &&
718 ad->ad_type->sat_equality->smr_normalize )
720 ml->sml_nvalues = ber_memalloc_x(
721 (nvals+1)*sizeof(struct berval), ctx );
723 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
724 rc = ad->ad_type->sat_equality->smr_normalize(
725 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
726 ad->ad_type->sat_syntax,
727 ad->ad_type->sat_equality,
728 &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
730 Debug( LDAP_DEBUG_ANY,
731 "<= str2entry NULL (ssyn_normalize %d)\n",
733 snprintf( textbuf, textlen,
734 "%s: value #%ld normalization failed",
735 ml->sml_type.bv_val, (long) nvals );
741 ml->sml_nvalues[nvals].bv_val = NULL;
742 ml->sml_nvalues[nvals].bv_len = 0;
745 /* check for duplicates, but ignore Deletes.
747 if( nvals > 1 && ml->sml_op != LDAP_MOD_DELETE ) {
749 MatchingRule *mr = ad->ad_type->sat_equality;
751 for ( i = 1; i < nvals ; i++ ) {
752 /* test asserted values against themselves */
753 for( j = 0; j < i; j++ ) {
754 rc = ordered_value_match( &match, ml->sml_desc, mr,
756 | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX
757 | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
758 | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
760 ? &ml->sml_nvalues[i]
761 : &ml->sml_values[i],
763 ? &ml->sml_nvalues[j]
764 : &ml->sml_values[j],
766 if ( rc == LDAP_SUCCESS && match == 0 ) {
767 /* value exists already */
768 snprintf( textbuf, textlen,
769 "%s: value #%d provided more than once",
770 ml->sml_desc->ad_cname.bv_val, j );
772 return LDAP_TYPE_OR_VALUE_EXISTS;
774 } else if ( rc != LDAP_SUCCESS ) {
787 int slap_mods_opattrs(
790 Modifications **modtail,
792 char *textbuf, size_t textlen,
795 struct berval name, timestamp, csn;
797 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
798 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
801 int mop = op->o_tag == LDAP_REQ_ADD
802 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
804 assert( modtail != NULL );
805 assert( *modtail == NULL );
807 if ( SLAP_LASTMOD( op->o_bd )) {
812 time_t now = slap_get_time();
815 ltm = gmtime_r( &now, <m_buf );
817 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
818 ltm = gmtime( &now );
819 #endif /* HAVE_GMTIME_R */
820 lutil_gentime( timebuf, sizeof(timebuf), ltm );
822 slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, manage_ctxcsn );
824 #ifndef HAVE_GMTIME_R
825 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
828 timestamp.bv_val = timebuf;
829 timestamp.bv_len = strlen(timebuf);
831 if( op->o_dn.bv_len == 0 ) {
832 BER_BVSTR( &name, SLAPD_ANONYMOUS );
840 if( op->o_tag == LDAP_REQ_ADD ) {
841 struct berval tmpval;
844 int rc = mods_structural_class( mods, &tmpval,
845 text, textbuf, textlen );
846 if( rc != LDAP_SUCCESS ) return rc;
848 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
850 mod->sml_type.bv_val = NULL;
851 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
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 ber_dupbv( &mod->sml_nvalues[0], &tmpval );
861 mod->sml_nvalues[1].bv_len = 0;
862 mod->sml_nvalues[1].bv_val = NULL;
863 assert( mod->sml_nvalues[0].bv_val );
865 modtail = &mod->sml_next;
868 if ( SLAP_LASTMOD( op->o_bd )) {
869 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
871 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
872 tmpval.bv_val = uuidbuf;
874 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
876 mod->sml_type.bv_val = NULL;
877 mod->sml_desc = slap_schema.si_ad_entryUUID;
879 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
880 ber_dupbv( &mod->sml_values[0], &tmpval );
881 mod->sml_values[1].bv_len = 0;
882 mod->sml_values[1].bv_val = NULL;
883 assert( mod->sml_values[0].bv_val );
885 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
886 (*mod->sml_desc->ad_type->sat_equality->smr_normalize)(
887 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
888 mod->sml_desc->ad_type->sat_syntax,
889 mod->sml_desc->ad_type->sat_equality,
890 mod->sml_values, mod->sml_nvalues, NULL );
891 mod->sml_nvalues[1].bv_len = 0;
892 mod->sml_nvalues[1].bv_val = NULL;
894 modtail = &mod->sml_next;
896 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
898 mod->sml_type.bv_val = NULL;
899 mod->sml_desc = slap_schema.si_ad_creatorsName;
901 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
902 ber_dupbv( &mod->sml_values[0], &name );
903 mod->sml_values[1].bv_len = 0;
904 mod->sml_values[1].bv_val = NULL;
905 assert( mod->sml_values[0].bv_val );
907 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
908 ber_dupbv( &mod->sml_nvalues[0], &nname );
909 mod->sml_nvalues[1].bv_len = 0;
910 mod->sml_nvalues[1].bv_val = NULL;
911 assert( mod->sml_nvalues[0].bv_val );
913 modtail = &mod->sml_next;
915 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
917 mod->sml_type.bv_val = NULL;
918 mod->sml_desc = slap_schema.si_ad_createTimestamp;
920 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
921 ber_dupbv( &mod->sml_values[0], ×tamp );
922 mod->sml_values[1].bv_len = 0;
923 mod->sml_values[1].bv_val = NULL;
924 assert( mod->sml_values[0].bv_val );
925 mod->sml_nvalues = NULL;
927 modtail = &mod->sml_next;
931 if ( SLAP_LASTMOD( op->o_bd )) {
932 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
934 mod->sml_type.bv_val = NULL;
935 mod->sml_desc = slap_schema.si_ad_entryCSN;
936 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
937 ber_dupbv( &mod->sml_values[0], &csn );
938 mod->sml_values[1].bv_len = 0;
939 mod->sml_values[1].bv_val = NULL;
940 assert( mod->sml_values[0].bv_val );
941 mod->sml_nvalues = NULL;
943 modtail = &mod->sml_next;
945 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
947 mod->sml_type.bv_val = NULL;
948 mod->sml_desc = slap_schema.si_ad_modifiersName;
949 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
950 ber_dupbv( &mod->sml_values[0], &name );
951 mod->sml_values[1].bv_len = 0;
952 mod->sml_values[1].bv_val = NULL;
953 assert( mod->sml_values[0].bv_val );
955 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
956 ber_dupbv( &mod->sml_nvalues[0], &nname );
957 mod->sml_nvalues[1].bv_len = 0;
958 mod->sml_nvalues[1].bv_val = NULL;
959 assert( mod->sml_nvalues[0].bv_val );
961 modtail = &mod->sml_next;
963 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
965 mod->sml_type.bv_val = NULL;
966 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
967 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
968 ber_dupbv( &mod->sml_values[0], ×tamp );
969 mod->sml_values[1].bv_len = 0;
970 mod->sml_values[1].bv_val = NULL;
971 assert( mod->sml_values[0].bv_val );
972 mod->sml_nvalues = NULL;
974 modtail = &mod->sml_next;