Previous | Next | Trail Map | Tips for LDAP Users | Schema

Attribute Matching Rule Definitions

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(in the API reference documentation) 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 Definition

To 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.
// Get the schema tree root
DirContext schema = ctx.getSchema("");

// Get the schema object for the matching rule
DirContext mrSchema =
If you get the attributes of the mrSchema schema object, then you will see the following.
NAME: caseExactOrderingMatch-en
NUMERICOID: 2.16.840.1.113730.
DESC: en

Note: This example works only with directory servers that publish their matching rules, such as the Netscape Directory Server v4.1.

You can use not only lookup() to retrieve schema objects from the schema tree, but also such methods as list()(in the API reference documentation) or search()(in the API reference documentation).

Creating, Modifying, or Updating a Matching Rule Definition

Dynamically 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.

Previous | Next | Trail Map | Tips for LDAP Users | Schema