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 );
351 if ( rc != 0 && rc != LDAP_OTHER ) {
353 * either there is no preOp (modify) plugins
354 * or a plugin failed. Just log it
356 * FIXME: is this correct?
359 LDAP_LOG( OPERATION, INFO, "do_modify: modify preOps "
360 "failed\n", 0, 0, 0 );
362 Debug(LDAP_DEBUG_TRACE, "do_modify: modify preOps failed.\n",
366 #endif /* defined( LDAP_SLAPI ) */
369 * do the modify if 1 && (2 || 3)
370 * 1) there is a modify function implemented in this backend;
371 * 2) this backend is master for what it holds;
372 * 3) it's a replica and the dn supplied is the update_ndn.
374 if ( be->be_modify ) {
375 /* do the update here */
376 int repl_user = be_isupdate( be, &op->o_ndn );
377 #ifndef SLAPD_MULTIMASTER
378 /* Multimaster slapd does not have to check for replicator dn
379 * because it accepts each modify request
381 if ( !be->be_update_ndn.bv_len || repl_user )
384 int update = be->be_update_ndn.bv_len;
386 char textbuf[SLAP_TEXT_BUFLEN];
387 size_t textlen = sizeof textbuf;
389 rc = slap_mods_check( modlist, update, &text,
392 if( rc != LDAP_SUCCESS ) {
393 send_ldap_result( conn, op, rc,
394 NULL, text, NULL, NULL );
399 for( modtail = &modlist;
401 modtail = &(*modtail)->sml_next )
406 rc = slap_mods_opattrs( be, op, modlist, modtail, &text,
408 if( rc != LDAP_SUCCESS ) {
409 send_ldap_result( conn, op, rc,
416 if ( (*be->be_modify)( be, conn, op, &pdn, &ndn, modlist ) == 0
417 #ifdef SLAPD_MULTIMASTER
421 /* but we log only the ones not from a replicator user */
422 replog( be, op, &pdn, &ndn, modlist );
425 #ifndef SLAPD_MULTIMASTER
426 /* send a referral */
428 BerVarray defref = be->be_update_refs
429 ? be->be_update_refs : default_referral;
430 BerVarray ref = referral_rewrite( defref,
431 NULL, &pdn, LDAP_SCOPE_DEFAULT );
433 send_ldap_result( conn, op, rc = LDAP_REFERRAL, NULL, NULL,
434 ref ? ref : defref, NULL );
436 ber_bvarray_free( ref );
440 send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
441 NULL, "operation not supported within namingContext",
445 #if defined( LDAP_SLAPI )
446 rc = doPluginFNs( be, SLAPI_PLUGIN_POST_MODIFY_FN, pb );
447 if ( rc != 0 && rc != LDAP_OTHER ) {
449 * either there is no postOp (modify) plugins
450 * or a plugin failed. Just log it
452 * FIXME: is this correct?
455 LDAP_LOG( OPERATION, INFO, "do_modify: modify postOps "
456 "failed\n", 0, 0, 0 );
458 Debug(LDAP_DEBUG_TRACE, "do_modify: modify postOps "
459 "failed.\n", 0, 0, 0);
462 #endif /* defined( LDAP_SLAPI ) */
467 if ( modlist != NULL )
468 slap_mods_free( modlist );
470 FreeLDAPMods( modv );
475 * Do basic attribute type checking and syntax validation.
486 for( ; ml != NULL; ml = ml->sml_next ) {
487 AttributeDescription *ad = NULL;
489 /* convert to attribute description */
490 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
492 if( rc != LDAP_SUCCESS ) {
493 snprintf( textbuf, textlen, "%s: %s",
494 ml->sml_type.bv_val, *text );
501 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
502 && !slap_ad_is_binary( ad ))
504 /* attribute requires binary transfer */
505 snprintf( textbuf, textlen,
506 "%s: requires ;binary transfer",
507 ml->sml_type.bv_val );
509 return LDAP_UNDEFINED_TYPE;
512 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
513 && slap_ad_is_binary( ad ))
515 /* attribute requires binary transfer */
516 snprintf( textbuf, textlen,
517 "%s: disallows ;binary transfer",
518 ml->sml_type.bv_val );
520 return LDAP_UNDEFINED_TYPE;
523 if( slap_ad_is_tag_range( ad )) {
524 /* attribute requires binary transfer */
525 snprintf( textbuf, textlen,
526 "%s: inappropriate use of tag range option",
527 ml->sml_type.bv_val );
529 return LDAP_UNDEFINED_TYPE;
532 if (!update && is_at_no_user_mod( ad->ad_type )) {
533 /* user modification disallowed */
534 snprintf( textbuf, textlen,
535 "%s: no user modification allowed",
536 ml->sml_type.bv_val );
538 return LDAP_CONSTRAINT_VIOLATION;
541 if ( is_at_obsolete( ad->ad_type ) &&
542 ( ml->sml_op == LDAP_MOD_ADD || ml->sml_bvalues != NULL ) )
545 * attribute is obsolete,
546 * only allow replace/delete with no values
548 snprintf( textbuf, textlen,
549 "%s: attribute is obsolete",
550 ml->sml_type.bv_val );
552 return LDAP_CONSTRAINT_VIOLATION;
558 if( ml->sml_bvalues != NULL ) {
560 slap_syntax_validate_func *validate =
561 ad->ad_type->sat_syntax->ssyn_validate;
562 slap_syntax_transform_func *pretty =
563 ad->ad_type->sat_syntax->ssyn_pretty;
565 if( !pretty && !validate ) {
566 *text = "no validator for syntax";
567 snprintf( textbuf, textlen,
568 "%s: no validator for syntax %s",
570 ad->ad_type->sat_syntax->ssyn_oid );
572 return LDAP_INVALID_SYNTAX;
576 * check that each value is valid per syntax
577 * and pretty if appropriate
579 for( nvals = 0; ml->sml_bvalues[nvals].bv_val; nvals++ ) {
582 rc = pretty( ad->ad_type->sat_syntax,
583 &ml->sml_bvalues[nvals], &pval );
585 rc = validate( ad->ad_type->sat_syntax,
586 &ml->sml_bvalues[nvals] );
590 snprintf( textbuf, textlen,
591 "%s: value #%ld invalid per syntax",
592 ml->sml_type.bv_val, (long) nvals );
594 return LDAP_INVALID_SYNTAX;
598 ber_memfree( ml->sml_bvalues[nvals].bv_val );
599 ml->sml_bvalues[nvals] = pval;
604 * a rough single value check... an additional check is needed
605 * to catch add of single value to existing single valued attribute
607 if( ( ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE )
608 && nvals > 1 && is_at_single_value( ad->ad_type ))
610 snprintf( textbuf, textlen,
611 "%s: multiple value provided",
612 ml->sml_type.bv_val );
614 return LDAP_CONSTRAINT_VIOLATION;
622 int slap_mods_opattrs(
626 Modifications **modtail,
628 char *textbuf, size_t textlen )
630 struct berval name, timestamp, csn;
631 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
632 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
635 int mop = op->o_tag == LDAP_REQ_ADD
636 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
638 assert( modtail != NULL );
639 assert( *modtail == NULL );
641 if( SLAP_LASTMOD(be) ) {
643 time_t now = slap_get_time();
645 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
646 ltm = gmtime( &now );
647 lutil_gentime( timebuf, sizeof(timebuf), ltm );
649 csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 );
650 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
653 timestamp.bv_val = timebuf;
654 timestamp.bv_len = strlen(timebuf);
656 if( op->o_dn.bv_len == 0 ) {
657 name.bv_val = SLAPD_ANONYMOUS;
658 name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
664 if( op->o_tag == LDAP_REQ_ADD ) {
665 struct berval tmpval;
667 if( global_schemacheck ) {
668 int rc = mods_structural_class( mods, &tmpval,
669 text, textbuf, textlen );
670 if( rc != LDAP_SUCCESS ) {
674 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
676 mod->sml_type.bv_val = NULL;
677 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
678 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
679 ber_dupbv( &mod->sml_bvalues[0], &tmpval );
680 mod->sml_bvalues[1].bv_val = NULL;
681 assert( mod->sml_bvalues[0].bv_val );
683 modtail = &mod->sml_next;
686 if( SLAP_LASTMOD(be) ) {
687 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
689 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
690 tmpval.bv_val = uuidbuf;
692 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
694 mod->sml_type.bv_val = NULL;
695 mod->sml_desc = slap_schema.si_ad_entryUUID;
696 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
697 ber_dupbv( &mod->sml_bvalues[0], &tmpval );
698 mod->sml_bvalues[1].bv_val = NULL;
699 assert( mod->sml_bvalues[0].bv_val );
701 modtail = &mod->sml_next;
703 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
705 mod->sml_type.bv_val = NULL;
706 mod->sml_desc = slap_schema.si_ad_creatorsName;
707 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
708 ber_dupbv( &mod->sml_bvalues[0], &name );
709 mod->sml_bvalues[1].bv_val = NULL;
710 assert( mod->sml_bvalues[0].bv_val );
712 modtail = &mod->sml_next;
714 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
716 mod->sml_type.bv_val = NULL;
717 mod->sml_desc = slap_schema.si_ad_createTimestamp;
718 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
719 ber_dupbv( &mod->sml_bvalues[0], ×tamp );
720 mod->sml_bvalues[1].bv_val = NULL;
721 assert( mod->sml_bvalues[0].bv_val );
723 modtail = &mod->sml_next;
727 if( SLAP_LASTMOD(be) ) {
728 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
730 mod->sml_type.bv_val = NULL;
731 mod->sml_desc = slap_schema.si_ad_entryCSN;
732 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
733 ber_dupbv( &mod->sml_bvalues[0], &csn );
734 mod->sml_bvalues[1].bv_val = NULL;
735 assert( mod->sml_bvalues[0].bv_val );
737 modtail = &mod->sml_next;
739 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
741 mod->sml_type.bv_val = NULL;
742 mod->sml_desc = slap_schema.si_ad_modifiersName;
743 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
744 ber_dupbv( &mod->sml_bvalues[0], &name );
745 mod->sml_bvalues[1].bv_val = NULL;
746 assert( mod->sml_bvalues[0].bv_val );
748 modtail = &mod->sml_next;
750 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
752 mod->sml_type.bv_val = NULL;
753 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
754 mod->sml_bvalues = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
755 ber_dupbv( &mod->sml_bvalues[0], ×tamp );
756 mod->sml_bvalues[1].bv_val = NULL;
757 assert( mod->sml_bvalues[0].bv_val );
759 modtail = &mod->sml_next;
768 * Synthesise an LDAPMod array from a Modifications list to pass
771 static LDAPMod **Modifications2LDAPMods(Modifications *modlist)
773 LDAPMod *mods, **modv;
777 /* based on back-ldap/modify.c */
778 for (i = 0, ml = modlist; ml != NULL; i++, ml = ml->sml_next)
781 mods = (LDAPMod *)ch_malloc(i * sizeof(LDAPMod));
786 modv = (LDAPMod **)ch_malloc((i + 1) * sizeof(LDAPMod *));
792 for (i = 0, ml = modlist; ml != NULL; ml = ml->sml_next) {
793 if (ml->sml_desc->ad_type->sat_no_user_mod) {
797 mods[i].mod_op = ml->sml_op | LDAP_MOD_BVALUES;
798 mods[i].mod_type = ml->sml_desc->ad_cname.bv_val;
799 if (ml->sml_bvalues != NULL) {
800 for (j = 0; ml->sml_bvalues[j].bv_val != NULL; j++)
802 mods[i].mod_bvalues = (struct berval **)ch_malloc((j + 1) *
803 sizeof(struct berval *));
804 for (j = 0; ml->sml_bvalues[j].bv_val != NULL; j++)
805 mods[i].mod_bvalues[j] = &ml->sml_bvalues[j];
807 mods[i].mod_bvalues = NULL;
817 * Free a contiguous block of LDAP modifications.
819 void FreeLDAPMods(LDAPMod **modv)
826 for (i = 0; modv[i] != NULL; i++) {
827 ch_free(modv[i]->mod_bvalues);
832 #endif /* LDAP_SLAPI */