From 2ee43073e938d1a1091813faed099b9b2298be73 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 9 Feb 2009 05:38:30 +0000 Subject: [PATCH] ITS#5927 MicrosoftAD compatibility hack (YUCK) - treat '=' as '-' if defined in an attributeoption --- servers/slapd/ad.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index 9a7cea8316..e1dab72b3e 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -64,6 +64,8 @@ static Attr_option lang_option = { BER_BVC("lang-"), 1 }; static Attr_option *options = &lang_option; static int option_count = 1; +static int msad_range_hack = 0; + static Attr_option *ad_find_option_definition( const char *opt, int optlen ); static int ad_keystring( @@ -76,7 +78,9 @@ static int ad_keystring( } for( i=1; ibv_len; i++ ) { - if( !AD_CHAR( bv->bv_val[i] ) ) { + if( !AD_CHAR( bv->bv_val[i] )) { + if ( msad_range_hack && bv->bv_val[i] == '=' ) + continue; return 1; } } @@ -234,7 +238,8 @@ int slap_bv2ad( } else if ( ad_find_option_definition( opt, optlen ) ) { int i; - if( opt[optlen-1] == '-' ) { + if( opt[optlen-1] == '-' || + ( opt[optlen-1] == '=' && msad_range_hack )) { desc.ad_flags |= SLAP_DESC_TAG_RANGE; } @@ -1178,6 +1183,11 @@ ad_define_option( const char *name, const char *fname, int lineno ) optlen = 0; do { if ( !DESC_CHAR( name[optlen] ) ) { + /* allow trailing '=', same as '-' */ + if ( name[optlen] == '=' && !name[optlen+1] ) { + msad_range_hack = 1; + continue; + } Debug( LDAP_DEBUG_ANY, "%s: line %d: illegal option name \"%s\"\n", fname, lineno, name ); @@ -1204,7 +1214,8 @@ ad_define_option( const char *name, const char *fname, int lineno ) options[i].name.bv_val = ch_strdup( name ); options[i].name.bv_len = optlen; - options[i].prefix = (name[optlen-1] == '-'); + options[i].prefix = (name[optlen-1] == '-') || + (name[optlen-1] == '='); if ( i != option_count && options[i].prefix && -- 2.39.5