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 ( LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo ) &&
459 ( !op->o_bd->be_update_ndn.bv_len || repl_user ))
461 if ( LDAP_STAILQ_EMPTY( &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 ( !LDAP_STAILQ_EMPTY( &op->o_bd->be_syncinfo )) {
508 LDAP_STAILQ_FOREACH( si, &op->o_bd->be_syncinfo, si_next ) {
510 ber_dupbv( &tmpbv, &si->si_provideruri_bv[0] );
511 ber_bvarray_add( &defref, &tmpbv );
514 defref = op->o_bd->be_update_refs
515 ? op->o_bd->be_update_refs : default_referral;
517 if ( defref != NULL ) {
518 rs->sr_ref = referral_rewrite( defref,
520 LDAP_SCOPE_DEFAULT );
521 if (!rs->sr_ref) rs->sr_ref = defref;
522 rs->sr_err = LDAP_REFERRAL;
523 send_ldap_result( op, rs );
524 if (rs->sr_ref != defref) {
525 ber_bvarray_free( rs->sr_ref );
528 send_ldap_error( op, rs,
529 LDAP_UNWILLING_TO_PERFORM,
530 "referral missing" );
535 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
536 "operation not supported within namingContext" );
539 #if defined( LDAP_SLAPI )
540 } /* modlist != NULL */
542 if ( pb && doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) {
544 LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins "
545 "failed\n", 0, 0, 0 );
547 Debug(LDAP_DEBUG_TRACE, "do_modify: modify postoperation plugins "
548 "failed.\n", 0, 0, 0);
551 #endif /* defined( LDAP_SLAPI ) */
555 slap_graduate_commit_csn( op );
557 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
558 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
559 if ( modlist != NULL ) slap_mods_free( modlist );
560 #if defined( LDAP_SLAPI )
561 if ( modv != NULL ) slapi_x_free_ldapmods( modv );
567 * Do basic attribute type checking and syntax validation.
579 for( ; ml != NULL; ml = ml->sml_next ) {
580 AttributeDescription *ad = NULL;
582 /* convert to attribute description */
583 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
585 if( rc != LDAP_SUCCESS ) {
586 snprintf( textbuf, textlen, "%s: %s",
587 ml->sml_type.bv_val, *text );
594 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
595 && !slap_ad_is_binary( ad ))
597 /* attribute requires binary transfer */
598 snprintf( textbuf, textlen,
599 "%s: requires ;binary transfer",
600 ml->sml_type.bv_val );
602 return LDAP_UNDEFINED_TYPE;
605 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
606 && slap_ad_is_binary( ad ))
608 /* attribute requires binary transfer */
609 snprintf( textbuf, textlen,
610 "%s: disallows ;binary transfer",
611 ml->sml_type.bv_val );
613 return LDAP_UNDEFINED_TYPE;
616 if( slap_ad_is_tag_range( ad )) {
617 /* attribute requires binary transfer */
618 snprintf( textbuf, textlen,
619 "%s: inappropriate use of tag range option",
620 ml->sml_type.bv_val );
622 return LDAP_UNDEFINED_TYPE;
625 if (!update && is_at_no_user_mod( ad->ad_type )) {
626 /* user modification disallowed */
627 snprintf( textbuf, textlen,
628 "%s: no user modification allowed",
629 ml->sml_type.bv_val );
631 return LDAP_CONSTRAINT_VIOLATION;
634 if ( is_at_obsolete( ad->ad_type ) &&
635 (( ml->sml_op != LDAP_MOD_REPLACE &&
636 ml->sml_op != LDAP_MOD_DELETE ) ||
637 ml->sml_values != NULL ))
640 * attribute is obsolete,
641 * only allow replace/delete with no values
643 snprintf( textbuf, textlen,
644 "%s: attribute is obsolete",
645 ml->sml_type.bv_val );
647 return LDAP_CONSTRAINT_VIOLATION;
650 if ( ml->sml_op == LDAP_MOD_INCREMENT &&
651 #ifdef SLAPD_REAL_SYNTAX
652 !is_at_syntax( ad->ad_type, SLAPD_REAL_SYNTAX ) &&
654 !is_at_syntax( ad->ad_type, SLAPD_INTEGER_SYNTAX ) )
657 * attribute values must be INTEGER or REAL
659 snprintf( textbuf, textlen,
660 "%s: attribute syntax inappropriate for increment",
661 ml->sml_type.bv_val );
663 return LDAP_CONSTRAINT_VIOLATION;
669 if( ml->sml_values != NULL ) {
671 slap_syntax_validate_func *validate =
672 ad->ad_type->sat_syntax->ssyn_validate;
673 slap_syntax_transform_func *pretty =
674 ad->ad_type->sat_syntax->ssyn_pretty;
676 if( !pretty && !validate ) {
677 *text = "no validator for syntax";
678 snprintf( textbuf, textlen,
679 "%s: no validator for syntax %s",
681 ad->ad_type->sat_syntax->ssyn_oid );
683 return LDAP_INVALID_SYNTAX;
687 * check that each value is valid per syntax
688 * and pretty if appropriate
690 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
693 rc = pretty( ad->ad_type->sat_syntax,
694 &ml->sml_values[nvals], &pval, ctx );
696 rc = validate( ad->ad_type->sat_syntax,
697 &ml->sml_values[nvals] );
701 snprintf( textbuf, textlen,
702 "%s: value #%ld invalid per syntax",
703 ml->sml_type.bv_val, (long) nvals );
705 return LDAP_INVALID_SYNTAX;
709 ber_memfree_x( ml->sml_values[nvals].bv_val, ctx );
710 ml->sml_values[nvals] = pval;
715 * a rough single value check... an additional check is needed
716 * to catch add of single value to existing single valued attribute
718 if ((ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE)
719 && nvals > 1 && is_at_single_value( ad->ad_type ))
721 snprintf( textbuf, textlen,
722 "%s: multiple values provided",
723 ml->sml_type.bv_val );
725 return LDAP_CONSTRAINT_VIOLATION;
728 /* if the type has a normalizer, generate the
729 * normalized values. otherwise leave them NULL.
731 * this is different from the rule for attributes
732 * in an entry - in an attribute list, the normalized
733 * value is set equal to the non-normalized value
734 * when there is no normalizer.
736 if( nvals && ad->ad_type->sat_equality &&
737 ad->ad_type->sat_equality->smr_normalize )
739 ml->sml_nvalues = ber_memalloc_x(
740 (nvals+1)*sizeof(struct berval), ctx );
742 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
743 rc = ad->ad_type->sat_equality->smr_normalize(
744 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
745 ad->ad_type->sat_syntax,
746 ad->ad_type->sat_equality,
747 &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
750 LDAP_LOG( OPERATION, DETAIL1,
751 "str2entry: NULL (ssyn_normalize %d)\n",
754 Debug( LDAP_DEBUG_ANY,
755 "<= str2entry NULL (ssyn_normalize %d)\n",
758 snprintf( textbuf, textlen,
759 "%s: value #%ld normalization failed",
760 ml->sml_type.bv_val, (long) nvals );
766 ml->sml_nvalues[nvals].bv_val = NULL;
767 ml->sml_nvalues[nvals].bv_len = 0;
775 int slap_mods_opattrs(
778 Modifications **modtail,
780 char *textbuf, size_t textlen )
782 struct berval name, timestamp, csn;
784 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
785 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
788 int mop = op->o_tag == LDAP_REQ_ADD
789 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
791 assert( modtail != NULL );
792 assert( *modtail == NULL );
794 if ( SLAP_LASTMOD( op->o_bd )) {
796 time_t now = slap_get_time();
798 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
799 ltm = gmtime( &now );
800 lutil_gentime( timebuf, sizeof(timebuf), ltm );
802 slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 );
804 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
806 timestamp.bv_val = timebuf;
807 timestamp.bv_len = strlen(timebuf);
809 if( op->o_dn.bv_len == 0 ) {
810 name.bv_val = SLAPD_ANONYMOUS;
811 name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
819 if( op->o_tag == LDAP_REQ_ADD ) {
820 struct berval tmpval;
822 if( global_schemacheck ) {
823 int rc = mods_structural_class( mods, &tmpval,
824 text, textbuf, textlen );
825 if( rc != LDAP_SUCCESS ) return rc;
827 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
829 mod->sml_type.bv_val = NULL;
830 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
832 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
833 ber_dupbv( &mod->sml_values[0], &tmpval );
834 mod->sml_values[1].bv_len = 0;
835 mod->sml_values[1].bv_val = NULL;
836 assert( mod->sml_values[0].bv_val );
838 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
839 ber_dupbv( &mod->sml_nvalues[0], &tmpval );
840 mod->sml_nvalues[1].bv_len = 0;
841 mod->sml_nvalues[1].bv_val = NULL;
842 assert( mod->sml_nvalues[0].bv_val );
844 modtail = &mod->sml_next;
847 if ( SLAP_LASTMOD( op->o_bd )) {
848 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
850 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
851 tmpval.bv_val = uuidbuf;
853 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
855 mod->sml_type.bv_val = NULL;
856 mod->sml_desc = slap_schema.si_ad_entryUUID;
858 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
859 ber_dupbv( &mod->sml_values[0], &tmpval );
860 mod->sml_values[1].bv_len = 0;
861 mod->sml_values[1].bv_val = NULL;
862 assert( mod->sml_values[0].bv_val );
864 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
865 (*mod->sml_desc->ad_type->sat_equality->smr_normalize)(
866 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
867 mod->sml_desc->ad_type->sat_syntax,
868 mod->sml_desc->ad_type->sat_equality,
869 mod->sml_values, mod->sml_nvalues, NULL );
870 mod->sml_nvalues[1].bv_len = 0;
871 mod->sml_nvalues[1].bv_val = NULL;
873 modtail = &mod->sml_next;
875 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
877 mod->sml_type.bv_val = NULL;
878 mod->sml_desc = slap_schema.si_ad_creatorsName;
880 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
881 ber_dupbv( &mod->sml_values[0], &name );
882 mod->sml_values[1].bv_len = 0;
883 mod->sml_values[1].bv_val = NULL;
884 assert( mod->sml_values[0].bv_val );
886 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
887 ber_dupbv( &mod->sml_nvalues[0], &nname );
888 mod->sml_nvalues[1].bv_len = 0;
889 mod->sml_nvalues[1].bv_val = NULL;
890 assert( mod->sml_nvalues[0].bv_val );
892 modtail = &mod->sml_next;
894 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
896 mod->sml_type.bv_val = NULL;
897 mod->sml_desc = slap_schema.si_ad_createTimestamp;
899 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
900 ber_dupbv( &mod->sml_values[0], ×tamp );
901 mod->sml_values[1].bv_len = 0;
902 mod->sml_values[1].bv_val = NULL;
903 assert( mod->sml_values[0].bv_val );
904 mod->sml_nvalues = NULL;
906 modtail = &mod->sml_next;
910 if ( SLAP_LASTMOD( op->o_bd )) {
911 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
913 mod->sml_type.bv_val = NULL;
914 mod->sml_desc = slap_schema.si_ad_entryCSN;
915 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
916 ber_dupbv( &mod->sml_values[0], &csn );
917 mod->sml_values[1].bv_len = 0;
918 mod->sml_values[1].bv_val = NULL;
919 assert( mod->sml_values[0].bv_val );
920 mod->sml_nvalues = NULL;
922 modtail = &mod->sml_next;
924 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
926 mod->sml_type.bv_val = NULL;
927 mod->sml_desc = slap_schema.si_ad_modifiersName;
928 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
929 ber_dupbv( &mod->sml_values[0], &name );
930 mod->sml_values[1].bv_len = 0;
931 mod->sml_values[1].bv_val = NULL;
932 assert( mod->sml_values[0].bv_val );
934 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
935 ber_dupbv( &mod->sml_nvalues[0], &nname );
936 mod->sml_nvalues[1].bv_len = 0;
937 mod->sml_nvalues[1].bv_val = NULL;
938 assert( mod->sml_nvalues[0].bv_val );
940 modtail = &mod->sml_next;
942 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
944 mod->sml_type.bv_val = NULL;
945 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
946 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
947 ber_dupbv( &mod->sml_values[0], ×tamp );
948 mod->sml_values[1].bv_len = 0;
949 mod->sml_values[1].bv_val = NULL;
950 assert( mod->sml_values[0].bv_val );
951 mod->sml_nvalues = NULL;
953 modtail = &mod->sml_next;