HP-UX Directory Server 8.1 plug-in reference

Table Of Contents
2.2.3 Registering your plug-in functions
Whether the plug-in is registered through the initialization function depends on the type of
function being registered.
For some plug-in types, you do not need to register the plug-in function from within the
initialization function. For example, you register entry store and entry fetch plug-ins by specifying
the function names in the plugin directive in the dse.ldif file.
For other plug-in types, such as preoperation plug-ins and postoperation plug-ins, the Directory
Server gets the pointer to the function from a parameter in the initialization function parameter
block. In these cases, you use the “slapi_pblock_set()” function to specify the name of the plug-in
function.
The full list parameters that you can use to register the plug-in functions are listed in
Chapter 52 “Parameters for registering plug-in functions”.
For example, if you want to register searchdn_preop_search() as a preoperation search
function, include the following code in the initialization function:
slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_SEARCH_FN, (void *)
searchdn_preop_search )
SLAPI_PLUGIN_PRE_SEARCH_FN is the parameter that specifies the preoperation plug-in
function for the LDAP search operation.
NOTE:
If the plug-in functions are not registered, the Directory Server will not call them. All custom
plug-in functions should be registered.
More than one plug-in function can be registered in the initialization function; it is not necessary
to write an initialization function for each plug-in function that needs to be registered. You
should, however, define a different initialization function for each type of plug-in that you are
registering.
2.2.4 Returning a value to the Directory Server
If the initialization function is successful, it should return 0. If an error occurs, it should return
-1, in which case the Directory Server will exit.
2.2.5 Example of an initialization function
The following is an example of an initialization function that registers the preoperation plug-in
function searchdn_preop_search(). After the initialization function returns, the server will
call searchdn_preop_search() before each LDAP search operation is executed.
#include "slapi-plugin.h"
...
#ifdef _WIN32
__declspec(dllexport)
#endif
searchdn_preop_init( Slapi_PBlock *pb );
{
/*Specify the version of the plug-in (set this to "01" )*/
if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 )
!= 0 ||
/* Set up theserver to call searchdn_preop_search()
* before each LDAP search operation. */
slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_SEARCH_FN,
(void *)searchdn_preop_search ) !=0 ) {
2.2 Writing plug-in initialization functions 35