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>
43 struct berval dn = BER_BVNULL;
47 Modifications *modlist = NULL;
48 Modifications **modtail = &modlist;
50 char textbuf[ SLAP_TEXT_BUFLEN ];
51 size_t textlen = sizeof( textbuf );
53 Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
56 * Parse the modify request. It looks like this:
58 * ModifyRequest := [APPLICATION 6] SEQUENCE {
59 * name DistinguishedName,
60 * mods SEQUENCE OF SEQUENCE {
61 * operation ENUMERATED {
66 * modification SEQUENCE {
68 * values SET OF AttributeValue
74 if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) {
75 Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 );
77 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
78 return SLAPD_DISCONNECT;
81 Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
83 /* collect modifications & save for later */
84 for ( tag = ber_first_element( op->o_ber, &len, &last );
86 tag = ber_next_element( op->o_ber, &len, last ) )
89 Modifications tmp, *mod;
91 tmp.sml_nvalues = NULL;
93 if ( ber_scanf( op->o_ber, "{e{m[W]}}", &mop,
94 &tmp.sml_type, &tmp.sml_values ) == LBER_ERROR )
96 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR,
97 "decoding modlist error" );
98 rs->sr_err = SLAPD_DISCONNECT;
102 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
105 mod->sml_type = tmp.sml_type;
106 mod->sml_values = tmp.sml_values;
107 mod->sml_nvalues = NULL;
108 mod->sml_desc = NULL;
109 mod->sml_next = NULL;
114 if ( mod->sml_values == NULL ) {
115 Debug( LDAP_DEBUG_ANY,
116 "do_modify: modify/add operation (%ld) requires values\n",
119 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
120 "modify/add operation requires values" );
126 case LDAP_MOD_DELETE:
127 case LDAP_MOD_REPLACE:
130 case LDAP_MOD_INCREMENT:
131 if( op->o_protocol >= LDAP_VERSION3 ) {
133 if ( mod->sml_values == NULL ) {
134 Debug( LDAP_DEBUG_ANY, "do_modify: "
135 "modify/increment operation (%ld) requires value\n",
138 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
139 "modify/increment operation requires value" );
143 if ( !BER_BVISNULL( &mod->sml_values[ 1 ] ) ) {
144 Debug( LDAP_DEBUG_ANY, "do_modify: modify/increment "
145 "operation (%ld) requires single value\n",
148 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
149 "modify/increment operation requires single value" );
158 Debug( LDAP_DEBUG_ANY,
159 "do_modify: unrecognized modify operation (%ld)\n",
162 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
163 "unrecognized modify operation" );
168 modtail = &mod->sml_next;
172 if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
173 Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
178 rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
180 if( rs->sr_err != LDAP_SUCCESS ) {
181 Debug( LDAP_DEBUG_ANY,
182 "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 );
183 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
187 rs->sr_err = slap_mods_check( modlist,
188 &rs->sr_text, textbuf, textlen, NULL );
190 if ( rs->sr_err != LDAP_SUCCESS ) {
191 send_ldap_result( op, rs );
195 /* FIXME: needs review */
196 op->orm_modlist = modlist;
197 op->orm_increment = increment;
199 op->o_bd = frontendDB;
200 rs->sr_err = frontendDB->be_modify( op, rs );
203 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
204 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
205 if ( op->orm_modlist != NULL ) slap_mods_free( op->orm_modlist, 1 );
211 fe_op_modify( Operation *op, SlapReply *rs )
217 Modifications *modlist = op->orm_modlist;
218 Modifications **modtail = &modlist;
219 int increment = op->orm_increment;
221 char textbuf[ SLAP_TEXT_BUFLEN ];
222 size_t textlen = sizeof( textbuf );
224 if( op->o_req_ndn.bv_len == 0 ) {
225 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
227 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
228 "modify upon the root DSE not supported" );
231 } else if ( bvmatch( &op->o_req_ndn, &frontendDB->be_schemandn ) ) {
232 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
234 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
235 "modification of subschema subentry not supported" );
240 Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
242 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
243 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
244 tmp->sml_op == LDAP_MOD_ADD ? "add" :
245 (tmp->sml_op == LDAP_MOD_INCREMENT ? "increment" :
246 (tmp->sml_op == LDAP_MOD_DELETE ? "delete" :
247 "replace")), tmp->sml_type.bv_val, 0 );
249 if ( tmp->sml_values == NULL ) {
250 Debug( LDAP_DEBUG_ARGS, "%s\n",
251 "\t\tno values", NULL, NULL );
252 } else if ( BER_BVISNULL( &tmp->sml_values[ 0 ] ) ) {
253 Debug( LDAP_DEBUG_ARGS, "%s\n",
254 "\t\tzero values", NULL, NULL );
255 } else if ( BER_BVISNULL( &tmp->sml_values[ 1 ] ) ) {
256 Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
257 "\t\tone value", (long) tmp->sml_values[0].bv_len, NULL );
259 Debug( LDAP_DEBUG_ARGS, "%s\n",
260 "\t\tmultiple values", NULL, NULL );
264 if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
265 char abuf[BUFSIZ/2], *ptr = abuf;
268 Statslog( LDAP_DEBUG_STATS, "%s MOD dn=\"%s\"\n",
269 op->o_log_prefix, op->o_req_dn.bv_val, 0, 0, 0 );
271 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
272 if (len + 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
273 Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n",
274 op->o_log_prefix, abuf, 0, 0, 0 );
279 if( 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
280 Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n",
281 op->o_log_prefix, tmp->sml_type.bv_val, 0, 0, 0 );
289 ptr = lutil_strcopy(ptr, tmp->sml_type.bv_val);
290 len += tmp->sml_type.bv_len;
293 Statslog( LDAP_DEBUG_STATS, "%s MOD attr=%s\n",
294 op->o_log_prefix, abuf, 0, 0, 0 );
297 #endif /* LDAP_DEBUG */
299 manageDSAit = get_manageDSAit( op );
302 * We could be serving multiple database backends. Select the
303 * appropriate one, or send a referral to our "referral server"
304 * if we don't hold it.
306 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 1 );
307 if ( op->o_bd == NULL ) {
308 rs->sr_ref = referral_rewrite( default_referral,
309 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
310 if (!rs->sr_ref) rs->sr_ref = default_referral;
312 if (rs->sr_ref != NULL ) {
313 rs->sr_err = LDAP_REFERRAL;
314 op->o_bd = frontendDB;
315 send_ldap_result( op, rs );
318 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
320 op->o_bd = frontendDB;
321 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
322 "no global superior knowledge" );
328 /* If we've got a glued backend, check the real backend */
330 if ( SLAP_GLUE_INSTANCE( op->o_bd )) {
331 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 );
334 /* check restrictions */
335 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
336 send_ldap_result( op, rs );
340 /* check for referrals */
341 if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
345 rs->sr_err = slap_mods_obsolete_check( op, modlist,
346 &rs->sr_text, textbuf, textlen );
347 if ( rs->sr_err != LDAP_SUCCESS ) {
348 send_ldap_result( op, rs );
352 /* check for modify/increment support */
353 if( increment && !SLAP_INCREMENT( op->o_bd ) ) {
354 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
355 "modify/increment not supported in context" );
359 * do the modify if 1 && (2 || 3)
360 * 1) there is a modify function implemented in this backend;
361 * 2) this backend is master for what it holds;
362 * 3) it's a replica and the dn supplied is the update_ndn.
364 if ( op->o_bd->be_modify ) {
365 /* do the update here */
366 int repl_user = be_isupdate( op );
368 /* Multimaster slapd does not have to check for replicator dn
369 * because it accepts each modify request
371 #ifndef SLAPD_MULTIMASTER
372 if ( !SLAP_SHADOW(op->o_bd) || repl_user )
375 int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
376 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
381 rs->sr_err = slap_mods_no_user_mod_check( op, modlist,
382 &rs->sr_text, textbuf, textlen );
383 if ( rs->sr_err != LDAP_SUCCESS ) {
384 send_ldap_result( op, rs );
389 op->orm_modlist = modlist;
390 #ifdef SLAPD_MULTIMASTER
394 /* but multimaster slapd logs only the ones
395 * not from a replicator user */
396 cb.sc_next = op->o_callback;
397 op->o_callback = &cb;
399 op->o_bd->be_modify( op, rs );
401 #ifndef SLAPD_MULTIMASTER
402 /* send a referral */
404 BerVarray defref = op->o_bd->be_update_refs
405 ? op->o_bd->be_update_refs : default_referral;
406 if ( defref != NULL ) {
407 rs->sr_ref = referral_rewrite( defref,
409 LDAP_SCOPE_DEFAULT );
410 if ( rs->sr_ref == NULL ) {
411 /* FIXME: must duplicate, because
412 * overlays may muck with it */
415 rs->sr_err = LDAP_REFERRAL;
416 send_ldap_result( op, rs );
417 if ( rs->sr_ref != defref ) {
418 ber_bvarray_free( rs->sr_ref );
422 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
423 "shadow context; no update referral" );
428 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
429 "operation not supported within namingContext" );
437 * Obsolete constraint checking.
440 slap_mods_obsolete_check(
447 if( get_manageDIT( op ) ) return LDAP_SUCCESS;
449 for ( ; ml != NULL; ml = ml->sml_next ) {
450 if ( is_at_obsolete( ml->sml_desc->ad_type ) &&
451 (( ml->sml_op != LDAP_MOD_REPLACE &&
452 ml->sml_op != LDAP_MOD_DELETE ) ||
453 ml->sml_values != NULL ))
456 * attribute is obsolete,
457 * only allow replace/delete with no values
459 snprintf( textbuf, textlen,
460 "%s: attribute is obsolete",
461 ml->sml_type.bv_val );
463 return LDAP_CONSTRAINT_VIOLATION;
471 * No-user-modification constraint checking.
474 slap_mods_no_user_mod_check(
481 for ( ; ml != NULL; ml = ml->sml_next ) {
482 if ( !is_at_no_user_mod( ml->sml_desc->ad_type ) ) continue;
484 if ( get_manageDIT( op ) ) {
485 if ( ml->sml_desc->ad_type->sat_flags & SLAP_AT_MANAGEABLE ) {
486 ml->sml_flags |= SLAP_MOD_MANAGING;
490 /* attribute not manageable */
491 snprintf( textbuf, textlen,
492 "%s: no-user-modification attribute not manageable",
493 ml->sml_type.bv_val );
496 /* user modification disallowed */
497 snprintf( textbuf, textlen,
498 "%s: no user modification allowed",
499 ml->sml_type.bv_val );
503 return LDAP_CONSTRAINT_VIOLATION;
510 slap_mods_no_repl_user_mod_check(
520 for ( mods = ml; mods != NULL; mods = mods->sml_next ) {
521 assert( mods->sml_op == LDAP_MOD_ADD );
523 /* check doesn't already appear */
524 for ( modp = ml; modp != NULL; modp = modp->sml_next ) {
525 if ( mods->sml_desc == modp->sml_desc && mods != modp ) {
526 snprintf( textbuf, textlen,
527 "attribute '%s' provided more than once",
528 mods->sml_desc->ad_cname.bv_val );
529 return LDAP_TYPE_OR_VALUE_EXISTS;
538 * Do basic attribute type checking and syntax validation.
549 for( ; ml != NULL; ml = ml->sml_next ) {
550 AttributeDescription *ad = NULL;
552 /* convert to attribute description */
553 if ( ml->sml_desc == NULL ) {
554 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
555 if( rc != LDAP_SUCCESS ) {
556 snprintf( textbuf, textlen, "%s: %s",
557 ml->sml_type.bv_val, *text );
565 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
566 && !slap_ad_is_binary( ad ))
568 /* attribute requires binary transfer */
569 snprintf( textbuf, textlen,
570 "%s: requires ;binary transfer",
571 ml->sml_type.bv_val );
573 return LDAP_UNDEFINED_TYPE;
576 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
577 && slap_ad_is_binary( ad ))
579 /* attribute does not require binary transfer */
580 snprintf( textbuf, textlen,
581 "%s: disallows ;binary transfer",
582 ml->sml_type.bv_val );
584 return LDAP_UNDEFINED_TYPE;
587 if( slap_ad_is_tag_range( ad )) {
588 /* attribute requires binary transfer */
589 snprintf( textbuf, textlen,
590 "%s: inappropriate use of tag range option",
591 ml->sml_type.bv_val );
593 return LDAP_UNDEFINED_TYPE;
597 if ( is_at_obsolete( ad->ad_type ) &&
598 (( ml->sml_op != LDAP_MOD_REPLACE &&
599 ml->sml_op != LDAP_MOD_DELETE ) ||
600 ml->sml_values != NULL ))
603 * attribute is obsolete,
604 * only allow replace/delete with no values
606 snprintf( textbuf, textlen,
607 "%s: attribute is obsolete",
608 ml->sml_type.bv_val );
610 return LDAP_CONSTRAINT_VIOLATION;
614 if ( ml->sml_op == LDAP_MOD_INCREMENT &&
615 #ifdef SLAPD_REAL_SYNTAX
616 !is_at_syntax( ad->ad_type, SLAPD_REAL_SYNTAX ) &&
618 !is_at_syntax( ad->ad_type, SLAPD_INTEGER_SYNTAX ) )
621 * attribute values must be INTEGER or REAL
623 snprintf( textbuf, textlen,
624 "%s: attribute syntax inappropriate for increment",
625 ml->sml_type.bv_val );
627 return LDAP_CONSTRAINT_VIOLATION;
633 if( ml->sml_values != NULL ) {
635 slap_syntax_validate_func *validate =
636 ad->ad_type->sat_syntax->ssyn_validate;
637 slap_syntax_transform_func *pretty =
638 ad->ad_type->sat_syntax->ssyn_pretty;
640 if( !pretty && !validate ) {
641 *text = "no validator for syntax";
642 snprintf( textbuf, textlen,
643 "%s: no validator for syntax %s",
645 ad->ad_type->sat_syntax->ssyn_oid );
647 return LDAP_INVALID_SYNTAX;
651 * check that each value is valid per syntax
652 * and pretty if appropriate
654 for ( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
658 #ifdef SLAP_ORDERED_PRETTYNORM
659 rc = ordered_value_pretty( ad,
660 &ml->sml_values[nvals], &pval, ctx );
661 #else /* ! SLAP_ORDERED_PRETTYNORM */
662 rc = pretty( ad->ad_type->sat_syntax,
663 &ml->sml_values[nvals], &pval, ctx );
664 #endif /* ! SLAP_ORDERED_PRETTYNORM */
666 #ifdef SLAP_ORDERED_PRETTYNORM
667 rc = ordered_value_validate( ad,
668 &ml->sml_values[nvals] );
669 #else /* ! SLAP_ORDERED_PRETTYNORM */
670 rc = validate( ad->ad_type->sat_syntax,
671 &ml->sml_values[nvals] );
672 #endif /* ! SLAP_ORDERED_PRETTYNORM */
676 snprintf( textbuf, textlen,
677 "%s: value #%ld invalid per syntax",
678 ml->sml_type.bv_val, (long) nvals );
680 return LDAP_INVALID_SYNTAX;
684 ber_memfree_x( ml->sml_values[nvals].bv_val, ctx );
685 ml->sml_values[nvals] = pval;
690 * a rough single value check... an additional check is needed
691 * to catch add of single value to existing single valued attribute
693 if ((ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE)
694 && nvals > 1 && is_at_single_value( ad->ad_type ))
696 snprintf( textbuf, textlen,
697 "%s: multiple values provided",
698 ml->sml_type.bv_val );
700 return LDAP_CONSTRAINT_VIOLATION;
703 /* if the type has a normalizer, generate the
704 * normalized values. otherwise leave them NULL.
706 * this is different from the rule for attributes
707 * in an entry - in an attribute list, the normalized
708 * value is set equal to the non-normalized value
709 * when there is no normalizer.
711 if( nvals && ad->ad_type->sat_equality &&
712 ad->ad_type->sat_equality->smr_normalize )
714 ml->sml_nvalues = ber_memalloc_x(
715 (nvals+1)*sizeof(struct berval), ctx );
717 for ( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
718 #ifdef SLAP_ORDERED_PRETTYNORM
719 rc = ordered_value_normalize(
720 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
722 ad->ad_type->sat_equality,
723 &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
724 #else /* ! SLAP_ORDERED_PRETTYNORM */
725 rc = ad->ad_type->sat_equality->smr_normalize(
726 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
727 ad->ad_type->sat_syntax,
728 ad->ad_type->sat_equality,
729 &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
730 #endif /* ! SLAP_ORDERED_PRETTYNORM */
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 BER_BVZERO( &ml->sml_nvalues[nvals] );
746 /* check for duplicates, but ignore Deletes.
748 if( nvals > 1 && ml->sml_op != LDAP_MOD_DELETE ) {
750 MatchingRule *mr = ad->ad_type->sat_equality;
752 for ( i = 1; i < nvals ; i++ ) {
753 /* test asserted values against themselves */
754 for( j = 0; j < i; j++ ) {
755 rc = ordered_value_match( &match, ml->sml_desc, mr,
757 | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX
758 | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
759 | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
761 ? &ml->sml_nvalues[i]
762 : &ml->sml_values[i],
764 ? &ml->sml_nvalues[j]
765 : &ml->sml_values[j],
767 if ( rc == LDAP_SUCCESS && match == 0 ) {
768 /* value exists already */
769 snprintf( textbuf, textlen,
770 "%s: value #%d provided more than once",
771 ml->sml_desc->ad_cname.bv_val, j );
773 return LDAP_TYPE_OR_VALUE_EXISTS;
775 } else if ( rc != LDAP_SUCCESS ) {
788 /* Enter with bv->bv_len = sizeof buffer, returns with
789 * actual length of string
791 void slap_timestamp( time_t *tm, struct berval *bv )
797 ltm = gmtime_r( tm, <m_buf );
799 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
803 bv->bv_len = lutil_gentime( bv->bv_val, bv->bv_len, ltm );
805 #ifndef HAVE_GMTIME_R
806 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
810 /* modify only calls this for non-replicas. modrdn always calls.
812 void slap_mods_opattrs(
817 struct berval name, timestamp, csn = BER_BVNULL;
819 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
820 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
821 Modifications *mod, **modtail, *modlast;
823 if ( SLAP_LASTMOD( op->o_bd ) ) {
825 timestamp.bv_val = timebuf;
826 if ( BER_BVISEMPTY( &op->o_csn )) {
828 csn.bv_len = sizeof( csnbuf );
829 slap_get_csn( op, &csn, manage_ctxcsn );
833 ptr = strchr( csn.bv_val, '#' );
835 timestamp.bv_len = ptr - csn.bv_val;
836 if ( timestamp.bv_len >= sizeof( timebuf ))
837 timestamp.bv_len = sizeof( timebuf ) - 1;
838 strncpy( timebuf, csn.bv_val, timestamp.bv_len );
839 timebuf[timestamp.bv_len] = '\0';
841 time_t now = slap_get_time();
843 timestamp.bv_len = sizeof(timebuf);
845 slap_timestamp( &now, ×tamp );
848 if ( BER_BVISEMPTY( &op->o_dn ) ) {
849 BER_BVSTR( &name, SLAPD_ANONYMOUS );
856 for ( mod = mods; mod->sml_next; mod = mod->sml_next )
858 modtail = &mod->sml_next;
860 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
861 mod->sml_op = LDAP_MOD_REPLACE;
862 mod->sml_flags = SLAP_MOD_INTERNAL;
863 mod->sml_next = NULL;
864 BER_BVZERO( &mod->sml_type );
865 mod->sml_desc = slap_schema.si_ad_entryCSN;
866 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
867 ber_dupbv( &mod->sml_values[0], &csn );
868 BER_BVZERO( &mod->sml_values[1] );
869 assert( !BER_BVISNULL( &mod->sml_values[0] ) );
870 mod->sml_nvalues = NULL;
873 modtail = &mod->sml_next;
875 if ( get_manageDIT( op ) ) {
876 for ( mod = mods; mod != modlast; mod = mod->sml_next ) {
877 if ( mod->sml_desc == slap_schema.si_ad_modifiersName ) {
883 if ( mod->sml_desc != slap_schema.si_ad_modifiersName ) {
884 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
885 mod->sml_op = LDAP_MOD_REPLACE;
886 mod->sml_flags = SLAP_MOD_INTERNAL;
887 mod->sml_next = NULL;
888 BER_BVZERO( &mod->sml_type );
889 mod->sml_desc = slap_schema.si_ad_modifiersName;
890 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
891 ber_dupbv( &mod->sml_values[0], &name );
892 BER_BVZERO( &mod->sml_values[1] );
893 assert( !BER_BVISNULL( &mod->sml_values[0] ) );
895 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
896 ber_dupbv( &mod->sml_nvalues[0], &nname );
897 BER_BVZERO( &mod->sml_nvalues[1] );
898 assert( !BER_BVISNULL( &mod->sml_nvalues[0] ) );
900 modtail = &mod->sml_next;
903 if ( get_manageDIT( op ) ) {
904 for ( mod = mods; mod != modlast; mod = mod->sml_next ) {
905 if ( mod->sml_desc == slap_schema.si_ad_modifyTimestamp ) {
911 if ( mod->sml_desc != slap_schema.si_ad_modifyTimestamp ) {
912 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
913 mod->sml_op = LDAP_MOD_REPLACE;
914 mod->sml_flags = SLAP_MOD_INTERNAL;
915 mod->sml_next = NULL;
916 BER_BVZERO( &mod->sml_type );
917 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
918 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
919 ber_dupbv( &mod->sml_values[0], ×tamp );
920 BER_BVZERO( &mod->sml_values[1] );
921 assert( !BER_BVISNULL( &mod->sml_values[0] ) );
922 mod->sml_nvalues = NULL;