As for other plug-in types, extended operation plug-ins include an initialization function that registers other functions in the plug-in with Directory Server. For extended operation plug-ins, this initialization function also registers the OIDs handled by the plug-in. The function registers OIDs by setting SLAPI_PLUGIN_EXT_OP_OIDLIST in the parameter block Directory Server, which the function passes to the initialization function.
This example demonstrates how the OID list is built and registered.
#include "slapi-plugin.h" Slapi_PluginDesc expdesc = { "test-extendedop", /* plug-in identifier */ "Sun Microsystems, Inc.", /* vendor name */ "6.0", /* plug-in revision number */ "Sample extended operation plug-in"/* plug-in description */ }; #ifdef _WIN32 __declspec(dllexport) #endif int testexop_init(Slapi_PBlock * pb) { char ** argv; /* Args from configuration */ int argc; /* entry for plug-in. */ char ** oid_list; /* OIDs supported */ int rc = 0; /* 0 means success */ int i; /* Get the arguments from the configuration entry. */ rc |= slapi_pblock_get(pb, SLAPI_PLUGIN_ARGV, &argv); rc |= slapi_pblock_get(pb, SLAPI_PLUGIN_ARGC, &argc); if (rc != 0) { slapi_log_info_ex( SLAPI_LOG_INFO_AREA_PLUGIN, SLAPI_LOG_INFO_LEVEL_DEFAULT, SLAPI_LOG_NO_MSGID, SLAPI_LOG_NO_CONNID, SLAPI_LOG_NO_OPID, "testexop_init in test-extendedop plug-in", "Could not get plug-in arguments.\n" ); return (rc); } /* Extended operation plug-ins may handle a range of OIDs. */ oid_list = (char **)slapi_ch_malloc((argc + 1) * sizeof(char *)); for (i = 0; i < argc; ++i) { oid_list[i] = slapi_ch_strdup(argv[i]); slapi_log_info_ex( SLAPI_LOG_INFO_AREA_PLUGIN, SLAPI_LOG_INFO_LEVEL_DEFAULT, SLAPI_LOG_NO_MSGID, SLAPI_LOG_NO_CONNID, SLAPI_LOG_NO_OPID, "testexop_init in test-extendedop plug-in", "Registering plug-in for extended operation %s.\n", oid_list[i] ); } oid_list[argc] = NULL; rc |= slapi_pblock_set( /* Plug-in API version */ pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_CURRENT_VERSION ); rc |= slapi_pblock_set( /* Plug-in description */ pb, SLAPI_PLUGIN_DESCRIPTION, (void *) &expdesc ); rc |= slapi_pblock_set( /* Extended op. handler */ pb, SLAPI_PLUGIN_EXT_OP_FN, (void *) test_extendedop ); rc |= slapi_pblock_set( /* List of OIDs handled */ pb, SLAPI_PLUGIN_EXT_OP_OIDLIST, oid_list ); return (rc); }
Notice that you extract OIDs from the arguments passed by Directory Server. Directory Server passes the arguments from the configuration entry to the parameter block, by using slapi_ch_strdup() on each argv[] element. The OID list is then built by allocating space for the array by using slapi_ch_malloc() and placing the OIDs in each oid_list[] element. You then register the plug-in OID list by using SLAPI_PLUGIN_EXT_OP_OIDLIST. You register the extended operation handler function, test_extendedop(), using SLAPI_PLUGIN_EXT_OP_FN as shown.
Refer to Part II, Directory Server Plug-In API Reference for details about parameter block arguments and plug-in API functions.