mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 16:49:39 -05:00
Update framework to support registration of approximate matching
rules.
This commit is contained in:
parent
e0e314db88
commit
6c41d272cf
6 changed files with 160 additions and 42 deletions
|
|
@ -306,6 +306,7 @@ at_add(
|
|||
if ( sat->sat_equality_oid ) {
|
||||
if ( (mr = mr_find(sat->sat_equality_oid)) ) {
|
||||
sat->sat_equality = mr;
|
||||
sat->sat_approx = mr->smr_associated;
|
||||
} else {
|
||||
*err = sat->sat_equality_oid;
|
||||
return SLAP_SCHERR_MR_NOT_FOUND;
|
||||
|
|
|
|||
|
|
@ -171,6 +171,8 @@ test_ava_filter(
|
|||
mr = a->a_desc->ad_type->sat_approx;
|
||||
if( mr != NULL ) break;
|
||||
|
||||
/* use EQUALITY matching rule if no APPROX rule */
|
||||
|
||||
case LDAP_FILTER_EQUALITY:
|
||||
mr = a->a_desc->ad_type->sat_equality;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ mr_add(
|
|||
slap_mr_match_func *match,
|
||||
slap_mr_indexer_func *indexer,
|
||||
slap_mr_filter_func *filter,
|
||||
MatchingRule *amr,
|
||||
const char **err
|
||||
)
|
||||
{
|
||||
|
|
@ -132,6 +133,7 @@ mr_add(
|
|||
smr->smr_match = match;
|
||||
smr->smr_indexer = indexer;
|
||||
smr->smr_filter = filter;
|
||||
smr->smr_associated = amr;
|
||||
|
||||
if ( smr->smr_syntax_oid ) {
|
||||
if ( (syn = syn_find(smr->smr_syntax_oid)) ) {
|
||||
|
|
@ -157,9 +159,11 @@ register_matching_rule(
|
|||
slap_mr_normalize_func *normalize,
|
||||
slap_mr_match_func *match,
|
||||
slap_mr_indexer_func *indexer,
|
||||
slap_mr_filter_func *filter )
|
||||
slap_mr_filter_func *filter,
|
||||
const char* associated )
|
||||
{
|
||||
LDAPMatchingRule *mr;
|
||||
MatchingRule *amr = NULL;
|
||||
int code;
|
||||
const char *err;
|
||||
|
||||
|
|
@ -169,6 +173,16 @@ register_matching_rule(
|
|||
return -1;
|
||||
}
|
||||
|
||||
if( associated != NULL ) {
|
||||
amr = mr_find( associated );
|
||||
|
||||
Debug( LDAP_DEBUG_ANY, "register_matching_rule: could not locate "
|
||||
"associated matching rule %s for %s\n",
|
||||
associated, desc, 0 );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
mr = ldap_str2matchingrule( desc, &code, &err, LDAP_SCHEMA_ALLOW_ALL);
|
||||
if ( !mr ) {
|
||||
Debug( LDAP_DEBUG_ANY, "Error in register_matching_rule: %s before %s in %s\n",
|
||||
|
|
@ -177,7 +191,7 @@ register_matching_rule(
|
|||
}
|
||||
|
||||
code = mr_add( mr, usage,
|
||||
convert, normalize, match, indexer, filter,
|
||||
convert, normalize, match, indexer, filter, amr,
|
||||
&err );
|
||||
|
||||
ldap_memfree( mr );
|
||||
|
|
|
|||
|
|
@ -604,6 +604,7 @@ LDAP_SLAPD_F (int) mr_add LDAP_P((LDAPMatchingRule *mr,
|
|||
slap_mr_match_func *match,
|
||||
slap_mr_indexer_func *indexer,
|
||||
slap_mr_filter_func *filter,
|
||||
MatchingRule * associated,
|
||||
const char **err));
|
||||
|
||||
LDAP_SLAPD_F (int) register_syntax LDAP_P((
|
||||
|
|
@ -620,7 +621,8 @@ LDAP_SLAPD_F (int) register_matching_rule LDAP_P((
|
|||
slap_mr_normalize_func *normalize,
|
||||
slap_mr_match_func *match,
|
||||
slap_mr_indexer_func *indexer,
|
||||
slap_mr_filter_func *filter ));
|
||||
slap_mr_filter_func *filter,
|
||||
const char *associated ));
|
||||
|
||||
LDAP_SLAPD_F (int) schema_info LDAP_P(( Entry **entry, const char **text ));
|
||||
|
||||
|
|
|
|||
|
|
@ -53,6 +53,12 @@
|
|||
#define generalizedTimeMatch numericStringMatch
|
||||
#define generalizedTimeOrderingMatch numericStringMatch
|
||||
|
||||
/* approx matching rules */
|
||||
#define directoryStringApproxMatchOID "1.3.6.1.4.1.4203.666.4.4"
|
||||
#define directoryStringApproxMatch NULL
|
||||
#define IA5StringApproxMatchOID "1.3.6.1.4.1.4203.666.4.5"
|
||||
#define IA5StringApproxMatch NULL
|
||||
|
||||
/* unimplemented matching routines */
|
||||
#define caseIgnoreListMatch NULL
|
||||
#define caseIgnoreListSubstringsMatch NULL
|
||||
|
|
@ -78,6 +84,7 @@
|
|||
#define caseExactSubstringsIndexer caseExactIA5SubstringsIndexer
|
||||
#define caseExactSubstringsFilter caseExactIA5SubstringsFilter
|
||||
|
||||
|
||||
static int
|
||||
octetStringMatch(
|
||||
int *matchp,
|
||||
|
|
@ -2097,6 +2104,8 @@ struct mrule_defs_rec {
|
|||
slap_mr_match_func * mrd_match;
|
||||
slap_mr_indexer_func * mrd_indexer;
|
||||
slap_mr_filter_func * mrd_filter;
|
||||
|
||||
char * mrd_associated;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -2126,170 +2135,256 @@ struct mrule_defs_rec {
|
|||
*/
|
||||
|
||||
struct mrule_defs_rec mrule_defs[] = {
|
||||
/*
|
||||
* EQUALITY matching rules must be listed after associated APPROX
|
||||
* matching rules. So, we list all APPROX matching rules first.
|
||||
*/
|
||||
{"( " directoryStringApproxMatchOID " NAME 'directoryStringApproxMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
|
||||
SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
|
||||
NULL, NULL,
|
||||
directoryStringApproxMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( " IA5StringApproxMatchOID " NAME 'IA5StringApproxMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
|
||||
SLAP_MR_EQUALITY_APPROX | SLAP_MR_EXT,
|
||||
NULL, NULL,
|
||||
IA5StringApproxMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
/*
|
||||
* Other matching rules
|
||||
*/
|
||||
|
||||
{"( 2.5.13.0 NAME 'objectIdentifierMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, objectIdentifierMatch,
|
||||
caseIgnoreIA5Indexer, caseIgnoreIA5Filter},
|
||||
NULL, NULL,
|
||||
objectIdentifierMatch, caseIgnoreIA5Indexer, caseIgnoreIA5Filter,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.1 NAME 'distinguishedNameMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, dnMatch, dnIndexer, dnFilter},
|
||||
NULL, NULL,
|
||||
dnMatch, dnIndexer, dnFilter,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.2 NAME 'caseIgnoreMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, caseIgnoreMatch, caseIgnoreIndexer, caseIgnoreFilter},
|
||||
NULL, NULL,
|
||||
caseIgnoreMatch, caseIgnoreIndexer, caseIgnoreFilter,
|
||||
directoryStringApproxMatchOID },
|
||||
|
||||
{"( 2.5.13.3 NAME 'caseIgnoreOrderingMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
|
||||
SLAP_MR_ORDERING,
|
||||
NULL, NULL, caseIgnoreOrderingMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
caseIgnoreOrderingMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.4 NAME 'caseIgnoreSubstringsMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
|
||||
SLAP_MR_SUBSTR | SLAP_MR_EXT,
|
||||
NULL, NULL, caseIgnoreSubstringsMatch,
|
||||
caseIgnoreSubstringsIndexer, caseIgnoreSubstringsFilter},
|
||||
NULL, NULL,
|
||||
caseIgnoreSubstringsMatch,
|
||||
caseIgnoreSubstringsIndexer,
|
||||
caseIgnoreSubstringsFilter,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.5 NAME 'caseExactMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, caseExactMatch, caseExactIndexer, caseExactFilter},
|
||||
NULL, NULL,
|
||||
caseExactMatch, caseExactIndexer, caseExactFilter,
|
||||
directoryStringApproxMatchOID },
|
||||
|
||||
{"( 2.5.13.6 NAME 'caseExactOrderingMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
|
||||
SLAP_MR_ORDERING,
|
||||
NULL, NULL, caseExactOrderingMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
caseExactOrderingMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.7 NAME 'caseExactSubstringsMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
|
||||
SLAP_MR_SUBSTR | SLAP_MR_EXT,
|
||||
NULL, NULL, caseExactSubstringsMatch,
|
||||
caseExactSubstringsIndexer, caseExactSubstringsFilter},
|
||||
NULL, NULL,
|
||||
caseExactSubstringsMatch,
|
||||
caseExactSubstringsIndexer,
|
||||
caseExactSubstringsFilter,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.8 NAME 'numericStringMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.36 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, caseIgnoreIA5Match, NULL, NULL},
|
||||
NULL, NULL,
|
||||
caseIgnoreIA5Match, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.10 NAME 'numericStringSubstringsMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
|
||||
SLAP_MR_SUBSTR | SLAP_MR_EXT,
|
||||
NULL, NULL, caseIgnoreIA5SubstringsMatch,
|
||||
caseIgnoreIA5SubstringsIndexer, caseIgnoreIA5SubstringsFilter},
|
||||
NULL, NULL,
|
||||
caseIgnoreIA5SubstringsMatch,
|
||||
caseIgnoreIA5SubstringsIndexer,
|
||||
caseIgnoreIA5SubstringsFilter,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.11 NAME 'caseIgnoreListMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.41 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, caseIgnoreListMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
caseIgnoreListMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.12 NAME 'caseIgnoreListSubstringsMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
|
||||
SLAP_MR_SUBSTR | SLAP_MR_EXT,
|
||||
NULL, NULL, caseIgnoreListSubstringsMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
caseIgnoreListSubstringsMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.13 NAME 'booleanMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, booleanMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
booleanMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.14 NAME 'integerMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, integerMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
integerMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.16 NAME 'bitStringMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.6 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, bitStringMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
bitStringMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.17 NAME 'octetStringMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, octetStringMatch, octetStringIndexer, octetStringFilter},
|
||||
NULL, NULL,
|
||||
octetStringMatch, octetStringIndexer, octetStringFilter,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.20 NAME 'telephoneNumberMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.50 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, telephoneNumberMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
telephoneNumberMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.21 NAME 'telephoneNumberSubstringsMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.58 )",
|
||||
SLAP_MR_SUBSTR | SLAP_MR_EXT,
|
||||
NULL, NULL, telephoneNumberSubstringsMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
telephoneNumberSubstringsMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.22 NAME 'presentationAddressMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.43 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, presentationAddressMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
presentationAddressMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.23 NAME 'uniqueMemberMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.34 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, uniqueMemberMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
uniqueMemberMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.24 NAME 'protocolInformationMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.42 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, protocolInformationMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
protocolInformationMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.27 NAME 'generalizedTimeMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, generalizedTimeMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
generalizedTimeMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 )",
|
||||
SLAP_MR_ORDERING,
|
||||
NULL, NULL, generalizedTimeOrderingMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
generalizedTimeOrderingMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.29 NAME 'integerFirstComponentMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, integerFirstComponentMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
integerFirstComponentMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 2.5.13.30 NAME 'objectIdentifierFirstComponentMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL, objectIdentifierFirstComponentMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
objectIdentifierFirstComponentMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 1.3.6.1.4.1.1466.109.114.1 NAME 'caseExactIA5Match' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL,
|
||||
caseExactIA5Match, caseExactIA5Indexer, caseExactIA5Filter},
|
||||
caseExactIA5Match, caseExactIA5Indexer, caseExactIA5Filter,
|
||||
IA5StringApproxMatchOID },
|
||||
|
||||
{"( 1.3.6.1.4.1.1466.109.114.2 NAME 'caseIgnoreIA5Match' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
|
||||
SLAP_MR_EQUALITY | SLAP_MR_EXT,
|
||||
NULL, NULL,
|
||||
caseIgnoreIA5Match, caseExactIA5Indexer, caseExactIA5Filter},
|
||||
caseIgnoreIA5Match, caseExactIA5Indexer, caseExactIA5Filter,
|
||||
IA5StringApproxMatchOID },
|
||||
|
||||
{"( 1.3.6.1.4.1.1466.109.114.3 NAME 'caseIgnoreIA5SubstringsMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
|
||||
SLAP_MR_SUBSTR,
|
||||
NULL, NULL, caseIgnoreIA5SubstringsMatch,
|
||||
caseIgnoreIA5SubstringsIndexer, caseIgnoreIA5SubstringsFilter},
|
||||
NULL, NULL,
|
||||
caseIgnoreIA5SubstringsMatch,
|
||||
caseIgnoreIA5SubstringsIndexer,
|
||||
caseIgnoreIA5SubstringsFilter,
|
||||
NULL},
|
||||
|
||||
{"( 1.3.6.1.4.1.4203.666.4.3 NAME 'caseExactIA5SubstringsMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )",
|
||||
SLAP_MR_SUBSTR,
|
||||
NULL, NULL, caseExactIA5SubstringsMatch,
|
||||
caseExactIA5SubstringsIndexer, caseExactIA5SubstringsFilter},
|
||||
NULL, NULL,
|
||||
caseExactIA5SubstringsMatch,
|
||||
caseExactIA5SubstringsIndexer,
|
||||
caseExactIA5SubstringsFilter,
|
||||
NULL},
|
||||
|
||||
{"( 1.3.6.1.4.1.4203.666.4.1 NAME 'authPasswordMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 )",
|
||||
SLAP_MR_EQUALITY,
|
||||
NULL, NULL, authPasswordMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
authPasswordMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{"( 1.3.6.1.4.1.4203.666.4.2 NAME 'OpenLDAPaciMatch' "
|
||||
"SYNTAX 1.3.6.1.4.1.4203.666.2.1 )",
|
||||
SLAP_MR_EQUALITY,
|
||||
NULL, NULL, OpenLDAPaciMatch, NULL, NULL},
|
||||
NULL, NULL,
|
||||
OpenLDAPaciMatch, NULL, NULL,
|
||||
NULL},
|
||||
|
||||
{NULL, SLAP_MR_NONE, NULL, NULL, NULL}
|
||||
{NULL, SLAP_MR_NONE, NULL, NULL, NULL, NULL}
|
||||
};
|
||||
|
||||
int
|
||||
|
|
@ -2336,7 +2431,8 @@ schema_init( void )
|
|||
mrule_defs[i].mrd_normalize,
|
||||
mrule_defs[i].mrd_match,
|
||||
mrule_defs[i].mrd_indexer,
|
||||
mrule_defs[i].mrd_filter );
|
||||
mrule_defs[i].mrd_filter,
|
||||
mrule_defs[i].mrd_associated );
|
||||
|
||||
if ( res ) {
|
||||
fprintf( stderr,
|
||||
|
|
|
|||
|
|
@ -301,7 +301,10 @@ typedef struct slap_matching_rule {
|
|||
slap_mr_match_func *smr_match;
|
||||
slap_mr_indexer_func *smr_indexer;
|
||||
slap_mr_filter_func *smr_filter;
|
||||
|
||||
struct slap_matching_rule *smr_associated;
|
||||
struct slap_matching_rule *smr_next;
|
||||
|
||||
#define smr_oid smr_mrule.mr_oid
|
||||
#define smr_names smr_mrule.mr_names
|
||||
#define smr_desc smr_mrule.mr_desc
|
||||
|
|
|
|||
Loading…
Reference in a new issue