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 );
448 for( modtail = &modlist;
450 modtail = &(*modtail)->sml_next )
455 rs->sr_err = slap_mods_opattrs( op, modlist, modtail,
456 &rs->sr_text, textbuf, textlen, 1 );
457 if( rs->sr_err != LDAP_SUCCESS ) {
458 send_ldap_result( op, rs );
463 op->orm_modlist = modlist;
464 #ifdef SLAPD_MULTIMASTER
468 /* but multimaster slapd logs only the ones
469 * not from a replicator user */
470 cb.sc_next = op->o_callback;
471 op->o_callback = &cb;
473 op->o_bd->be_modify( op, rs );
475 #ifndef SLAPD_MULTIMASTER
476 /* send a referral */
478 BerVarray defref = op->o_bd->be_update_refs
479 ? op->o_bd->be_update_refs : default_referral;
480 if ( defref != NULL ) {
481 rs->sr_ref = referral_rewrite( defref,
483 LDAP_SCOPE_DEFAULT );
484 if ( rs->sr_ref == NULL ) {
485 /* FIXME: must duplicate, because
486 * overlays may muck with it */
489 rs->sr_err = LDAP_REFERRAL;
490 send_ldap_result( op, rs );
491 if ( rs->sr_ref != defref ) {
492 ber_bvarray_free( rs->sr_ref );
496 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
497 "shadow context; no update referral" );
502 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
503 "operation not supported within namingContext" );
506 #if defined( LDAP_SLAPI )
507 if ( pb != NULL && slapi_int_call_plugins( op->o_bd,
508 SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 )
510 Debug(LDAP_DEBUG_TRACE,
511 "do_modify: modify postoperation plugins failed.\n", 0, 0, 0);
513 #endif /* defined( LDAP_SLAPI ) */
516 #if defined( LDAP_SLAPI )
517 if ( modv != NULL ) slapi_int_free_ldapmods( modv );
524 * Do non-update constraint checking.
527 slap_mods_no_update_check(
533 for ( ; ml != NULL; ml = ml->sml_next ) {
534 if ( is_at_no_user_mod( ml->sml_desc->ad_type ) ) {
535 /* user modification disallowed */
536 snprintf( textbuf, textlen,
537 "%s: no user modification allowed",
538 ml->sml_type.bv_val );
540 return LDAP_CONSTRAINT_VIOLATION;
548 * Do basic attribute type checking and syntax validation.
559 for( ; ml != NULL; ml = ml->sml_next ) {
560 AttributeDescription *ad = NULL;
562 /* convert to attribute description */
563 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
565 if( rc != LDAP_SUCCESS ) {
566 snprintf( textbuf, textlen, "%s: %s",
567 ml->sml_type.bv_val, *text );
574 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
575 && !slap_ad_is_binary( ad ))
577 /* attribute requires binary transfer */
578 snprintf( textbuf, textlen,
579 "%s: requires ;binary transfer",
580 ml->sml_type.bv_val );
582 return LDAP_UNDEFINED_TYPE;
585 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
586 && slap_ad_is_binary( ad ))
588 /* attribute does not require binary transfer */
589 snprintf( textbuf, textlen,
590 "%s: disallows ;binary transfer",
591 ml->sml_type.bv_val );
593 return LDAP_UNDEFINED_TYPE;
596 if( slap_ad_is_tag_range( ad )) {
597 /* attribute requires binary transfer */
598 snprintf( textbuf, textlen,
599 "%s: inappropriate use of tag range option",
600 ml->sml_type.bv_val );
602 return LDAP_UNDEFINED_TYPE;
606 /* moved to slap_mods_no_update_check() */
607 if (!update && is_at_no_user_mod( ad->ad_type )) {
608 /* user modification disallowed */
609 snprintf( textbuf, textlen,
610 "%s: no user modification allowed",
611 ml->sml_type.bv_val );
613 return LDAP_CONSTRAINT_VIOLATION;
617 if ( is_at_obsolete( ad->ad_type ) &&
618 (( ml->sml_op != LDAP_MOD_REPLACE &&
619 ml->sml_op != LDAP_MOD_DELETE ) ||
620 ml->sml_values != NULL ))
623 * attribute is obsolete,
624 * only allow replace/delete with no values
626 snprintf( textbuf, textlen,
627 "%s: attribute is obsolete",
628 ml->sml_type.bv_val );
630 return LDAP_CONSTRAINT_VIOLATION;
633 if ( ml->sml_op == LDAP_MOD_INCREMENT &&
634 #ifdef SLAPD_REAL_SYNTAX
635 !is_at_syntax( ad->ad_type, SLAPD_REAL_SYNTAX ) &&
637 !is_at_syntax( ad->ad_type, SLAPD_INTEGER_SYNTAX ) )
640 * attribute values must be INTEGER or REAL
642 snprintf( textbuf, textlen,
643 "%s: attribute syntax inappropriate for increment",
644 ml->sml_type.bv_val );
646 return LDAP_CONSTRAINT_VIOLATION;
652 if( ml->sml_values != NULL ) {
654 slap_syntax_validate_func *validate =
655 ad->ad_type->sat_syntax->ssyn_validate;
656 slap_syntax_transform_func *pretty =
657 ad->ad_type->sat_syntax->ssyn_pretty;
659 if( !pretty && !validate ) {
660 *text = "no validator for syntax";
661 snprintf( textbuf, textlen,
662 "%s: no validator for syntax %s",
664 ad->ad_type->sat_syntax->ssyn_oid );
666 return LDAP_INVALID_SYNTAX;
670 * check that each value is valid per syntax
671 * and pretty if appropriate
673 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
676 rc = pretty( ad->ad_type->sat_syntax,
677 &ml->sml_values[nvals], &pval, ctx );
679 rc = validate( ad->ad_type->sat_syntax,
680 &ml->sml_values[nvals] );
684 snprintf( textbuf, textlen,
685 "%s: value #%ld invalid per syntax",
686 ml->sml_type.bv_val, (long) nvals );
688 return LDAP_INVALID_SYNTAX;
692 ber_memfree_x( ml->sml_values[nvals].bv_val, ctx );
693 ml->sml_values[nvals] = pval;
698 * a rough single value check... an additional check is needed
699 * to catch add of single value to existing single valued attribute
701 if ((ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE)
702 && nvals > 1 && is_at_single_value( ad->ad_type ))
704 snprintf( textbuf, textlen,
705 "%s: multiple values provided",
706 ml->sml_type.bv_val );
708 return LDAP_CONSTRAINT_VIOLATION;
711 /* if the type has a normalizer, generate the
712 * normalized values. otherwise leave them NULL.
714 * this is different from the rule for attributes
715 * in an entry - in an attribute list, the normalized
716 * value is set equal to the non-normalized value
717 * when there is no normalizer.
719 if( nvals && ad->ad_type->sat_equality &&
720 ad->ad_type->sat_equality->smr_normalize )
722 ml->sml_nvalues = ber_memalloc_x(
723 (nvals+1)*sizeof(struct berval), ctx );
725 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
726 rc = ad->ad_type->sat_equality->smr_normalize(
727 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
728 ad->ad_type->sat_syntax,
729 ad->ad_type->sat_equality,
730 &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
732 Debug( LDAP_DEBUG_ANY,
733 "<= str2entry NULL (ssyn_normalize %d)\n",
735 snprintf( textbuf, textlen,
736 "%s: value #%ld normalization failed",
737 ml->sml_type.bv_val, (long) nvals );
743 ml->sml_nvalues[nvals].bv_val = NULL;
744 ml->sml_nvalues[nvals].bv_len = 0;
747 /* check for duplicates, but ignore Deletes.
749 if( nvals > 1 && ml->sml_op != LDAP_MOD_DELETE ) {
751 MatchingRule *mr = ad->ad_type->sat_equality;
753 for ( i = 1; i < nvals ; i++ ) {
754 /* test asserted values against themselves */
755 for( j = 0; j < i; j++ ) {
756 rc = ordered_value_match( &match, ml->sml_desc, mr,
758 | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX
759 | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
760 | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
762 ? &ml->sml_nvalues[i]
763 : &ml->sml_values[i],
765 ? &ml->sml_nvalues[j]
766 : &ml->sml_values[j],
768 if ( rc == LDAP_SUCCESS && match == 0 ) {
769 /* value exists already */
770 snprintf( textbuf, textlen,
771 "%s: value #%d provided more than once",
772 ml->sml_desc->ad_cname.bv_val, j );
774 return LDAP_TYPE_OR_VALUE_EXISTS;
776 } else if ( rc != LDAP_SUCCESS ) {
789 int slap_mods_opattrs(
792 Modifications **modtail,
794 char *textbuf, size_t textlen,
797 struct berval name, timestamp, csn;
799 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
800 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
803 int mop = op->o_tag == LDAP_REQ_ADD
804 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
806 assert( modtail != NULL );
807 assert( *modtail == NULL );
809 if ( SLAP_LASTMOD( op->o_bd )) {
814 time_t now = slap_get_time();
817 ltm = gmtime_r( &now, <m_buf );
819 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
820 ltm = gmtime( &now );
821 #endif /* HAVE_GMTIME_R */
822 lutil_gentime( timebuf, sizeof(timebuf), ltm );
824 slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, manage_ctxcsn );
826 #ifndef HAVE_GMTIME_R
827 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
830 timestamp.bv_val = timebuf;
831 timestamp.bv_len = strlen(timebuf);
833 if( op->o_dn.bv_len == 0 ) {
834 BER_BVSTR( &name, SLAPD_ANONYMOUS );
842 if( op->o_tag == LDAP_REQ_ADD ) {
843 struct berval tmpval;
845 if( global_schemacheck ) {
846 int rc = mods_structural_class( mods, &tmpval,
847 text, textbuf, textlen );
848 if( rc != LDAP_SUCCESS ) return rc;
850 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
852 mod->sml_type.bv_val = NULL;
853 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
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 );
861 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
862 ber_dupbv( &mod->sml_nvalues[0], &tmpval );
863 mod->sml_nvalues[1].bv_len = 0;
864 mod->sml_nvalues[1].bv_val = NULL;
865 assert( mod->sml_nvalues[0].bv_val );
867 modtail = &mod->sml_next;
870 if ( SLAP_LASTMOD( op->o_bd )) {
871 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
873 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
874 tmpval.bv_val = uuidbuf;
876 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
878 mod->sml_type.bv_val = NULL;
879 mod->sml_desc = slap_schema.si_ad_entryUUID;
881 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
882 ber_dupbv( &mod->sml_values[0], &tmpval );
883 mod->sml_values[1].bv_len = 0;
884 mod->sml_values[1].bv_val = NULL;
885 assert( mod->sml_values[0].bv_val );
887 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
888 (*mod->sml_desc->ad_type->sat_equality->smr_normalize)(
889 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
890 mod->sml_desc->ad_type->sat_syntax,
891 mod->sml_desc->ad_type->sat_equality,
892 mod->sml_values, mod->sml_nvalues, NULL );
893 mod->sml_nvalues[1].bv_len = 0;
894 mod->sml_nvalues[1].bv_val = NULL;
896 modtail = &mod->sml_next;
898 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
900 mod->sml_type.bv_val = NULL;
901 mod->sml_desc = slap_schema.si_ad_creatorsName;
903 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
904 ber_dupbv( &mod->sml_values[0], &name );
905 mod->sml_values[1].bv_len = 0;
906 mod->sml_values[1].bv_val = NULL;
907 assert( mod->sml_values[0].bv_val );
909 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
910 ber_dupbv( &mod->sml_nvalues[0], &nname );
911 mod->sml_nvalues[1].bv_len = 0;
912 mod->sml_nvalues[1].bv_val = NULL;
913 assert( mod->sml_nvalues[0].bv_val );
915 modtail = &mod->sml_next;
917 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
919 mod->sml_type.bv_val = NULL;
920 mod->sml_desc = slap_schema.si_ad_createTimestamp;
922 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
923 ber_dupbv( &mod->sml_values[0], ×tamp );
924 mod->sml_values[1].bv_len = 0;
925 mod->sml_values[1].bv_val = NULL;
926 assert( mod->sml_values[0].bv_val );
927 mod->sml_nvalues = NULL;
929 modtail = &mod->sml_next;
933 if ( SLAP_LASTMOD( op->o_bd )) {
934 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
936 mod->sml_type.bv_val = NULL;
937 mod->sml_desc = slap_schema.si_ad_entryCSN;
938 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
939 ber_dupbv( &mod->sml_values[0], &csn );
940 mod->sml_values[1].bv_len = 0;
941 mod->sml_values[1].bv_val = NULL;
942 assert( mod->sml_values[0].bv_val );
943 mod->sml_nvalues = NULL;
945 modtail = &mod->sml_next;
947 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
949 mod->sml_type.bv_val = NULL;
950 mod->sml_desc = slap_schema.si_ad_modifiersName;
951 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
952 ber_dupbv( &mod->sml_values[0], &name );
953 mod->sml_values[1].bv_len = 0;
954 mod->sml_values[1].bv_val = NULL;
955 assert( mod->sml_values[0].bv_val );
957 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
958 ber_dupbv( &mod->sml_nvalues[0], &nname );
959 mod->sml_nvalues[1].bv_len = 0;
960 mod->sml_nvalues[1].bv_val = NULL;
961 assert( mod->sml_nvalues[0].bv_val );
963 modtail = &mod->sml_next;
965 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
967 mod->sml_type.bv_val = NULL;
968 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
969 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
970 ber_dupbv( &mod->sml_values[0], ×tamp );
971 mod->sml_values[1].bv_len = 0;
972 mod->sml_values[1].bv_val = NULL;
973 assert( mod->sml_values[0].bv_val );
974 mod->sml_nvalues = NULL;
976 modtail = &mod->sml_next;