HP-UX Directory Server 8.1 plug-in reference

Table Of Contents
The server first verifies that the SLAPI_PLUGIN_MR_INDEX_FN parameter specifies
an indexer function and the SLAPI_PLUGIN_MR_OID parameter specifies the official
OID of the matching rule.
If these are both set, the server sets the SLAPI_PLUGIN_MR_VALUES parameter to the
array of berval structures containing the new or modified values that need to be
indexed and calls the indexer function.
Next, the server gets the value of the SLAPI_PLUGIN_MR_KEYS parameter, which is
an array of berval structures containing the keys corresponding to the values.
4. The server inserts or deletes the keys and values in the index for that attribute.
5. The server calls the indexer destructor function (specified in the
SLAPI_PLUGIN_MR_DESTROY_FN parameter) to free the indexer object.
At the end of the process, the server frees any parameter blocks that were allocated during the
process.
11.3.3 Writing the indexer factory function
The indexer factory function takes a single Slapi_PBlock argument. This function should be
thread-safe. The server may call this function concurrently.
The indexer factory function should perform the following tasks:
1. Get the OID from the SLAPI_PLUGIN_MR_OID parameter, and determine whether that
OID is supported by your plug-in.
If the OID is not supported, you need to return the result code
[LDAP_UNAVAILABLE_CRITICAL_EXTENSION].
If the OID is supported, continue with this process.
2. Get the value of the SLAPI_PLUGIN_MR_USAGE parameter. This parameter should have
one of the following values:
If the value is SLAPI_PLUGIN_MR_USAGE_SORT, the server is calling your function to
sort search results. Refer to “Handling sorting by matching rules”, for more information.
If the value is SLAPI_PLUGIN_MR_USAGE_INDEX, the server is calling your function
to index an entry.
You can use this information to set different information in the indexer object or to set a
different indexer function, based on whether the function is being called to index or to sort.
3. You can also get any data that you set in the SLAPI_PLUGIN_PRIVATE parameter during
initialization. (Refer to “Writing an initialization function”.)
4. Create an indexer object containing any information that you want to pass to the indexer
function.
5. Set the following parameters:
Set the SLAPI_PLUGIN_MR_OID parameter to the official OID of the matching rule (if
the value of that parameter is not the official OID).
Set the SLAPI_PLUGIN_OBJECT parameter to the indexer object.
Set the SLAPI_PLUGIN_MR_INDEX_FN parameter to the indexer function. (Refer to
“Writing the indexer function”.)
Set the SLAPI_PLUGIN_DESTROY_FN parameter to the function responsible for freeing
any memory allocated by the factory function, such as the indexer object. refer to
“Writing the indexer factory function”, for details.
6. Return 0 (or the result code [LDAP_SUCCESS]) if everything completed successfully.
11.3.4 Getting and setting parameters in indexer factory functions
The following table summarizes the different parameters that the indexer factory function should
get and set in the parameter block that is passed in.
11.3 Indexing based on matching rules 91