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.
19 #include "slapi_common.h"
23 #include <ac/socket.h>
24 #include <ac/string.h>
34 static LDAPMod **Modifications2LDAPMods (Modifications *modlist);
35 static void FreeLDAPMods (LDAPMod **);
36 #endif /* LDAP_SLAPI */
43 struct berval dn = { 0, NULL };
44 struct berval pdn = { 0, NULL };
45 struct berval ndn = { 0, NULL };
49 Modifications *modlist = NULL;
50 Modifications **modtail = &modlist;
52 LDAPMod **modv = NULL;
61 Slapi_PBlock *pb = op->o_pb;
64 LDAP_LOG( OPERATION, ENTRY, "do_modify: enter\n", 0, 0, 0 );
66 Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
70 * Parse the modify request. It looks like this:
72 * ModifyRequest := [APPLICATION 6] SEQUENCE {
73 * name DistinguishedName,
74 * mods SEQUENCE OF SEQUENCE {
75 * operation ENUMERATED {
80 * modification SEQUENCE {
82 * values SET OF AttributeValue
88 if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) {
90 LDAP_LOG( OPERATION, ERR, "do_modify: ber_scanf failed\n", 0, 0, 0 );
92 Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 );
95 send_ldap_disconnect( conn, op,
96 LDAP_PROTOCOL_ERROR, "decoding error" );
97 return SLAPD_DISCONNECT;
101 LDAP_LOG( OPERATION, ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
103 Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
107 /* collect modifications & save for later */
109 for ( tag = ber_first_element( op->o_ber, &len, &last );
111 tag = ber_next_element( op->o_ber, &len, last ) )
114 Modifications tmp, *mod;
117 if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
118 &tmp.sml_type, &tmp.sml_bvalues )
121 send_ldap_disconnect( conn, op,
122 LDAP_PROTOCOL_ERROR, "decoding modlist error" );
123 rc = SLAPD_DISCONNECT;
127 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
129 mod->sml_type = tmp.sml_type;
130 mod->sml_bvalues = tmp.sml_bvalues;
131 mod->sml_desc = NULL;
137 if ( mod->sml_bvalues == NULL ) {
139 LDAP_LOG( OPERATION, ERR,
140 "do_modify: modify/add operation (%ld) requires values\n",
143 Debug( LDAP_DEBUG_ANY,
144 "do_modify: modify/add operation (%ld) requires values\n",
148 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
149 NULL, "modify/add operation requires values",
151 rc = LDAP_PROTOCOL_ERROR;
157 case LDAP_MOD_DELETE:
158 case LDAP_MOD_REPLACE:
163 LDAP_LOG( OPERATION, ERR,
164 "do_modify: invalid modify operation (%ld)\n", (long)mop, 0, 0 );
166 Debug( LDAP_DEBUG_ANY,
167 "do_modify: invalid modify operation (%ld)\n",
171 send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
172 NULL, "unrecognized modify operation", NULL, NULL );
173 rc = LDAP_PROTOCOL_ERROR;
178 modtail = &mod->sml_next;
182 if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
184 LDAP_LOG( OPERATION, ERR, "do_modify: get_ctrls failed\n", 0, 0, 0 );
186 Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
192 rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
193 if( rc != LDAP_SUCCESS ) {
195 LDAP_LOG( OPERATION, INFO, "do_modify: conn %d invalid dn (%s)\n",
196 conn->c_connid, dn.bv_val, 0 );
198 Debug( LDAP_DEBUG_ANY,
199 "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 );
201 send_ldap_result( conn, op, rc = LDAP_INVALID_DN_SYNTAX, NULL,
202 "invalid DN", NULL, NULL );
206 if( ndn.bv_len == 0 ) {
208 LDAP_LOG( OPERATION, ERR,
209 "do_modify: attempt to modify root DSE.\n",0, 0, 0 );
211 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
214 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
215 NULL, "modify upon the root DSE not supported", NULL, NULL );
218 } else if ( bvmatch( &ndn, &global_schemandn ) ) {
220 LDAP_LOG( OPERATION, ERR,
221 "do_modify: attempt to modify subschema subentry.\n" , 0, 0, 0 );
223 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
226 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
227 NULL, "modification of subschema subentry not supported",
234 LDAP_LOG( OPERATION, DETAIL1, "do_modify: modifications:\n", 0, 0, 0 );
236 Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
239 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
241 LDAP_LOG( OPERATION, DETAIL1, "\t%s: %s\n",
242 tmp->sml_op == LDAP_MOD_ADD ?
243 "add" : (tmp->sml_op == LDAP_MOD_DELETE ?
244 "delete" : "replace"), tmp->sml_type.bv_val, 0 );
246 if ( tmp->sml_bvalues == NULL ) {
247 LDAP_LOG( OPERATION, DETAIL1, "\t\tno values", 0, 0, 0 );
248 } else if ( tmp->sml_bvalues[0].bv_val == NULL ) {
249 LDAP_LOG( OPERATION, DETAIL1, "\t\tzero values", 0, 0, 0 );
250 } else if ( tmp->sml_bvalues[1].bv_val == NULL ) {
251 LDAP_LOG( OPERATION, DETAIL1, "\t\tone value", 0, 0, 0 );
253 LDAP_LOG( OPERATION, DETAIL1, "\t\tmultiple values", 0, 0, 0 );
257 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
258 tmp->sml_op == LDAP_MOD_ADD
259 ? "add" : (tmp->sml_op == LDAP_MOD_DELETE
260 ? "delete" : "replace"), tmp->sml_type.bv_val, 0 );
262 if ( tmp->sml_bvalues == NULL ) {
263 Debug( LDAP_DEBUG_ARGS, "%s\n",
264 "\t\tno values", NULL, NULL );
265 } else if ( tmp->sml_bvalues[0].bv_val == NULL ) {
266 Debug( LDAP_DEBUG_ARGS, "%s\n",
267 "\t\tzero values", NULL, NULL );
268 } else if ( tmp->sml_bvalues[1].bv_val == NULL ) {
269 Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
270 "\t\tone value", (long) tmp->sml_bvalues[0].bv_len, NULL );
272 Debug( LDAP_DEBUG_ARGS, "%s\n",
273 "\t\tmultiple values", NULL, NULL );
279 if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
280 char abuf[BUFSIZ/2], *ptr = abuf;
283 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD dn=\"%s\"\n",
284 op->o_connid, op->o_opid, dn.bv_val, 0, 0 );
286 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
287 if (len + 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
288 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
289 op->o_connid, op->o_opid, abuf, 0, 0 );
297 ptr = lutil_strcopy(ptr, tmp->sml_type.bv_val);
298 len += tmp->sml_type.bv_len;
301 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
302 op->o_connid, op->o_opid, abuf, 0, 0 );
306 manageDSAit = get_manageDSAit( op );
309 * We could be serving multiple database backends. Select the
310 * appropriate one, or send a referral to our "referral server"
311 * if we don't hold it.
313 if ( (be = select_backend( &ndn, manageDSAit, 0 )) == NULL ) {
314 BerVarray ref = referral_rewrite( default_referral,
315 NULL, &pdn, LDAP_SCOPE_DEFAULT );
317 send_ldap_result( conn, op, rc = LDAP_REFERRAL,
318 NULL, NULL, ref ? ref : default_referral, NULL );
320 ber_bvarray_free( ref );
324 /* check restrictions */
325 rc = backend_check_restrictions( be, conn, op, NULL, &text ) ;
326 if( rc != LDAP_SUCCESS ) {
327 send_ldap_result( conn, op, rc,
328 NULL, text, NULL, NULL );
332 /* check for referrals */
333 rc = backend_check_referrals( be, conn, op, &pdn, &ndn );
334 if ( rc != LDAP_SUCCESS ) {
338 /* deref suffix alias if appropriate */
339 suffix_alias( be, &ndn );
341 #if defined( LDAP_SLAPI )
342 slapi_backend_set_pb( pb, be );
343 slapi_connection_set_pb( pb, conn );
344 slapi_operation_set_pb( pb, op );
345 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
346 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
347 modv = Modifications2LDAPMods( modlist );
348 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
350 rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
353 * A preoperation plugin failure will abort the
357 LDAP_LOG( OPERATION, INFO, "do_modify: modify preoperation plugin "
358 "failed\n", 0, 0, 0 );
360 Debug(LDAP_DEBUG_TRACE, "do_modify: modify preoperation plugin failed.\n",
363 if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rc ) != 0)
364 rc = LDAP_OPERATIONS_ERROR;
367 #endif /* defined( LDAP_SLAPI ) */
370 * do the modify if 1 && (2 || 3)
371 * 1) there is a modify function implemented in this backend;
372 * 2) this backend is master for what it holds;
373 * 3) it's a replica and the dn supplied is the update_ndn.
375 if ( be->be_modify ) {
376 /* do the update here */
377 int repl_user = be_isupdate( be, &op->o_ndn );
378 #ifndef SLAPD_MULTIMASTER
379 /* Multimaster slapd does not have to check for replicator dn
380 * because it accepts each modify request
382 if ( !be->be_update_ndn.bv_len || repl_user )
385 int update = be->be_update_ndn.bv_len;
387 char textbuf[SLAP_TEXT_BUFLEN];
388 size_t textlen = sizeof textbuf;
390 rc = slap_mods_check( modlist, update, &text,
393 if( rc != LDAP_SUCCESS ) {
394 send_ldap_result( conn, op, rc,
395 NULL, text, NULL, NULL );
400 for( modtail = &modlist;
402 modtail = &(*modtail)->sml_next )
407 rc = slap_mods_opattrs( be, op, modlist, modtail, &text,
409 if( rc != LDAP_SUCCESS ) {
410 send_ldap_result( conn, op, rc,
417 if ( (*be->be_modify)( be, conn, op, &pdn, &ndn, modlist ) == 0
418 #ifdef SLAPD_MULTIMASTER
422 /* but we log only the ones not from a replicator user */
423 replog( be, op, &pdn, &ndn, modlist );
426 #ifndef SLAPD_MULTIMASTER
427 /* send a referral */
429 BerVarray defref = be->be_update_refs
430 ? be->be_update_refs : default_referral;
431 BerVarray ref = referral_rewrite( defref,
432 NULL, &pdn, LDAP_SCOPE_DEFAULT );
434 send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
435 ref ? ref : defref, NULL );
437 ber_bvarray_free( ref );
441 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
442 NULL, "operation not supported within namingContext",
446 #if defined( LDAP_SLAPI )
447 if ( doPluginFNs( be, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) != 0 ) {
449 LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins "
450 "failed\n", 0, 0, 0 );
452 Debug(LDAP_DEBUG_TRACE, "do_modify: modify postoperation plugins "
453 "failed.\n", 0, 0, 0);
456 #endif /* defined( LDAP_SLAPI ) */
461 if ( modlist != NULL ) slap_mods_free( modlist );
463 if ( modv != NULL ) FreeLDAPMods( modv );
469 * Do basic attribute type checking and syntax validation.
480 for( ; ml != NULL; ml = ml->sml_next ) {
481 AttributeDescription *ad = NULL;
483 /* convert to attribute description */
484 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
486 if( rc != LDAP_SUCCESS ) {
487 snprintf( textbuf, textlen, "%s: %s",
488 ml->sml_type.bv_val, *text );
495 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
496 && !slap_ad_is_binary( ad ))
498 /* attribute requires binary transfer */
499 snprintf( textbuf, textlen,
500 "%s: requires ;binary transfer",
501 ml->sml_type.bv_val );
503 return LDAP_UNDEFINED_TYPE;
506 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
507 && slap_ad_is_binary( ad ))
509 /* attribute requires binary transfer */
510 snprintf( textbuf, textlen,
511 "%s: disallows ;binary transfer",
512 ml->sml_type.bv_val );
514 return LDAP_UNDEFINED_TYPE;
517 if( slap_ad_is_tag_range( ad )) {
518 /* attribute requires binary transfer */
519 snprintf( textbuf, textlen,
520 "%s: inappropriate use of tag range option",
521 ml->sml_type.bv_val );
523 return LDAP_UNDEFINED_TYPE;
526 if (!update && is_at_no_user_mod( ad->ad_type )) {
527 /* user modification disallowed */
528 snprintf( textbuf, textlen,
529 "%s: no user modification allowed",
530 ml->sml_type.bv_val );
532 return LDAP_CONSTRAINT_VIOLATION;
535 if ( is_at_obsolete( ad->ad_type ) &&
536 ( ml->sml_op == LDAP_MOD_ADD || ml->sml_bvalues != NULL ) )
539 * attribute is obsolete,
540 * only allow replace/delete with no values
542 snprintf( textbuf, textlen,
543 "%s: attribute is obsolete",
544 ml->sml_type.bv_val );
546 return LDAP_CONSTRAINT_VIOLATION;
552 if( ml->sml_bvalues != NULL ) {
554 slap_syntax_validate_func *validate =
555 ad->ad_type->sat_syntax->ssyn_validate;
556 slap_syntax_transform_func *pretty =
557 ad->ad_type->sat_syntax->ssyn_pretty;
559 if( !pretty && !validate ) {
560 *text = "no validator for syntax";
561 snprintf( textbuf, textlen,
562 "%s: no validator for syntax %s",
564 ad->ad_type->sat_syntax->ssyn_oid );
566 return LDAP_INVALID_SYNTAX;
570 * check that each value is valid per syntax
571 * and pretty if appropriate
573 for( nvals = 0; ml->sml_bvalues[nvals].bv_val; nvals++ ) {
576 rc = pretty( ad->ad_type->sat_syntax,
577 &ml->sml_bvalues[nvals], &pval );
579 rc = validate( ad->ad_type->sat_syntax,
580 &ml->sml_bvalues[nvals] );
584 snprintf( textbuf, textlen,
585 "%s: value #%ld invalid per syntax",
586 ml->sml_type.bv_val, (long) nvals );
588 return LDAP_INVALID_SYNTAX;
592 ber_memfree( ml->sml_bvalues[nvals].bv_val );
593 ml->sml_bvalues[nvals] = pval;
598 * a rough single value check... an additional check is needed
599 * to catch add of single value to existing single valued attribute
601 if( ( ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE )
602 && nvals > 1 && is_at_single_value( ad->ad_type ))
604 snprintf( textbuf, textlen,
605 "%s: multiple value provided",
606 ml->sml_type.bv_val );
608 return LDAP_CONSTRAINT_VIOLATION;
616 int slap_mods_opattrs(
620 Modifications **modtail,
622 char *textbuf, size_t textlen )
624 struct berval name, timestamp, csn;
625 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
626 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
629 int mop = op->o_tag == LDAP_REQ_ADD
630 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
632 assert( modtail != NULL );
633 assert( *modtail == NULL );
635 if( SLAP_LASTMOD(be) ) {
637 time_t now = slap_get_time();
639 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
640 ltm = gmtime( &now );
641 lutil_gentime( timebuf, sizeof(timebuf), ltm );
643 csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 );
644 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
647 timestamp.bv_val = timebuf;
648 timestamp.bv_len = strlen(timebuf);
650 if( op->o_dn.bv_len == 0 ) {
651 name.bv_val = SLAPD_ANONYMOUS;
652 name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
658 if( op->o_tag == LDAP_REQ_ADD ) {
659 struct berval tmpval;
661 if( global_schemacheck ) {
662 int rc = mods_structural_class( mods, &tmpval,
663 text, textbuf, textlen );
664 if( rc != LDAP_SUCCESS ) {
668 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
670 mod->sml_type.bv_val = NULL;
671 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
672 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
673 ber_dupbv( &mod->sml_bvalues[0], &tmpval );
674 mod->sml_bvalues[1].bv_val = NULL;
675 assert( mod->sml_bvalues[0].bv_val );
677 modtail = &mod->sml_next;
680 if( SLAP_LASTMOD(be) ) {
681 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
683 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
684 tmpval.bv_val = uuidbuf;
686 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
688 mod->sml_type.bv_val = NULL;
689 mod->sml_desc = slap_schema.si_ad_entryUUID;
690 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
691 ber_dupbv( &mod->sml_bvalues[0], &tmpval );
692 mod->sml_bvalues[1].bv_val = NULL;
693 assert( mod->sml_bvalues[0].bv_val );
695 modtail = &mod->sml_next;
697 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
699 mod->sml_type.bv_val = NULL;
700 mod->sml_desc = slap_schema.si_ad_creatorsName;
701 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
702 ber_dupbv( &mod->sml_bvalues[0], &name );
703 mod->sml_bvalues[1].bv_val = NULL;
704 assert( mod->sml_bvalues[0].bv_val );
706 modtail = &mod->sml_next;
708 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
710 mod->sml_type.bv_val = NULL;
711 mod->sml_desc = slap_schema.si_ad_createTimestamp;
712 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
713 ber_dupbv( &mod->sml_bvalues[0], ×tamp );
714 mod->sml_bvalues[1].bv_val = NULL;
715 assert( mod->sml_bvalues[0].bv_val );
717 modtail = &mod->sml_next;
721 if( SLAP_LASTMOD(be) ) {
722 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
724 mod->sml_type.bv_val = NULL;
725 mod->sml_desc = slap_schema.si_ad_entryCSN;
726 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
727 ber_dupbv( &mod->sml_bvalues[0], &csn );
728 mod->sml_bvalues[1].bv_val = NULL;
729 assert( mod->sml_bvalues[0].bv_val );
731 modtail = &mod->sml_next;
733 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
735 mod->sml_type.bv_val = NULL;
736 mod->sml_desc = slap_schema.si_ad_modifiersName;
737 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
738 ber_dupbv( &mod->sml_bvalues[0], &name );
739 mod->sml_bvalues[1].bv_val = NULL;
740 assert( mod->sml_bvalues[0].bv_val );
742 modtail = &mod->sml_next;
744 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
746 mod->sml_type.bv_val = NULL;
747 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
748 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
749 ber_dupbv( &mod->sml_bvalues[0], ×tamp );
750 mod->sml_bvalues[1].bv_val = NULL;
751 assert( mod->sml_bvalues[0].bv_val );
753 modtail = &mod->sml_next;
762 * Synthesise an LDAPMod array from a Modifications list to pass
765 static LDAPMod **Modifications2LDAPMods(Modifications *modlist)
767 LDAPMod *mods, **modv;
771 /* based on back-ldap/modify.c */
772 for( i = 0, ml = modlist; ml != NULL; i++, ml = ml->sml_next )
775 mods = (LDAPMod *)ch_malloc( i * sizeof(LDAPMod) );
780 modv = (LDAPMod **)ch_malloc( (i + 1) * sizeof(LDAPMod *) );
786 for( i = 0, ml = modlist; ml != NULL; ml = ml->sml_next ) {
787 if ( ml->sml_desc->ad_type->sat_no_user_mod ) {
791 mods[i].mod_op = ml->sml_op | LDAP_MOD_BVALUES;
792 mods[i].mod_type = ml->sml_desc->ad_cname.bv_val;
793 if (ml->sml_bvalues != NULL) {
794 for( j = 0; ml->sml_bvalues[j].bv_val != NULL; j++ )
796 mods[i].mod_bvalues = (struct berval **)ch_malloc( (j + 1) *
797 sizeof(struct berval *) );
798 for( j = 0; ml->sml_bvalues[j].bv_val != NULL; j++ )
799 mods[i].mod_bvalues[j] = &ml->sml_bvalues[j];
801 mods[i].mod_bvalues = NULL;
811 * Free a contiguous block of LDAP modifications.
813 static void FreeLDAPMods(LDAPMod **modv)
820 for( i = 0; modv[i] != NULL; i++ ) {
821 ch_free( modv[i]->mod_bvalues );
826 #endif /* LDAP_SLAPI */