From: Howard Chu Date: Tue, 27 Sep 2005 16:15:59 +0000 (+0000) Subject: ITS#4025 add pretty/normal for pwdAttribute that recognizes descr's as X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~367 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=20cb8f49f9ffc5b7feddef8a104322313b842fe4;p=openldap ITS#4025 add pretty/normal for pwdAttribute that recognizes descr's as well as numeric OIDs --- diff --git a/servers/slapd/overlays/ppolicy.c b/servers/slapd/overlays/ppolicy.c index d68bd26683..0d87840a16 100644 --- a/servers/slapd/overlays/ppolicy.c +++ b/servers/slapd/overlays/ppolicy.c @@ -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 );