Sun Java System Directory Server Enterprise Edition 6.0 Developer's Guide

Example

The following code excerpt sets a plug-in component identifier used during an internal search.


Example 15–3 Setting a Plug-In Identifier for Use with Internal Operations

#include "slapi-plugin.h"
/* Declare the identifier as global to the plug-in.                 */
static Slapi_ComponentId * postop_id;

/* Assign a value as part of plug-in initialization.                */
int
testpostop_init(Slapi_PBlock * pb)
{
    int rc = 0;
    /* Register description, other functions, and so forth.         */
    rc |= slapi_pblock_set(
        pb,
        SLAPI_PLUGIN_START_FN,
        (void *) testpostop_set_log
    );
    /* Assign a value to the identifier.                            */
    rc |= slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &postop_id);
    return (rc);
}

/* The server uses the identifier when processing
 * internal operations, such as an internal search.                 */
int
testpostop_set_log(Slapi_PBlock * pb)
{
    Slapi_DN    * confdn = NULL;       /* DN for configuration entry */
    Slapi_Entry * config = NULL;       /* Configuration entry        */
    int rc = 0;

    confdn = slapi_sdn_new_dn_byval("cn=config");
    rc |= slapi_search_internal_get_entry(confdn, NULL, &config, postop_id);
    /* Use the results of the search.                                */
    return(rc);
}