HP-UX Directory Server 8.1 plug-in reference

Table Of Contents
2 Writing and compiling plug-ins
This chapter provides an introduction on how to write and compile HP-UX Directory Server.
Chapter 3 “Configuring plug-ins” describes how to load the plug-in into the Directory Server
configuration after it has been successfully compiled.
If you have already written a plug-in for the Directory Server, see “Using Directory Server plug-in
APIs” for information on migrating a custom plug-in to the latest version of Directory Server.
2.1 Writing a plug-in Function
To write a Directory Server plug-in, the plug-in code must:
Include the API header file.
Set the function parameters using the parameter block.
Call the front end.
Specify the function return value.
For additional information on writing specific plug-in types, see the following sections:
Chapter 6 “Writing pre- and postoperation plug-ins”
Chapter 9 “Writing entry store/fetch plug-ins”
Chapter 10 “Writing extended operation plug-ins”
2.1.1 Including the API header file
The interface to the Directory Server plug-in API is located in the slapi-plugin.h header file.
You must include this header file in the plug-ins that you write. The following is an example of
how to include this header file:
#include "slapi-plugin.h"
When the Directory Server is installed, slapi-plugin.h is installed in the following directory:
/opt/dirsrv/devel/include/slapi-plugin.h
2.1.2 Passing data with parameter blocks
Plug-in functions often make use of the Slapi_PBlock parameter block for passing information
to and from the Directory Server. The following plug-in function types pass a parameter block
as a function argument:
Preoperation plug-in functions.
Postoperation plug-in functions.
Matching rule functions for indexing.
Factory functions for matching rule index functions.
Factory functions for matching rule filter functions.
When invoking these types of plug-in functions, you pass a single argument of type
Slapi_PBlock to the Directory Server. This argument contains the parameter values needed
to complete the function request. Your plug-in function should have a prototype similar to the
following:
int myFunction( Slapi_PBlock pb );
In this prototype, pb is the parameter block that contains the parameters pertaining to the
operation or function.
For example, the parameter block for an add operation will contain the target DN and the entry
to be added; the parameter block for a bind operation will contain the DN of the user, the
authentication method, and the user's credentials.
2.1 Writing a plug-in Function 31