]> git.sur5r.net Git - openldap/commitdiff
SLAP_NVALUES:
authorKurt Zeilenga <kurt@openldap.org>
Thu, 27 Feb 2003 01:54:43 +0000 (01:54 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Thu, 27 Feb 2003 01:54:43 +0000 (01:54 +0000)
schema engine updated (but not schema routines so things don't run yet)
nvalues mostly populated, enough for tests 0-2 to pass
schema routines needs lots of work
modify/mods codes needs lots of work

25 files changed:
servers/slapd/acl.c
servers/slapd/ad.c
servers/slapd/at.c
servers/slapd/ava.c
servers/slapd/back-bdb/compare.c
servers/slapd/back-bdb/group.c
servers/slapd/back-bdb/search.c
servers/slapd/back-ldbm/group.c
servers/slapd/back-monitor/log.c
servers/slapd/compare.c
servers/slapd/dn.c
servers/slapd/entry.c
servers/slapd/filter.c
servers/slapd/filterentry.c
servers/slapd/matchedValues.c
servers/slapd/modify.c
servers/slapd/mods.c
servers/slapd/mra.c
servers/slapd/proto-slap.h
servers/slapd/schema_check.c
servers/slapd/schema_init.c
servers/slapd/schema_prep.c
servers/slapd/slap.h
servers/slapd/syntax.c
servers/slapd/value.c

index 4ca945e8dd0bbeff8a844cd3cb7b2c1626a8a727..404842ad1490a38d181bdb4ca22e2f609593a9cd 100644 (file)
@@ -889,8 +889,8 @@ dn_match_cleanup:;
                                at = attrs_find( at->a_next, b->a_dn_at ) )
                        {
                                if( value_find_ex( b->a_dn_at,
-                                       SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, at->a_vals, &bv )
-                                       == 0 )
+                                       SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
+                                       at->a_vals, &bv ) == 0 )
                                {
                                        /* found it */
                                        match = 1;
index 407b091cadf503595b36517f36e21ed1e615c749..cc3e7c1674a8fadcc73bf89e69618c8cf80ca66f 100644 (file)
@@ -845,3 +845,25 @@ ad_find_option_definition( const char *opt, int optlen )
        }
        return NULL;
 }
