From 20cb8f49f9ffc5b7feddef8a104322313b842fe4 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 27 Sep 2005 16:15:59 +0000 Subject: [PATCH] ITS#4025 add pretty/normal for pwdAttribute that recognizes descr's as well as numeric OIDs --- servers/slapd/overlays/ppolicy.c | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) 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 ); -- 2.39.5