A matching rule plug-in can create filters that the server can use when handling extensible search filters. A matching rule plug-in can also create indexers to index entries for extensible searches.
Functions Defined in Matching Rule Plug-Ins
The matching rule plug-in consists of the following:
When the server starts up and loads the matching rule plug-in, it calls the initialization function. In this function, you pass the server the pointers to the factory functions and the close function. The server calls these functions when needed (see "How Matching Rules Are Identified" on page 162 and "How the Server Associates Plug-Ins with OIDs" on page 163 for details).
How Matching Rules Are Identified
Matching rules are identified by OID. When the server encounters an OID in the following situations, it attempts to find the matching rule plug-in that handles the matching rule with that OID.
The server can encounter a matching rule OID in the following situations:
In all of these situations, the server uses the matching rule OID to find the plug-in responsible for handling the rule (see "How the Server Associates Plug-Ins with OIDs" on page 163 for details).
How the Server Associates Plug-Ins with OIDs
When the server encounters the OID for a matching rule, it attempts to find the plug-in associated with that matching rule.
If no plug-in is associated with the matching rule, the server calls each matching rule plug-in to find one that handles the specified matching rule.
When the server finds a plug-in that handles the matching rule, the server creates an association between the plug-in and the matching rule OID for future reference.
If no matching rule plug-in supports the specified OID, the server returns an LDAP_UNAVAILABLE_CRITICAL_EXTENSION error back to the client.
Finding a Plug-In for Indexing
To determine which matching rule plug-in is responsible for indexing an attribute with a given matching rule (based on its OID), the server does the following for each plug-in:
In a new Slapi_PBlock parameter block, the server sets the OID in the SLAPI_PLUGIN_MR_OID parameter.
Next, the server calls the indexer factory function (specified in the SLAPI_PLUGIN_MR_INDEXER_CREATE_FN parameter) for the plug-in.
The server checks the SLAPI_PLUGIN_MR_INDEX_FN parameter.
Finally, the server frees the parameter block from memory.
At some point in time, the server may also call the indexer destructor function (specified in the SLAPI_PLUGIN_MR_DESTROY_FN parameter) to free the indexer object that was created by the indexer factory function.
Finding a Plug-In for Searching
To determine which matching rule plug-in is responsible for handling an extensible match filter for a given matching rule (based on its OID), the server does the following for each plug-in:
In a new Slapi_PBlock parameter block, the server sets the following parameters:
Next, the server calls the filter factory function (specified in the SLAPI_PLUGIN_MR_FILTER_CREATE_FN parameter) for the plug-in.
The server checks the SLAPI_PLUGIN_MR_FILTER_MATCH_FN parameter.
Finally, the server gets the following information from the plug-in for future use:
Information specified in the filter object is used by both the filter index function and the filter matching function.
How the Server Uses Parameter Blocks
The server uses parameter blocks as a means to pass information to and from your plug-in functions.
When calling your matching rule plug-in functions, the server will create a new Slapi_PBlock parameter block, set some input parameters, and pass the parameter block to your function. After retrieving output paramters from the block, the server typically frees the parameter block from memory.
In general, you should not expect a parameter block to be passed from plug-in function to plug-in function. For example, the value of a parameter set by one plug-in function may not necessarily be accessible to other plug-in functions, since each function is usually passed a new and different parameter block.