ITS#4025 add pretty/normal for pwdAttribute that recognizes descr's as

well as numeric OIDs
This commit is contained in:
Howard Chu 2005-09-27 16:15:59 +00:00
parent eab3e6b572
commit 20cb8f49f9

View file

@ -1739,6 +1739,44 @@ ppolicy_parseCtrl(
return LDAP_SUCCESS;
}
static int
attrPretty(
Syntax *syntax,
struct berval *val,
struct berval *out,
void *ctx )
{
AttributeDescription *ad = NULL;
const char *err;
int code;
code = slap_bv2ad( val, &ad, &err );
if ( !code ) {
ber_dupbv_x( out, &ad->ad_type->sat_cname, ctx );
}
return code;
}
static int
attrNormalize(
slap_mask_t use,
Syntax *syntax,
MatchingRule *mr,
struct berval *val,
struct berval *out,
void *ctx )
{
AttributeDescription *ad = NULL;
const char *err;
int code;
code = slap_bv2ad( val, &ad, &err );
if ( !code ) {
ber_str2bv_x( ad->ad_type->sat_oid, 0, 1, out, ctx );
}
return code;
}
static int
ppolicy_db_init(
BackendDB *be
@ -1758,6 +1796,20 @@ ppolicy_db_init(
return code;
}
}
{
Syntax *syn;
MatchingRule *mr;
syn = ch_malloc( sizeof( Syntax ));
*syn = *ad_pwdAttribute->ad_type->sat_syntax;
syn->ssyn_pretty = attrPretty;
ad_pwdAttribute->ad_type->sat_syntax = syn;
mr = ch_malloc( sizeof( MatchingRule ));
*mr = *ad_pwdAttribute->ad_type->sat_equality;
mr->smr_normalize = attrNormalize;
ad_pwdAttribute->ad_type->sat_equality = mr;
}
}
on->on_bi.bi_private = ch_calloc( sizeof(pp_info), 1 );