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

Attribute Matching Rule Definitions

A matching rule specifies how values of an attribute are to be matched for equality, ordering, or substring comparision. Examples of matching rules are 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 containing DirContext(in the API reference documentation) objects representing matching rule definitions in the schema. For example, if a directory supports the "caseExactMatch" equality rule, the "MatchingRule" context might have a binding with name "caseExactMatch" that is bound to a DirContext object.


Note: Many servers do not publish their matching rules. Even among those that do publish their matching rules, some might not publish all of the rules.

Each object in "MatchingRule" context has the following mandatory and optional attributes:
 

Attribute Identifier Attribute Value Description
NUMERICOID (mandatory) unique 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 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 schema object for matching rule
DirContext mrSchema =
    (DirContext)schema.lookup("MatchingRule/caseExactOrderingMatch-en");
If you get the attributes of the mrSchema schema object, you will see:
SYNTAX: 1.3.6.1.4.1.1466.115.121.1.15
NAME: caseExactOrderingMatch-en
NUMERICOID: 2.16.840.1.113730.3.3.2.11.3
DESC: en

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

In addition to using lookup(), you can use methods such as list()(in the API reference documentation) or search()(in the API reference documentation) to retrieve schema objects from the schema tree.

Creating, Modifying, or Updating a Matching Rule Definition

It does not make sense to dynamically create, delete, or modify matching rules. 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