An Example Pre-Operation Plug-In
48
Netscape Directory Server Plug-In Programmer’s Guide • December 2003
Writing the Plug-In Example
The following example code includes the sample pre-operation search function and
the sample initialization function.
Code Example 4-1
Sample Pre-Operation Search and Initialization Functions
#include <stdio.h>
#include <string.h>
#include "slapi-plugin.h"
/* function prototypes */
int test_preop_init( Slapi_PBlock *pb );
int test_preop_search( Slapi_PBlock *pb );
/* Description of the plug-in */
Slapi_PluginDesc srchpdesc = { "test-search", "example.com", "0.5",
"sample pre-operation search plugin" };
/* Initialization function
This function registers your plug-in function as a
pre-operation search function in the Directory Server.
You need to specify this initialization function in the
server configuration file so that the server calls
this initialization function on startup. */
#ifdef _WIN32
__declspec(dllexport)
#endif
int
test_preop_init( Slapi_PBlock *pb )
{
/* Specify the version of the plug-in ("01" in this release ) */
if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION,
SLAPI_PLUGIN_VERSION_01 ) != 0 ||
/* Specify the description of the plug-in */
slapi_pblock_set( pb, SLAPI_PLUGIN_DESCRIPTION,
(void *)&srchpdesc ) != 0 ||
/* Set test_preop_search() as the function to call before
executing LDAP search operations. */
slapi_pblock_set( pb, SLAPI_PLUGIN_PRE_SEARCH_FN,
(void *) test_preop_search ) !=0 ) {
/* Log an error message and return -1 if a problem occurred */
slapi_log_error( SLAPI_LOG_PLUGIN, "test_preop_init",
"Error registering the plug-in.\n" );
return( -1 );
}
/* If successful, log a message and return 0 */
slapi_log_error( SLAPI_LOG_PLUGIN, "test_preop_init",
"Plug-in successfully registered.\n" );
return( 0 );
}
/* Pre-operation plug-in function for LDAP search operations
This function is called by the server before processing an LDAP
search operation. The function gets data about the search request
Summary of Contents for NETSCAPE DIRECTORY SERVER 6.2 - GATEWAY CUSTOMIZATION
Page 1: ...Plug In Programmer s Guide Netscape Directory Server Version6 2 December 2003...
Page 18: ...18 Netscape Directory Server Plug In Programmer s Guide December 2003...
Page 56: ...56 Netscape Directory Server Plug In Programmer s Guide December 2003...
Page 112: ...112 Netscape Directory Server Plug In Programmer s Guide December 2003...
Page 168: ...Plug In API Reference 168 Netscape Directory Server Plug In Programmer s Guide December 2003...
Page 170: ...170 Netscape Directory Server Plug In Programmer s Guide December 2003...
Page 600: ...600 Netscape Directory Server Plug In Programmer s Guide December 2003...
Page 612: ...612 Netscape Directory Server Plug In Programmer s Guide December 2003...