+
+MatchingRule *ad_mr(
+       AttributeDescription *ad,
+       unsigned usage )
+{
+       switch( usage & SLAP_MR_TYPE_MASK ) {
+       case SLAP_MR_NONE:
+       case SLAP_MR_EQUALITY:
+               return ad->ad_type->sat_equality;
+               break;
+       case SLAP_MR_ORDERING:
+               return ad->ad_type->sat_ordering;
+               break;
+       case SLAP_MR_SUBSTR:
+               return ad->ad_type->sat_substr;
+               break;
+       case SLAP_MR_EXT:
+       default:
+               assert( 0 /* ad_mr: bad usage */);
+       }
+       return NULL;
+}
index 5333e376dc76803ba4e0b95fc9620e474a54ce8c..d0b3e241d77f6dc95f46529dd4eee5019e222d0d 100644 (file)
@@ -485,6 +485,11 @@ at_add(
        }
 
        if ( sat->sat_ordering_oid ) {
+               if( !sat->sat_equality ) {
+                       *err = sat->sat_ordering_oid;
+                       return SLAP_SCHERR_ATTR_BAD_MR;
+               }
+
                mr = mr_find(sat->sat_ordering_oid);
 
                if( mr == NULL ) {
@@ -520,6 +525,11 @@ at_add(
        }
 
        if ( sat->sat_substr_oid ) {
+               if( !sat->sat_equality ) {
+                       *err = sat->sat_substr_oid;
+                       return SLAP_SCHERR_ATTR_BAD_MR;
+               }
+
                mr = mr_find(sat->sat_substr_oid);
 
                if( mr == NULL ) {
@@ -537,9 +547,7 @@ at_add(
                 * syntax and compat syntaxes instead of those
                 * associated with the substrings rule.
                 */
-               if( sat->sat_equality &&
-                       sat->sat_syntax != sat->sat_equality->smr_syntax )
-               {
+               if( sat->sat_syntax != sat->sat_equality->smr_syntax ) {
                        if( sat->sat_equality->smr_compat_syntaxes == NULL ) {
                                *err = sat->sat_substr_oid;
                                return SLAP_SCHERR_ATTR_BAD_MR;
index 01287a0b4f040dd17cfc99dbc327018ba0673c95..4a30f6417419b699d9f9acc606c66d5bafbb48b6 100644 (file)
@@ -63,8 +63,14 @@ get_ava(
                return rc;
        }
 
+#ifdef SLAP_NVALUES
+       rc = asserted_value_validate_normalize(
+               aa->aa_desc, ad_mr(aa->aa_desc, usage),
+               usage, &value, &aa->aa_value, text );
+#else
        rc = value_validate_normalize( aa->aa_desc, usage,
                &value, &aa->aa_value, text );
+#endif
 
        if( rc != LDAP_SUCCESS ) {
                ch_free( aa );
index df74448224530dea8c1c4c1677371bfc22ba34cb..4f2ab650c55517873d53e7e772fc737b8b8e2e77 100644 (file)
@@ -125,7 +125,14 @@ dn2entry_retry:
        {
                rc = LDAP_COMPARE_FALSE;
 
-               if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) {
+#ifdef SLAP_NVALUES
+               if ( value_find_ex( ava->aa_desc,
+                       SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
+                       a->a_vals, &ava->aa_value ) == 0 )
+#else
+               if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )
+#endif
+               {
                        rc = LDAP_COMPARE_TRUE;
                        break;
                }
index 4113eaa93687091dd6ecd00409ce0583b0126f82..10b3b171061f872e1a835264a75695a350d56863 100644 (file)
@@ -216,10 +216,7 @@ dn2entry_retry:
                group_oc_name, group_at_name, 0 ); 
 #endif
 
-       if( value_find_ex( group_at,
-               SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
-               attr->a_vals, op_ndn ) != LDAP_SUCCESS )
-       {
+       if( value_find_ex( group_at, 0, attr->a_vals, op_ndn ) != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( BACK_BDB, DETAIL1, 
                        "bdb_group: \"%s\" not in \"%s\": %s\n",
index feea82ee22d3745101c07f1e415dcd4949e79cf6..ffe0b4eb17f8a04e2af78f1d72aa55774c3222b3 100644 (file)
@@ -1226,8 +1226,7 @@ bdb_build_lcup_update_ctrl(
                                ber_dupbv( latest_entrycsn_bv, &entrycsn_bv );
                        } else {
                                res = value_match( &ret, desc,
-                                       desc->ad_type->sat_ordering,
-                                       SLAP_MR_ASSERTION_SYNTAX_MATCH,
+                                       desc->ad_type->sat_ordering, 0,
                                        &entrycsn_bv, latest_entrycsn_bv, &text );
                                if ( res != LDAP_SUCCESS ) {
                                        ret = 0;
@@ -1368,8 +1367,7 @@ bdb_build_sync_state_ctrl(
                                ber_dupbv( latest_entrycsn_bv, &entrycsn_bv );
                        } else {
                                res = value_match( &ret, desc,
-                                               desc->ad_type->sat_ordering,
-                                               SLAP_MR_ASSERTION_SYNTAX_MATCH,
+                                               desc->ad_type->sat_ordering, 0,
                                                &entrycsn_bv, latest_entrycsn_bv, &text );
                                if ( res != LDAP_SUCCESS ) {
                                        ret = 0;
index 1bf18026451760a9eb1754c11b669479bf6824aa..0c3f6c29b4cd5e5ec42f298e24bd63574f861148 100644 (file)
@@ -178,9 +178,7 @@ ldbm_back_group(
 #endif
 
 
-       if( value_find_ex( group_at, SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
-               attr->a_vals, op_ndn ) != LDAP_SUCCESS )
-       {
+       if( value_find_ex( group_at, 0, attr->a_vals, op_ndn ) != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( BACK_LDBM, DETAIL1, 
                        "ldbm_back_group: \"%s\" not in \"%s\": %s\n",
index dcc34c4bb351b9c3a0fb5dc8134a525af40a2a8f..2fd6e4d454c53d7e586ef7906777a3de47cf4760 100644 (file)
@@ -332,7 +332,11 @@ add_values( Entry *e, Modification *mod, int *newlevel )
                        for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
                                int match;
                                int rc = value_match( &match, mod->sm_desc, mr,
+#ifdef SLAP_NVALUES
+                                       0,
+#else
                                        SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
+#endif
                                        &a->a_vals[j], &asserted, &text );
 
                                if ( rc == LDAP_SUCCESS && match == 0 ) {
@@ -411,7 +415,11 @@ delete_values( Entry *e, Modification *mod, int *newlevel )
                for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
                        int match;
                        int rc = value_match( &match, mod->sm_desc, mr,
+#ifdef SLAP_NVALUES
+                               0,
+#else
                                SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
+#endif
                                &a->a_vals[j], &asserted, &text );
 
                        if( rc == LDAP_SUCCESS && match != 0 ) {
index 67651aa87792551a012faff9a55288bc61a60d2d..bca36de6faacf06c6e609b333fecd34aa80020b9 100644 (file)
@@ -143,8 +143,15 @@ do_compare(
                goto cleanup;
        }
 
+#ifdef SLAP_NVALUES
+       rc = asserted_value_validate_normalize( ava.aa_desc,
+               ava.aa_desc->ad_type->sat_equality,
+               SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
+               &value, &ava.aa_value, &text );
+#else
        rc = value_validate_normalize( ava.aa_desc, SLAP_MR_EQUALITY,
                &value, &ava.aa_value, &text );
+#endif
        if( rc != LDAP_SUCCESS ) {
                send_ldap_result( conn, op, rc, NULL, text, NULL, NULL );
                goto cleanup;
@@ -347,7 +354,15 @@ static int compare_entry(
        {
                rc = LDAP_COMPARE_FALSE;
 
-               if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 ) {
+#ifdef SLAP_NVALUES
+               if ( value_find_ex( ava->aa_desc,
+                       SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
+                       a->a_nvals ? a->a_nvals : a->a_vals,
+                       &ava->aa_value ) == 0 )
+#else
+               if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )
+#endif
+               {
                        rc = LDAP_COMPARE_TRUE;
                        break;
                }
index 148d8155e9756adda8cd41f9053395a96af96769..2b76efc5865bf68111fd588939b5a85941e21abe 100644 (file)
@@ -241,8 +241,11 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
                        LDAPAVA                 *ava = rdn[ 0 ][ iAVA ];
                        AttributeDescription    *ad;
                        slap_syntax_validate_func *validf = NULL;
+#ifdef SLAP_NVALUES
+                       slap_mr_normalize_func *normf = NULL;
+#endif
                        slap_syntax_transform_func *transf = NULL;
-                       MatchingRule *mr;
+                       MatchingRule *mr = NULL;
                        struct berval           bv = { 0, NULL };
                        int                     do_sort = 0;
 
@@ -267,17 +270,19 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
 
                        if( ava->la_flags & LDAP_AVA_BINARY ) {
                                /* AVA is binary encoded, don't muck with it */
-                               validf = NULL;
-                               transf = NULL;
-                               mr = NULL;
                        } else if( flags & SLAP_LDAPDN_PRETTY ) {
-                               validf = NULL;
                                transf = ad->ad_type->sat_syntax->ssyn_pretty;
-                               mr = NULL;
-                       } else {
+                               if( !transf ) {
+                                       validf = ad->ad_type->sat_syntax->ssyn_validate;
+                               }
+                       } else { /* normalization */
                                validf = ad->ad_type->sat_syntax->ssyn_validate;
-                               transf = ad->ad_type->sat_syntax->ssyn_normalize;
                                mr = ad->ad_type->sat_equality;
+#ifdef SLAP_NVALUES
+                               if( mr ) normf = mr->smr_normalize;
+#else
+                               transf = ad->ad_type->sat_syntax->ssyn_normalize;
+#endif
                        }
 
                        if ( validf ) {
@@ -294,7 +299,11 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
 
                        if ( transf ) {
                                /*
+#ifdef SLAP_NVALUES
+                                * transform value by pretty function
+#else
                                 * transform value by normalize/pretty function
+#endif
                                 *      if value is empty, use empty_bv
                                 */
                                rc = ( *transf )( ad->ad_type->sat_syntax,
@@ -308,6 +317,27 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
                                }
                        }
 
+#ifdef SLAP_NVALUES
+                       if ( normf ) {
+                               /*
+                                * normalize value
+                                *      if value is empty, use empty_bv
+                                */
+                               rc = ( *normf )(
+                                       0,
+                                       ad->ad_type->sat_syntax,
+                                       mr,
+                                       ava->la_value.bv_len
+                                               ? &ava->la_value
+                                               : (struct berval *) &slap_empty_bv,
+                                       &bv );
+                       
+                               if ( rc != LDAP_SUCCESS ) {
+                                       return LDAP_INVALID_SYNTAX;
+                               }
+                       }
+
+#else
                        if( mr && ( mr->smr_usage & SLAP_MR_DN_FOLD ) ) {
                                char *s = bv.bv_val;
 
@@ -317,6 +347,7 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags )
                                }
                                free( s );
                        }
+#endif
 
                        if( bv.bv_val ) {
                                free( ava->la_value.bv_val );
index f4dba0124bf4763c16a97185a6435d6e90c569bd..02683226849a75116c2a51ff0aa4708177a43441 100644 (file)
@@ -244,20 +244,21 @@ str2entry( char *s )
                nvals[0].bv_val = NULL;
 
                if( ad->ad_type->sat_equality &&
-                       ad->ad_type->sat_equality->smr_match &&
-                       ad->ad_type->sat_syntax->ssyn_normalize )
+                       ad->ad_type->sat_equality->smr_normalize )
                {
-                       rc = ad->ad_type->sat_syntax->ssyn_normalize(
+                       rc = ad->ad_type->sat_equality->smr_normalize(
+                               SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
                                ad->ad_type->sat_syntax,
+                               ad->ad_type->sat_equality,
                                &vals[0], &nvals[0] );
 
                        if( rc ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG( OPERATION, DETAIL1,
-                                       "str2entry:  NULL (ssyn_normalize %d)\n" , rc, 0, 0 );
+                                       "str2entry:  NULL (smr_normalize %d)\n" , rc, 0, 0 );
 #else
                                Debug( LDAP_DEBUG_ANY,
-                                       "<= str2entry NULL (ssyn_normalize %d)\n", rc, 0, 0 );
+                                       "<= str2entry NULL (smr_normalize %d)\n", rc, 0, 0 );
 #endif
 
                                entry_free( e );
@@ -683,24 +684,25 @@ int entry_decode(struct berval *bv, Entry **e)
 
 #ifdef SLAP_NVALUES
                if( count && ad->ad_type->sat_equality &&
-                       ad->ad_type->sat_equality->smr_match &&
-                       ad->ad_type->sat_syntax->ssyn_normalize )
+                       ad->ad_type->sat_equality->smr_normalize )
                {
                        a->a_nvals = ch_malloc((count+1)*sizeof(struct berval));
 
                        for(j=0; j<count; j++) {
-                               rc = ad->ad_type->sat_syntax->ssyn_normalize(
+                               rc = ad->ad_type->sat_equality->smr_normalize(
+                                       SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
                                        ad->ad_type->sat_syntax,
+                                       ad->ad_type->sat_equality,
                                        &a->a_vals[j], &a->a_nvals[j] );
 
                                if( rc ) {
 #ifdef NEW_LOGGING
                                        LDAP_LOG( OPERATION, DETAIL1,
-                                               "entry_decode: NULL (ssyn_normalize %d)\n",
+                                               "entry_decode: NULL (smr_normalize %d)\n",
                                                rc, 0, 0 );
 #else
                                        Debug( LDAP_DEBUG_ANY,
-                                               "<= entry_decode NULL (ssyn_normalize %d)\n",
+                                               "<= entry_decode NULL (smr_normalize %d)\n",
                                                rc, 0, 0 );
 #endif
 
index 45a8d190e9b343bb9488670d3cb149dd4ab92356..137102b940ce8441a0df61085993b5fd3c8a0b4f 100644 (file)
@@ -414,6 +414,15 @@ get_substring_filter(
                        goto return_error;
                }
 
+#ifdef SLAP_NVALUES
+               /* validate using equality matching rule validator! */
+               rc = asserted_value_validate_normalize(
+                       f->f_sub_desc, f->f_sub_desc->ad_type->sat_substr,
+                       usage, &value, &bv, text );
+               if( rc != LDAP_SUCCESS ) {
+                       goto return_error;
+               }
+#else
                /* validate using equality matching rule validator! */
                rc = value_validate( f->f_sub_desc->ad_type->sat_equality,
                        &value, text );
@@ -426,6 +435,7 @@ get_substring_filter(
                if( rc != LDAP_SUCCESS ) {
                        goto return_error;
                }
+#endif
 
                value = bv;
 
@@ -1423,6 +1433,15 @@ get_substring_vrFilter(
                        goto return_error;
                }
 
+#ifdef SLAP_NVALUES
+               /* validate using equality matching rule validator! */
+               rc = asserted_value_validate_normalize(
+                       vrf->vrf_sub_desc, vrf->vrf_sub_desc->ad_type->sat_substr,
+                       usage, &value, &bv, text );
+               if( rc != LDAP_SUCCESS ) {
+                       goto return_error;
+               }
+#else
                /* valiate using equality matching rule validator! */
                rc = value_validate( vrf->vrf_sub_desc->ad_type->sat_equality,
                        &value, text );
@@ -1435,6 +1454,7 @@ get_substring_vrFilter(
                if( rc != LDAP_SUCCESS ) {
                        goto return_error;
                }
+#endif
 
                value = bv;
 
index f01e7a822b93c6dea6f7591cd6192cf95c15160e..f1375564614182ecb290200ce2436b862ac3cb19 100644 (file)
@@ -237,8 +237,7 @@ static int test_mra_filter(
                                int rc;
                                const char *text;
        
-                               rc = value_match( &ret, a->a_desc, mra->ma_rule,
-                                       SLAP_MR_ASSERTION_SYNTAX_MATCH,
+                               rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
                                        bv, &mra->ma_value, &text );
        
                                if( rc != LDAP_SUCCESS ) {
@@ -266,9 +265,15 @@ static int test_mra_filter(
                        }
 
                        /* normalize for equality */
+#ifdef SLAP_NVALUES
+                       rc = asserted_value_validate_normalize( a->a_desc, mra->ma_rule,
+                               SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
+                               &mra->ma_value, &value, &text );
+#else
                        rc = value_validate_normalize( a->a_desc, 
                                SLAP_MR_EQUALITY,
                                &mra->ma_value, &value, &text );
+#endif
                        if ( rc != LDAP_SUCCESS ) {
                                continue;
                        }
@@ -284,8 +289,7 @@ static int test_mra_filter(
                                int ret;
                                int rc;
        
-                               rc = value_match( &ret, a->a_desc, mra->ma_rule,
-                                       SLAP_MR_ASSERTION_SYNTAX_MATCH,
+                               rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
                                        bv, &value, &text );
        
                                if( rc != LDAP_SUCCESS ) {
@@ -341,8 +345,15 @@ static int test_mra_filter(
                                        }
 
                                        /* normalize for equality */
+#ifdef SLAP_NVALUES
+                                       rc = asserted_value_validate_normalize( ad,
+                                               mra->ma_rule,
+                                               SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
+                                               &mra->ma_value, &value, &text );
+#else
                                        rc = value_validate_normalize( ad, SLAP_MR_EQUALITY,
                                                &mra->ma_value, &value, &text );
+#endif
                                        if ( rc != LDAP_SUCCESS ) {
                                                continue;
                                        }
@@ -355,8 +366,7 @@ static int test_mra_filter(
                                }
 
                                /* check match */
-                               rc = value_match( &ret, ad, mra->ma_rule,
-                                       SLAP_MR_ASSERTION_SYNTAX_MATCH,
+                               rc = value_match( &ret, ad, mra->ma_rule, 0,
                                        bv, &value, &text );
 
                                if( rc != LDAP_SUCCESS ) {
@@ -429,8 +439,7 @@ test_ava_filter(
                        int rc;
                        const char *text;
 
-                       rc = value_match( &ret, a->a_desc, mr,
-                               SLAP_MR_ASSERTION_SYNTAX_MATCH,
+                       rc = value_match( &ret, a->a_desc, mr, 0,
                                bv, &ava->aa_value, &text );
 
                        if( rc != LDAP_SUCCESS ) {
@@ -661,8 +670,7 @@ test_substrings_filter(
                        int rc;
                        const char *text;
 
-                       rc = value_match( &ret, a->a_desc, mr,
-                               SLAP_MR_ASSERTION_SYNTAX_MATCH,
+                       rc = value_match( &ret, a->a_desc, mr, 0,
                                bv, f->f_sub, &text );
 
                        if( rc != LDAP_SUCCESS ) {
index ca028564fe024deddafb05bd5b8316ed83c03d3e..17fe275a52ee358afdd43bc446aba6c3ab5623d4 100644 (file)
@@ -240,8 +240,8 @@ test_ava_vrFilter(
                        int rc;
                        const char *text;
 
-                       rc = value_match( &ret, a->a_desc, mr, 
-                               SLAP_MR_ASSERTION_SYNTAX_MATCH, bv, &ava->aa_value, &text );
+                       rc = value_match( &ret, a->a_desc, mr, 0,
+                               bv, &ava->aa_value, &text );
                        if( rc != LDAP_SUCCESS ) {
                                return rc;
                        }
@@ -326,8 +326,7 @@ test_substrings_vrFilter(
                        int rc;
                        const char *text;
 
-                       rc = value_match( &ret, a->a_desc, mr,
-                               SLAP_MR_ASSERTION_SYNTAX_MATCH,
+                       rc = value_match( &ret, a->a_desc, mr, 0,
                                bv, vrf->vrf_sub, &text );
 
                        if( rc != LDAP_SUCCESS ) {
@@ -365,6 +364,7 @@ test_mra_vrFilter(
                        value = mra->ma_value;
 
                } else {
+                       int rc;
                        const char      *text = NULL;
 
                        /* check if matching is appropriate */
@@ -373,14 +373,19 @@ test_mra_vrFilter(
                                continue;
                        }
 
+#ifdef SLAP_NVALUES
+                       rc = asserted_value_validate_normalize( a->a_desc, mra->ma_rule,
+                               SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
+                               &mra->ma_value, &value, &text );
+#else
                        /* normalize for equality */
-                       if ( value_validate_normalize( a->a_desc, 
+                       rc = value_validate_normalize( a->a_desc, 
                                SLAP_MR_EQUALITY,
                                &mra->ma_value, &value,
-                               &text ) != LDAP_SUCCESS ) {
-                               continue;
-                       }
+                               &text );
+#endif
 
+                       if( rc != LDAP_SUCCESS ) continue;
                }
 
                for ( bv = a->a_vals, j = 0; bv->bv_val != NULL; bv++, j++ ) {
@@ -388,11 +393,8 @@ test_mra_vrFilter(
                        int rc;
                        const char *text;
 
-                       rc = value_match( &ret, a->a_desc, mra->ma_rule,
-                               SLAP_MR_ASSERTION_SYNTAX_MATCH,
-                               bv, &value,
-                               &text );
-
+                       rc = value_match( &ret, a->a_desc, mra->ma_rule, 0,
+                               bv, &value, &text );
                        if( rc != LDAP_SUCCESS ) {
                                return rc;
                        }
index 94d642c2b557e0b0ae7746ef31306a8ce8434f16..a24e250abb05eee0c7c87f8efa86e0b0db33ccf4 100644 (file)
@@ -609,13 +609,14 @@ int slap_mods_check(
 
 #ifdef SLAP_NVALUES
                        if( nvals && ad->ad_type->sat_equality &&
-                               ad->ad_type->sat_equality->smr_match &&
-                               ad->ad_type->sat_syntax->ssyn_normalize )
+                               ad->ad_type->sat_equality->smr_normalize )
                        {
                                ml->sml_nvalues = ch_malloc( (nvals+1)*sizeof(struct berval) );
                                for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
-                                       rc = ad->ad_type->sat_syntax->ssyn_normalize(
+                                       rc = ad->ad_type->sat_equality->smr_normalize(
+                                               0,
                                                ad->ad_type->sat_syntax,
+                                               ad->ad_type->sat_equality,
                                                &ml->sml_values[nvals], &ml->sml_nvalues[nvals] );
                                        if( rc ) {
 #ifdef NEW_LOGGING
index d83ed68b7175a555a0f400256af6f865d6a218ca..21dc31669d1321a907bb8eaf36cbdc1f0f761e31 100644 (file)
@@ -30,6 +30,9 @@ modify_check_duplicates(
 {
        int             i, j, numvals = 0, nummods,
                        rc = LDAP_SUCCESS, matched;
+#ifdef SLAP_NVALUES
+       /* needs major reworking */
+#else
        BerVarray       nvals = NULL, nmods = NULL;
 
        /*
@@ -121,23 +124,24 @@ modify_check_duplicates(
                goto return_results;
        }
 
-       for ( i = 0; mods[ i ].bv_val != NULL; i++ ) {
+       for ( i=0; mods[i].bv_val != NULL; i++ ) {
                rc = value_normalize( ad, SLAP_MR_EQUALITY,
-                       &mods[ i ], &nmods[ i ], text );
+                       &mods[i], &nmods[i], text );
 
                if ( rc != LDAP_SUCCESS ) {
-                       nmods[ i ].bv_val = NULL;
+                       nmods[i].bv_val = NULL;
                        goto return_results;
                }
 
                if ( numvals > 0 && numvals < nummods ) {
-                       for ( matched = 0, j = 0; nvals[ j ].bv_val; j++ ) {
+                       for ( matched=0, j=0; nvals[j].bv_val; j++ ) {
                                int match;
 
                                rc = (*mr->smr_match)( &match,
                                        SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
                                        ad->ad_type->sat_syntax,
                                        mr, &nmods[ i ], &nvals[ j ] );
+
                                if ( rc != LDAP_SUCCESS ) {
                                        nmods[ i + 1 ].bv_val = NULL;
                                        *text = textbuf;
@@ -270,6 +274,7 @@ return_results:;
                ber_bvarray_free( nmods );
        }
 
+#endif
        return rc;
 }
 
@@ -324,8 +329,7 @@ modify_add_values(
                        /* test asserted values against existing values */
                        if( a ) {
                                for( matched = 0, j = 0; a->a_vals[j].bv_val != NULL; j++ ) {
-                                       if ( bvmatch( &mod->sm_bvalues[i],
-                                               &a->a_vals[j] ) ) {
+                                       if ( bvmatch( &mod->sm_bvalues[i], &a->a_vals[j] ) ) {
                                                if ( permissive ) {
                                                        matched++;
                                                        continue;
@@ -389,24 +393,49 @@ modify_add_values(
 
                int             rc;
 
-               if ( mod->sm_bvalues[ 1 ].bv_val == 0 ) {
+               if ( mod->sm_bvalues[1].bv_val == 0 ) {
                        if ( a != NULL ) {
                                struct berval   asserted;
                                int             i;
 
+#ifndef SLAP_NVALUES
                                rc = value_normalize( mod->sm_desc, SLAP_MR_EQUALITY,
                                        &mod->sm_bvalues[ 0 ], &asserted, text );
-
                                if ( rc != LDAP_SUCCESS ) {
                                        return rc;
                                }
+#endif
 
                                for ( matched = 0, i = 0; a->a_vals[ i ].bv_val; i++ ) {
                                        int     match;
 
+#ifdef SLAP_NVALUES
+                                       if( mod->sm_nvalues ) {
+                                               rc = value_match( &match, mod->sm_desc, mr,
+                                                       SLAP_MR_EQUALITY
+                                                               | SLAP_MR_VALUE_OF_ASSERTION_SYNTAX
+                                                               | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
+                                                               | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
+                                                       &a->a_nvals[i],
+                                                       &mod->sm_nvalues[0],
+                                                       text );
+
+                                       } else {
+                                               rc = value_match( &match, mod->sm_desc, mr,
+                                                       SLAP_MR_EQUALITY
+                                                               | SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
+                                                       &a->a_vals[i],
+                                                       &mod->sm_values[0],
+                                                       text );
+                                       }
+
+#else
                                        rc = value_match( &match, mod->sm_desc, mr,
                                                SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
-                                               &a->a_vals[ i ], &asserted, text );
+                                               &a->a_vals[i],
+                                               &asserted,
+                                               text );
+#endif
 
                                        if( rc == LDAP_SUCCESS && match == 0 ) {
                                                if ( permissive ) {
@@ -519,6 +548,9 @@ modify_delete_values(
                return LDAP_NO_SUCH_ATTRIBUTE;
        }
 
+#ifdef SLAP_NVALUES
+       nvals = a->a_nvals;
+#else
        /* find each value to delete */
        for ( j = 0; a->a_vals[ j ].bv_val != NULL; j++ )
                /* count existing values */ ;
@@ -545,10 +577,12 @@ modify_delete_values(
                        goto return_results;
                }
        }
+#endif
 
        for ( i = 0; mod->sm_bvalues[ i ].bv_val != NULL; i++ ) {
-               struct  berval asserted;
                int     found = 0;
+#ifndef SLAP_NVALUES
+               struct  berval asserted;
 
                /* normalize the value to be deleted */
                rc = value_normalize( mod->sm_desc, SLAP_MR_EQUALITY,
@@ -557,6 +591,7 @@ modify_delete_values(
                if( rc != LDAP_SUCCESS ) {
                        goto return_results;
                }
+#endif
 
                /* search it */
                for ( j = 0; nvals[ j ].bv_val != NULL; j++ ) {
@@ -566,13 +601,34 @@ modify_delete_values(
                                continue;
                        }
 
+#ifdef SLAP_NVALUES
+                       if( mod->sm_nvalues ) {
+                               rc = (*mr->smr_match)( &match,
+                                       SLAP_MR_VALUE_OF_ASSERTION_SYNTAX
+                                               | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH
+                                               | SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH,
+                                       a->a_desc->ad_type->sat_syntax,
+                                       mr, &nvals[ j ],
+                                       &mod->sm_nvalues[i] );
+                       } else {
+                               rc = (*mr->smr_match)( &match,
+                                       SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
+                                       a->a_desc->ad_type->sat_syntax,
+                                       mr, &nvals[ j ],
+                                       &mod->sm_values[i] );
+                       }
+#else
                        rc = (*mr->smr_match)( &match,
                                SLAP_MR_ATTRIBUTE_SYNTAX_MATCH,
                                a->a_desc->ad_type->sat_syntax,
-                               mr, &nvals[ j ], &asserted );
+                               mr, &nvals[ j ],
+                               &asserted );
+#endif
 
                        if ( rc != LDAP_SUCCESS ) {
+#ifndef SLAP_NVALUES
                                free( asserted.bv_val );
+#endif
                                *text = textbuf;
                                snprintf( textbuf, textlen,
                                        "%s: matching rule failed",
@@ -593,7 +649,9 @@ modify_delete_values(
                        break;
                }
 
+#ifndef SLAP_NVALUES
                free( asserted.bv_val );
+#endif
 
                if ( found == 0 ) {
                        *text = textbuf;
index 79c35c4674586753e0bf8f8b4bccb4624dde1a79..a8f2d7fcfd87f14f0832e85f3d843867cbe0ec93 100644 (file)
@@ -218,6 +218,7 @@ get_mra(
                        return LDAP_INAPPROPRIATE_MATCHING;
                }
 
+#ifndef SLAP_NVALUES
                /*
                 * OK, if no matching rule, normalize for equality, otherwise
                 * normalize for the matching rule.
@@ -232,8 +233,21 @@ get_mra(
                if ( rc == LDAP_SUCCESS ) {
                        ber_dupbv( &ma->ma_value, &value );
                }
+#endif
+       }
 
+#ifdef SLAP_NVALUES
+       /*
+        * Normalize per matching rule
+        */
+       rc = asserted_value_validate_normalize( ma->ma_desc,
+               ma->ma_rule,
+               SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
+               &ma->ma_value, &value, text );
+       if ( rc == LDAP_SUCCESS ) {
+               ber_dupbv( &ma->ma_value, &value );
        }
+#endif
 
        if( rc != LDAP_SUCCESS ) {
                mra_free( ma, 1 );
index c85866f60c81cc705d2408a98ef4be454e3da4f4..6a1ff16cae892c88bca12e912d4e4e4d0522d1f5 100644 (file)
@@ -88,6 +88,10 @@ LDAP_SLAPD_F (int) an_find LDAP_P(( AttributeName *a, struct berval *s ));
 LDAP_SLAPD_F (int) ad_define_option LDAP_P(( const char *name,
        const char *fname, int lineno ));
 
+LDAP_SLAPD_F (MatchingRule *) ad_mr(
+       AttributeDescription *ad,
+       unsigned usage );
+
 /*
  * add.c
  */
@@ -1065,6 +1069,15 @@ LDAP_SLAPD_F (void) slap_init_user LDAP_P(( char *username, char *groupname ));
 /*
  * value.c
  */
+#ifdef SLAP_NVALUES
+LDAP_SLAPD_F (int) asserted_value_validate_normalize LDAP_P((
+       AttributeDescription *ad,
+       MatchingRule *mr,
+       unsigned usage,
+       struct berval *in,
+       struct berval *out,
+       const char ** text ));
+#else
 LDAP_SLAPD_F (int) value_validate LDAP_P((
        MatchingRule *mr,
        struct berval *in,
@@ -1081,6 +1094,9 @@ LDAP_SLAPD_F (int) value_validate_normalize LDAP_P((
        struct berval *in,
        struct berval *out,
        const char ** text ));
+#define value_find(ad,values,value) (value_find_ex((ad),0,(values),(value)))
+#endif
+
 LDAP_SLAPD_F (int) value_match LDAP_P((
        int *match,
        AttributeDescription *ad,
@@ -1089,12 +1105,12 @@ LDAP_SLAPD_F (int) value_match LDAP_P((
        struct berval *v1,
        void *v2,
        const char ** text ));
-#define value_find(ad,values,value) (value_find_ex((ad),0,(values),(value)))
 LDAP_SLAPD_F (int) value_find_ex LDAP_P((
        AttributeDescription *ad,
        unsigned flags,
        BerVarray values,
        struct berval *value ));
+
 LDAP_SLAPD_F (int) value_add LDAP_P((
        BerVarray *vals,
        BerVarray addvals ));
index 6125db68117076cc346cbdaf406dfca06a70013a..3aca7b68b466950b9b725aed5e938cb0e7cc9a3b 100644 (file)
@@ -224,7 +224,7 @@ entry_schema_check(
 
        /* naming check */
        rc = entry_naming_check( e, text, textbuf, textlen );
-       if ( rc != LDAP_SUCCESS ) {
+       if( rc != LDAP_SUCCESS ) {
                return rc;
        }
 
@@ -849,7 +849,15 @@ entry_naming_check(
                        break;
                }
 
-               if ( value_find( desc, attr->a_vals, &ava->la_value ) != 0 ) {
+#ifdef SLAP_NVALUES
+               if ( value_find_ex( desc,
+                       SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH.
+                       attr->a_nvals ? attr->a_nvals : attr->a_vals,
+                       &ava->la_value ) != 0 )
+#else
+               if ( value_find( desc, attr->a_vals, &ava->la_value ) != 0 )
+#endif
+               {
                        snprintf( textbuf, textlen, 
                                "value of naming attribute '%s' is not present in entry",
                                ava->la_attr.bv_val );
index 53cdb6a6f2bc9a20c8221cefdfcc662aa12d3b9c..1822e719e5372ae22cb9f04343bb55bdd025526f 100644 (file)
 #define HASH_Update(c,buf,len) lutil_HASHUpdate(c,buf,len)
 #define HASH_Final(d,c)                        lutil_HASHFinal(d,c)
 
+#ifdef SLAP_NVALUES
+#define SLAP_MR_DN_FOLD (0) /* TO BE DELETED */
+#endif
+
 /* recycled validatation routines */
 #define berValidate                                            blobValidate
 
@@ -2983,11 +2987,13 @@ static int caseIgnoreIA5Indexer(
                        if( rc != LDAP_SUCCESS ) {
                                break;
                        }
+#ifndef SLAP_NVALUES
                } else if ( mr->smr_syntax->ssyn_normalize ) {
                        rc = (mr->smr_syntax->ssyn_normalize)( syntax, &values[i], &value );
                        if( rc != LDAP_SUCCESS ) {
                                break;
                        }
+#endif
                } else {
                        ber_dupbv( &value, &values[i] );
                }
index 9b1dbb57e0dc80ef525d779f9db1f8f7b389eb28..4d13356fb08b6bffd9231f4afa64d63c006e5e3a 100644 (file)
@@ -90,11 +90,15 @@ objectSubClassMatch(
                return SLAPD_COMPARE_UNDEFINED;
        }
 
+#ifdef SLAP_NVALUES
+       assert(0 /* FIX ME */);
+#else
        if( SLAP_IS_MR_ATTRIBUTE_SYNTAX_MATCH( flags ) ) {
                *matchp = ( asserted != oc );
        } else {
                *matchp = !is_object_subclass( asserted, oc );
        }
+#endif
 
 #if OCDEBUG
 #ifdef NEW_LOGGING
index bf4ab72477f6a3639e03807d2d31923b38f92bd2..9dea20e0aacbf203ddce887ed69de49a0a32f87d 100644 (file)
@@ -316,7 +316,9 @@ typedef struct slap_syntax {
 #define SLAP_SYNTAX_HIDE       0x8000U /* hide (do not publish) */
 
        slap_syntax_validate_func       *ssyn_validate;
+#ifndef SLAP_NVALUES
        slap_syntax_transform_func      *ssyn_normalize;
+#endif
        slap_syntax_transform_func      *ssyn_pretty;
 
 #ifdef SLAPD_BINARY_CONVERSION
@@ -338,7 +340,11 @@ typedef struct slap_syntax_defs_rec {
        char *sd_desc;
        int sd_flags;
        slap_syntax_validate_func *sd_validate;
+#ifdef SLAP_NVALUES
+       slap_syntax_transform_func *sd_normalizeXXX; /* to be deleted */
+#else
        slap_syntax_transform_func *sd_normalize;
+#endif
        slap_syntax_transform_func *sd_pretty;
 #ifdef SLAPD_BINARY_CONVERSION
        slap_syntax_transform_func *sd_ber2str;
@@ -410,23 +416,27 @@ typedef struct slap_matching_rule {
 
 #define SLAP_MR_HIDE                   0x8000U
 
-#define SLAP_MR_TYPE_MASK              0x0F00U
-#define SLAP_MR_SUBTYPE_MASK   0x00F0U
-#define SLAP_MR_USAGE                  0x000FU
+#define SLAP_MR_TYPE_MASK              0xF000U
+#define SLAP_MR_SUBTYPE_MASK   0x0F00U
+#define SLAP_MR_USAGE                  0x00FFU
 
 #define SLAP_MR_NONE                   0x0000U
-#define SLAP_MR_EQUALITY               0x0100U
-#define SLAP_MR_ORDERING               0x0200U
-#define SLAP_MR_SUBSTR                 0x0400U
-#define SLAP_MR_EXT                            0x0800U /* implicitly extensible */
+#define SLAP_MR_EQUALITY               0x1000U
+#define SLAP_MR_ORDERING               0x2000U
+#define SLAP_MR_SUBSTR                 0x4000U
+#define SLAP_MR_EXT                            0x8000U /* implicitly extensible */
+
+#define SLAP_MR_EQUALITY_APPROX        ( SLAP_MR_EQUALITY | 0x0100U )
 
-#define SLAP_MR_EQUALITY_APPROX        ( SLAP_MR_EQUALITY | 0x0010U )
-#define SLAP_MR_DN_FOLD                        0x0008U
+#define SLAP_MR_SUBSTR_INITIAL ( SLAP_MR_SUBSTR | 0x0100U )
+#define SLAP_MR_SUBSTR_ANY             ( SLAP_MR_SUBSTR | 0x0200U )
+#define SLAP_MR_SUBSTR_FINAL   ( SLAP_MR_SUBSTR | 0x0400U )
 
-#define SLAP_MR_SUBSTR_INITIAL ( SLAP_MR_SUBSTR | 0x0010U )
-#define SLAP_MR_SUBSTR_ANY             ( SLAP_MR_SUBSTR | 0x0020U )
-#define SLAP_MR_SUBSTR_FINAL   ( SLAP_MR_SUBSTR | 0x0040U )
+#ifndef SLAP_NVALUES
+#define SLAP_MR_DN_FOLD                        0x0080U
+#endif
 
+#ifndef SLAP_NVALUES
 /*
  * normally the asserted value is expected to conform to
  * assertion syntax specified in the matching rule, however
@@ -434,8 +444,8 @@ typedef struct slap_matching_rule {
  * the asserted value is expected to conform to the
  * attribute's value syntax.
  */
-#define SLAP_MR_ASSERTION_SYNTAX_MATCH                         0x0000U
-#define SLAP_MR_ATTRIBUTE_SYNTAX_MATCH                         0x0001U
+#define SLAP_MR_ASSERTION_SYNTAX_MATCH         0x0000U
+#define SLAP_MR_ATTRIBUTE_SYNTAX_MATCH         0x0001U
 
 /* For SLAP_MR_ATTRIBUTE_SYNTAX_MATCHes, this flag indicates
  * that the asserted value of the attribute syntax has been
@@ -444,11 +454,32 @@ typedef struct slap_matching_rule {
  */
 #define SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH       0x0002U
 
+#else
+/*
+ * The asserted value, depending on the particular usage,
+ * is expected to conform to either the assertion syntax
+ * or the attribute syntax.   In some cases, the syntax of
+ * the value is known.  If so, these flags indicate which
+ * syntax the value is expected to conform to.  If not,
+ * neither of these flags is set (until the syntax of the
+ * provided value is determined).  If the value is of the
+ * attribute syntax, the flag is changed once a value of
+ * the assertion syntax is derived from the provided value.
+ */
+#define SLAP_MR_VALUE_OF_ASSERTION_SYNTAX      0x0001U
+#define SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX      0x0002U
+
+#define SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( usage ) \
+       ((usage) & SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX )
+#define SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX( usage ) \
+       ((usage) & SLAP_MR_VALUE_OF_ASSERTION_SYNTAX )
+#endif
+
 /* either or both the asserted value or attribute value
  * may be provided in normalized form
  */
-#define SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH                0x0004U
-#define SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH       0x0008U
+#define SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH                0x0010U
+#define SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH       0x0020U
 
 #define SLAP_IS_MR_ASSERTION_SYNTAX_MATCH( usage ) \
        (!((usage) & SLAP_MR_ATTRIBUTE_SYNTAX_MATCH))
@@ -519,6 +550,7 @@ typedef struct slap_mrule_defs_rec {
        slap_mr_indexer_func *          mrd_indexer;
        slap_mr_filter_func *           mrd_filter;
 
+       /* For equality rule, this may refer to an appropriate approximate rule */
        char *                                          mrd_associated;
 } slap_mrule_defs_rec;
 
index d808d8126a1d98dde21bfeaf49da65fb334a818b..f8468a91aa00dd3b25471cf7a319fd241b87a816 100644 (file)
@@ -151,7 +151,9 @@ syn_add(
        ssyn->ssyn_oidlen = strlen(syn->syn_oid);
        ssyn->ssyn_flags = def->sd_flags;
        ssyn->ssyn_validate = def->sd_validate;
+#ifndef SLAP_NVALUES
        ssyn->ssyn_normalize = def->sd_normalize;
+#endif
        ssyn->ssyn_pretty = def->sd_pretty;
 
 #ifdef SLAPD_BINARY_CONVERSION
index cd6c65c93e32efc72f31f8dca0753ef62d360c60..83ec803257317ec46768e31110d75641a0699f5c 100644 (file)
@@ -123,6 +123,56 @@ value_add_one(
        return LDAP_SUCCESS;
 }
 
+#ifdef SLAP_NVALUES
+int asserted_value_validate_normalize( 
+       AttributeDescription *ad,
+       MatchingRule *mr,
+       unsigned usage,
+       struct berval *in,
+       struct berval *out,
+       const char ** text )
+{
+       int rc;
+
+       /* we expect the value to be in the assertion syntax */
+       assert( !SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX(usage) );
+
+       if( mr == NULL ) {
+               *text = "inappropriate matching request";
+               return LDAP_INAPPROPRIATE_MATCHING;
+       }
+
+       if( !mr->smr_match ) {
+               *text = "requested matching rule not supported";
+               return LDAP_INAPPROPRIATE_MATCHING;
+       }
+
+       assert( mr->smr_syntax );
+       assert( mr->smr_syntax->ssyn_validate );
+
+       rc = (mr->smr_syntax->ssyn_validate)( mr->smr_syntax, in );
+
+       if( rc != LDAP_SUCCESS ) {
+               *text = "value does not conform to assertion syntax";
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       if( mr->smr_normalize ) {
+               rc = (mr->smr_normalize)( usage,
+                       ad ? ad->ad_type->sat_syntax : NULL,
+                       mr, in, out );
+
+               if( rc != LDAP_SUCCESS ) {
+                       *text = "unable to normalize value for matching";
+                       return LDAP_INVALID_SYNTAX;
+               }
+
+       } else {
+               ber_dupbv( out, in );
+       }
+}
+
+#else
 int
 value_validate(
        MatchingRule *mr,
@@ -165,25 +215,7 @@ value_normalize(
        const char **text )
 {
        int rc;
-       MatchingRule *mr;
-
-       switch( usage & SLAP_MR_TYPE_MASK ) {
-       case SLAP_MR_NONE:
-       case SLAP_MR_EQUALITY:
-               mr = ad->ad_type->sat_equality;
-               break;
-       case SLAP_MR_ORDERING:
-               mr = ad->ad_type->sat_ordering;
-               break;
-       case SLAP_MR_SUBSTR:
-               mr = ad->ad_type->sat_substr;
-               break;
-       case SLAP_MR_EXT:
-       default:
-               assert( 0 );
-               *text = "internal error";
-               return LDAP_OTHER;
-       }
+       MatchingRule *mr = ad_mr( ad, usage );
 
        if( mr == NULL ) {
                *text = "inappropriate matching request";
@@ -233,25 +265,7 @@ value_validate_normalize(
        const char **text )
 {
        int rc;
-       MatchingRule *mr;
-
-       switch( usage & SLAP_MR_TYPE_MASK ) {
-       case SLAP_MR_NONE:
-       case SLAP_MR_EQUALITY:
-               mr = ad->ad_type->sat_equality;
-               break;
-       case SLAP_MR_ORDERING:
-               mr = ad->ad_type->sat_ordering;
-               break;
-       case SLAP_MR_SUBSTR:
-               mr = ad->ad_type->sat_substr;
-               break;
-       case SLAP_MR_EXT:
-       default:
-               assert( 0 );
-               *text = "internal error";
-               return LDAP_OTHER;
-       }
+       MatchingRule *mr = ad_mr( ad, usage );
 
        if( mr == NULL ) {
                *text = "inappropriate matching request";
@@ -308,6 +322,7 @@ value_validate_normalize(
 
        return LDAP_SUCCESS;
 }
+#endif
 
 int
 value_match(
@@ -329,6 +344,7 @@ value_match(
                return LDAP_INAPPROPRIATE_MATCHING;
        }
 
+#ifndef SLAP_NVALUES
        if( ad->ad_type->sat_syntax->ssyn_normalize ) {
                rc = ad->ad_type->sat_syntax->ssyn_normalize(
                        ad->ad_type->sat_syntax, v1, &nv1 );
@@ -349,6 +365,7 @@ value_match(
                /* let smr_match know we've converted the value */
                flags |= SLAP_MR_ATTRIBUTE_SYNTAX_CONVERTED_MATCH;
        }
+#endif
 
        rc = (mr->smr_match)( match, flags,
                ad->ad_type->sat_syntax,
@@ -361,7 +378,6 @@ value_match(
        return rc;
 }
 
-
 int value_find_ex(
        AttributeDescription *ad,
        unsigned flags,
@@ -377,6 +393,23 @@ int value_find_ex(
                return LDAP_INAPPROPRIATE_MATCHING;
        }
 
+#ifdef SLAP_NVALUES
+       assert(SLAP_IS_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH( flags ));
+
+       if( !SLAP_IS_MR_ASSERTED_VALUE_NORMALIZED_MATCH( flags ) &&
+               mr->smr_normalize )
+       {
+               rc = (mr->smr_normalize)(
+                       flags & SLAP_MR_TYPE_MASK|SLAP_MR_SUBTYPE_MASK,
+                       ad ? ad->ad_type->sat_syntax : NULL,
+                       mr, val, &nval );
+
+               if( rc != LDAP_SUCCESS ) {
+                       return LDAP_INVALID_SYNTAX;
+               }
+       }
+#else
+
        /* Take care of this here or ssyn_normalize later will hurt */
        if ( SLAP_IS_MR_ATTRIBUTE_SYNTAX_NONCONVERTED_MATCH( flags )
                && mr->smr_convert )
@@ -406,6 +439,7 @@ int value_find_ex(
                        return LDAP_INAPPROPRIATE_MATCHING;
                }
        }
+#endif
 
        for ( i = 0; vals[i].bv_val != NULL; i++ ) {
                int match;