move to more appropriate file ...

This commit is contained in:
Pierangelo Masarati 2003-04-07 17:18:42 +00:00
parent 6dbd7341f9
commit 243311d56a
2 changed files with 44 additions and 43 deletions

View File

@ -149,46 +149,3 @@ ldap_back_add(
return ldap_back_op_result( lc, op, rs, msgid, 1 ) != LDAP_SUCCESS;
}
int
ldap_dnattr_rewrite(
dncookie *dc,
BerVarray a_vals
)
{
struct berval bv;
int i, last;
for ( last = 0; a_vals[last].bv_val != NULL; last++ );
last--;
for ( i = 0; a_vals[i].bv_val != NULL; i++ ) {
switch ( ldap_back_dn_massage( dc, &a_vals[i], &bv ) ) {
case LDAP_SUCCESS:
case LDAP_OTHER: /* ? */
default: /* ??? */
/* leave attr untouched if massage failed */
if ( bv.bv_val && bv.bv_val != a_vals[i].bv_val ) {
ch_free( a_vals[i].bv_val );
a_vals[i] = bv;
}
break;
case LDAP_UNWILLING_TO_PERFORM:
/*
* FIXME: need to check if it may be considered
* legal to trim values when adding/modifying;
* it should be when searching (see ACLs).
*/
ch_free( a_vals[i].bv_val );
if (last > i ) {
a_vals[i] = a_vals[last];
}
a_vals[last].bv_len = 0;
a_vals[last].bv_val = NULL;
last--;
break;
}
}
return 0;
}

View File

@ -468,3 +468,47 @@ ldap_back_filter_map_rewrite(
return 0;
}
int
ldap_dnattr_rewrite(
dncookie *dc,
BerVarray a_vals
)
{
struct berval bv;
int i, last;
for ( last = 0; a_vals[last].bv_val != NULL; last++ );
last--;
for ( i = 0; a_vals[i].bv_val != NULL; i++ ) {
switch ( ldap_back_dn_massage( dc, &a_vals[i], &bv ) ) {
case LDAP_SUCCESS:
case LDAP_OTHER: /* ? */
default: /* ??? */
/* leave attr untouched if massage failed */
if ( bv.bv_val && bv.bv_val != a_vals[i].bv_val ) {
ch_free( a_vals[i].bv_val );
a_vals[i] = bv;
}
break;
case LDAP_UNWILLING_TO_PERFORM:
/*
* FIXME: need to check if it may be considered
* legal to trim values when adding/modifying;
* it should be when searching (see ACLs).
*/
ch_free( a_vals[i].bv_val );
if (last > i ) {
a_vals[i] = a_vals[last];
}
a_vals[last].bv_len = 0;
a_vals[last].bv_val = NULL;
last--;
break;
}
}
return 0;
}