A matching rule specifies how attribute values are to be matched for equality, ordering, and substring comparison. Examples of matching rules are the case-exact ordering rule for English language-based strings and case-ignore equality match for Directory String.
In the schema tree, the name "MatchingRule" is bound to a flat context that contains DirContext objects that represent matching rule definitions in the schema. For example, if a directory supports the "caseExactMatch" equality rule, then the "MatchingRule" context might have a binding with the name "caseExactMatch" that is bound to a DirContext object. Each object in "MatchingRule" context has the mandatory and optional attributes shown in the following table.
Note: Many servers do not publish their matching rules. Even among those that do, some might not publish all of the rules.
Attribute Identifier Attribute Value Description NUMERICOID (mandatory) Unique object identifier (OID) NAME Matching rule's name DESC Matching rule's description SYNTAX Numeric OID of the syntax to which this matching rule applies OBSOLETE "true" if obsolete; "false" or absent otherwise
These attributes correspond to the definition of "MatchingRuleDescription" in RFC 2252. All of the attribute values are represented by the java.lang.String class.
Retrieving the Schema of a Matching Rule DefinitionTo retrieve the schema object of a matching rule, you look for it in the schema tree. For example, you can obtain the schema object representing the "caseExactOrderingMatch-en" rule by using the following code.If you get the attributes of the mrSchema schema object, then you will see the following.// Get the schema tree root DirContext schema = ctx.getSchema(""); // Get the schema object for the matching rule DirContext mrSchema = (DirContext)schema.lookup("MatchingRule/caseExactOrderingMatch-en");SYNTAX: 188.8.131.52.4.1.14184.108.40.206.15 NAME: caseExactOrderingMatch-en NUMERICOID: 2.16.840.1.1137220.127.116.11.11.3 DESC: en
Note: This example works only with directory servers that publish their matching rules, such as the SunONE Directory Server v5.1.
You can use not only lookup() to retrieve schema objects from the schema tree, but also such methods as list() or search().
Creating, Modifying, or Updating a Matching Rule DefinitionDynamically creating, deleting, or modifying matching rules does not make sense. Most servers support a fixed set of matching rules. Changing that set programmatically is usually not a supported feature.