2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1998-2004 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>
37 #include "slapi/slapi.h"
47 struct berval dn = BER_BVNULL;
51 Modifications *modlist = NULL;
52 Modifications **modtail = &modlist;
57 LDAPMod **modv = NULL;
63 LDAP_LOG( OPERATION, ENTRY, "do_modify: enter\n", 0, 0, 0 );
65 Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
69 * Parse the modify request. It looks like this:
71 * ModifyRequest := [APPLICATION 6] SEQUENCE {
72 * name DistinguishedName,
73 * mods SEQUENCE OF SEQUENCE {
74 * operation ENUMERATED {
79 * modification SEQUENCE {
81 * values SET OF AttributeValue
87 if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) {
89 LDAP_LOG( OPERATION, ERR, "do_modify: ber_scanf failed\n", 0, 0, 0 );
91 Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 );
94 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
95 return SLAPD_DISCONNECT;
99 LDAP_LOG( OPERATION, ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
101 Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
104 /* collect modifications & save for later */
105 for ( tag = ber_first_element( op->o_ber, &len, &last );
107 tag = ber_next_element( op->o_ber, &len, last ) )
110 Modifications tmp, *mod;
112 tmp.sml_nvalues = NULL;
114 if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
115 &tmp.sml_type, &tmp.sml_values )
118 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR,
119 "decoding modlist error" );
120 rs->sr_err = SLAPD_DISCONNECT;
124 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
126 mod->sml_type = tmp.sml_type;
127 mod->sml_values = tmp.sml_values;
128 mod->sml_nvalues = NULL;
129 mod->sml_desc = NULL;
130 mod->sml_next = NULL;
135 if ( mod->sml_values == NULL ) {
137 LDAP_LOG( OPERATION, ERR,
138 "do_modify: modify/add operation (%ld) requires values\n",
141 Debug( LDAP_DEBUG_ANY,
142 "do_modify: modify/add operation (%ld) requires values\n",
146 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
147 "modify/add operation requires values" );
153 case LDAP_MOD_DELETE:
154 case LDAP_MOD_REPLACE:
157 case LDAP_MOD_INCREMENT:
158 if( op->o_protocol >= LDAP_VERSION3 ) {
160 if ( mod->sml_values == NULL ) {
162 LDAP_LOG( OPERATION, ERR, "do_modify: "
163 "modify/increment operation (%ld) requires value\n",
166 Debug( LDAP_DEBUG_ANY, "do_modify: "
167 "modify/increment operation (%ld) requires value\n",
171 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
172 "modify/increment operation requires value" );
176 if( mod->sml_values[1].bv_val ) {
178 LDAP_LOG( OPERATION, ERR, "do_modify: modify/increment "
179 "operation (%ld) requires single value\n",
182 Debug( LDAP_DEBUG_ANY, "do_modify: modify/increment "
183 "operation (%ld) requires single value\n",
187 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
188 "modify/increment operation requires single value" );
198 LDAP_LOG( OPERATION, ERR,
199 "do_modify: unrecognized modify operation (%ld)\n",
202 Debug( LDAP_DEBUG_ANY,
203 "do_modify: unrecognized modify operation (%ld)\n",
207 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
208 "unrecognized modify operation" );
213 modtail = &mod->sml_next;
217 if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
219 LDAP_LOG( OPERATION, ERR, "do_modify: get_ctrls failed\n", 0, 0, 0 );
221 Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
227 rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
229 if( rs->sr_err != LDAP_SUCCESS ) {
231 LDAP_LOG( OPERATION, INFO, "do_modify: conn %d invalid dn (%s)\n",
232 op->o_connid, dn.bv_val, 0 );
234 Debug( LDAP_DEBUG_ANY,
235 "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 );
237 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
241 if( op->o_req_ndn.bv_len == 0 ) {
243 LDAP_LOG( OPERATION, ERR,
244 "do_modify: attempt to modify root DSE.\n",0, 0, 0 );
246 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
249 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
250 "modify upon the root DSE not supported" );
253 } else if ( bvmatch( &op->o_req_ndn, &global_schemandn ) ) {
255 LDAP_LOG( OPERATION, ERR,
256 "do_modify: attempt to modify subschema subentry.\n" , 0, 0, 0 );
258 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
261 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
262 "modification of subschema subentry not supported" );
268 LDAP_LOG( OPERATION, DETAIL1, "do_modify: modifications:\n", 0, 0, 0 );
270 Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
273 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
275 LDAP_LOG( OPERATION, DETAIL1, "\t%s: %s\n",
276 tmp->sml_op == LDAP_MOD_ADD ? "add" :
277 (tmp->sml_op == LDAP_MOD_INCREMENT ? "increment" :
278 (tmp->sml_op == LDAP_MOD_DELETE ? "delete" :
279 "replace")), tmp->sml_type.bv_val, 0 );
281 if ( tmp->sml_values == NULL ) {
282 LDAP_LOG( OPERATION, DETAIL1, "\t\tno values", 0, 0, 0 );
283 } else if ( tmp->sml_values[0].bv_val == NULL ) {
284 LDAP_LOG( OPERATION, DETAIL1, "\t\tzero values", 0, 0, 0 );
285 } else if ( tmp->sml_values[1].bv_val == NULL ) {
286 LDAP_LOG( OPERATION, DETAIL1, "\t\tone value", 0, 0, 0 );
288 LDAP_LOG( OPERATION, DETAIL1, "\t\tmultiple values", 0, 0, 0 );
292 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
293 tmp->sml_op == LDAP_MOD_ADD ? "add" :
294 (tmp->sml_op == LDAP_MOD_INCREMENT ? "increment" :
295 (tmp->sml_op == LDAP_MOD_DELETE ? "delete" :
296 "replace")), tmp->sml_type.bv_val, 0 );
298 if ( tmp->sml_values == NULL ) {
299 Debug( LDAP_DEBUG_ARGS, "%s\n",
300 "\t\tno values", NULL, NULL );
301 } else if ( tmp->sml_values[0].bv_val == NULL ) {
302 Debug( LDAP_DEBUG_ARGS, "%s\n",
303 "\t\tzero values", NULL, NULL );
304 } else if ( tmp->sml_values[1].bv_val == NULL ) {
305 Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
306 "\t\tone value", (long) tmp->sml_values[0].bv_len, NULL );
308 Debug( LDAP_DEBUG_ARGS, "%s\n",
309 "\t\tmultiple values", NULL, NULL );
314 if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
315 char abuf[BUFSIZ/2], *ptr = abuf;
318 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD dn=\"%s\"\n",
319 op->o_connid, op->o_opid, dn.bv_val, 0, 0 );
321 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
322 if (len + 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, abuf, 0, 0 );
329 if( 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
330 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
331 op->o_connid, op->o_opid, tmp->sml_type.bv_val, 0, 0 );
339 ptr = lutil_strcopy(ptr, tmp->sml_type.bv_val);
340 len += tmp->sml_type.bv_len;
343 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
344 op->o_connid, op->o_opid, abuf, 0, 0 );
347 #endif /* LDAP_DEBUG */
349 manageDSAit = get_manageDSAit( op );
352 * We could be serving multiple database backends. Select the
353 * appropriate one, or send a referral to our "referral server"
354 * if we don't hold it.
356 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 );
357 if ( op->o_bd == NULL ) {
358 rs->sr_ref = referral_rewrite( default_referral,
359 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
360 if (!rs->sr_ref) rs->sr_ref = default_referral;
362 if (rs->sr_ref != NULL ) {
363 rs->sr_err = LDAP_REFERRAL;
364 send_ldap_result( op, rs );
366 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
368 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
369 "no global superior knowledge" );
374 /* check restrictions */
375 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
376 send_ldap_result( op, rs );
380 /* check for referrals */
381 if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
385 /* check for modify/increment support */
386 if( increment && !SLAP_INCREMENT( op->o_bd ) ) {
387 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
388 "modify/increment not supported in context" );
391 #if defined( LDAP_SLAPI )
394 slapi_int_pblock_set_operation( pb, op );
395 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
396 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
397 modv = slapi_int_modifications2ldapmods( &modlist );
398 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
400 rs->sr_err = slapi_int_call_plugins( op->o_bd,
401 SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
402 if ( rs->sr_err < 0 ) {
404 * A preoperation plugin failure will abort the
408 LDAP_LOG( OPERATION, INFO,
409 "do_modify: modify preoperation plugin failed\n",
412 Debug(LDAP_DEBUG_TRACE,
413 "do_modify: modify preoperation plugin failed.\n",
416 if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE,
417 (void *)&rs->sr_err ) != 0 ) || rs->sr_err == LDAP_SUCCESS )
419 rs->sr_err = LDAP_OTHER;
421 slapi_int_free_ldapmods( modv );
427 * It's possible that the preoperation plugin changed the
428 * modification array, so we need to convert it back to
429 * a Modification list.
431 * Calling slapi_int_modifications2ldapmods() destroyed modlist so
432 * we don't need to free it.
434 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
435 modlist = slapi_int_ldapmods2modifications( modv );
439 * NB: it is valid for the plugin to return no modifications
440 * (for example, a plugin might store some attributes elsewhere
441 * and remove them from the modification list; if only those
442 * attribute types were included in the modification request,
443 * then slapi_int_ldapmods2modifications() above will return
446 * However, the post-operation plugin should still be
449 if ( modlist == NULL ) {
450 rs->sr_err = LDAP_SUCCESS;
451 send_ldap_result( op, rs );
453 #endif /* defined( LDAP_SLAPI ) */
456 * do the modify if 1 && (2 || 3)
457 * 1) there is a modify function implemented in this backend;
458 * 2) this backend is master for what it holds;
459 * 3) it's a replica and the dn supplied is the update_ndn.
461 if ( op->o_bd->be_modify ) {
462 /* do the update here */
463 int repl_user = be_isupdate( op );
465 /* Multimaster slapd does not have to check for replicator dn
466 * because it accepts each modify request
468 #ifndef SLAPD_MULTIMASTER
469 if ( !SLAP_SHADOW(op->o_bd) || repl_user )
472 int update = op->o_bd->be_update_ndn.bv_len;
473 char textbuf[SLAP_TEXT_BUFLEN];
474 size_t textlen = sizeof textbuf;
475 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
477 rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
478 textbuf, textlen, NULL );
480 if( rs->sr_err != LDAP_SUCCESS ) {
481 send_ldap_result( op, rs );
486 for( modtail = &modlist;
488 modtail = &(*modtail)->sml_next )
493 rs->sr_err = slap_mods_opattrs( op, modlist, modtail,
494 &rs->sr_text, textbuf, textlen );
495 if( rs->sr_err != LDAP_SUCCESS ) {
496 send_ldap_result( op, rs );
501 op->orm_modlist = modlist;
502 #ifdef SLAPD_MULTIMASTER
506 /* but we log only the ones not from a replicator user */
507 cb.sc_next = op->o_callback;
508 op->o_callback = &cb;
510 op->o_bd->be_modify( op, rs );
512 #ifndef SLAPD_MULTIMASTER
513 /* send a referral */
515 BerVarray defref = op->o_bd->be_update_refs
516 ? 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, LDAP_UNWILLING_TO_PERFORM,
529 "shadow context; no update referral" );
534 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
535 "operation not supported within namingContext" );
538 #if defined( LDAP_SLAPI )
539 } /* modlist != NULL */
541 if ( pb != NULL && slapi_int_call_plugins( op->o_bd,
542 SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 )
545 LDAP_LOG( OPERATION, INFO,
546 "do_modify: modify postoperation plugins failed\n", 0, 0, 0 );
548 Debug(LDAP_DEBUG_TRACE,
549 "do_modify: modify postoperation plugins failed.\n", 0, 0, 0);
552 #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_int_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 )) {
799 time_t now = slap_get_time();
802 ltm = gmtime_r( &now, <m_buf );
804 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
805 ltm = gmtime( &now );
806 #endif /* HAVE_GMTIME_R */
807 lutil_gentime( timebuf, sizeof(timebuf), ltm );
809 slap_get_csn( op, csnbuf, sizeof(csnbuf), &csn, 1 );
811 #ifndef HAVE_GMTIME_R
812 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
815 timestamp.bv_val = timebuf;
816 timestamp.bv_len = strlen(timebuf);
818 if( op->o_dn.bv_len == 0 ) {
819 name.bv_val = SLAPD_ANONYMOUS;
820 name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
828 if( op->o_tag == LDAP_REQ_ADD ) {
829 struct berval tmpval;
831 if( global_schemacheck ) {
832 int rc = mods_structural_class( mods, &tmpval,
833 text, textbuf, textlen );
834 if( rc != LDAP_SUCCESS ) return rc;
836 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
838 mod->sml_type.bv_val = NULL;
839 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
841 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
842 ber_dupbv( &mod->sml_values[0], &tmpval );
843 mod->sml_values[1].bv_len = 0;
844 mod->sml_values[1].bv_val = NULL;
845 assert( mod->sml_values[0].bv_val );
847 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
848 ber_dupbv( &mod->sml_nvalues[0], &tmpval );
849 mod->sml_nvalues[1].bv_len = 0;
850 mod->sml_nvalues[1].bv_val = NULL;
851 assert( mod->sml_nvalues[0].bv_val );
853 modtail = &mod->sml_next;
856 if ( SLAP_LASTMOD( op->o_bd )) {
857 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
859 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
860 tmpval.bv_val = uuidbuf;
862 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
864 mod->sml_type.bv_val = NULL;
865 mod->sml_desc = slap_schema.si_ad_entryUUID;
867 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
868 ber_dupbv( &mod->sml_values[0], &tmpval );
869 mod->sml_values[1].bv_len = 0;
870 mod->sml_values[1].bv_val = NULL;
871 assert( mod->sml_values[0].bv_val );
873 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
874 (*mod->sml_desc->ad_type->sat_equality->smr_normalize)(
875 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
876 mod->sml_desc->ad_type->sat_syntax,
877 mod->sml_desc->ad_type->sat_equality,
878 mod->sml_values, mod->sml_nvalues, NULL );
879 mod->sml_nvalues[1].bv_len = 0;
880 mod->sml_nvalues[1].bv_val = NULL;
882 modtail = &mod->sml_next;
884 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
886 mod->sml_type.bv_val = NULL;
887 mod->sml_desc = slap_schema.si_ad_creatorsName;
889 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
890 ber_dupbv( &mod->sml_values[0], &name );
891 mod->sml_values[1].bv_len = 0;
892 mod->sml_values[1].bv_val = NULL;
893 assert( mod->sml_values[0].bv_val );
895 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
896 ber_dupbv( &mod->sml_nvalues[0], &nname );
897 mod->sml_nvalues[1].bv_len = 0;
898 mod->sml_nvalues[1].bv_val = NULL;
899 assert( mod->sml_nvalues[0].bv_val );
901 modtail = &mod->sml_next;
903 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
905 mod->sml_type.bv_val = NULL;
906 mod->sml_desc = slap_schema.si_ad_createTimestamp;
908 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
909 ber_dupbv( &mod->sml_values[0], ×tamp );
910 mod->sml_values[1].bv_len = 0;
911 mod->sml_values[1].bv_val = NULL;
912 assert( mod->sml_values[0].bv_val );
913 mod->sml_nvalues = NULL;
915 modtail = &mod->sml_next;
919 if ( SLAP_LASTMOD( op->o_bd )) {
920 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
922 mod->sml_type.bv_val = NULL;
923 mod->sml_desc = slap_schema.si_ad_entryCSN;
924 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
925 ber_dupbv( &mod->sml_values[0], &csn );
926 mod->sml_values[1].bv_len = 0;
927 mod->sml_values[1].bv_val = NULL;
928 assert( mod->sml_values[0].bv_val );
929 mod->sml_nvalues = NULL;
931 modtail = &mod->sml_next;
933 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
935 mod->sml_type.bv_val = NULL;
936 mod->sml_desc = slap_schema.si_ad_modifiersName;
937 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
938 ber_dupbv( &mod->sml_values[0], &name );
939 mod->sml_values[1].bv_len = 0;
940 mod->sml_values[1].bv_val = NULL;
941 assert( mod->sml_values[0].bv_val );
943 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
944 ber_dupbv( &mod->sml_nvalues[0], &nname );
945 mod->sml_nvalues[1].bv_len = 0;
946 mod->sml_nvalues[1].bv_val = NULL;
947 assert( mod->sml_nvalues[0].bv_val );
949 modtail = &mod->sml_next;
951 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
953 mod->sml_type.bv_val = NULL;
954 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
955 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
956 ber_dupbv( &mod->sml_values[0], ×tamp );
957 mod->sml_values[1].bv_len = 0;
958 mod->sml_values[1].bv_val = NULL;
959 assert( mod->sml_values[0].bv_val );
960 mod->sml_nvalues = NULL;
962 modtail = &mod->sml_next;