HP-UX Directory Server 8.1 plug-in reference

Table Of Contents
Typically, your function should perform an operation on the value specified in the
SLAPI_EXT_OP_REQ_VALUE parameter. After the extended operation completes, your function
should return a single value, according to the following:
If your function has sent a result code back to the client, you should return the value
SLAPI_PLUGIN_EXTENDED_SENT_RESULT. This indicates that the front end does not need
to send a result code.
If your function has not sent a result code back to the client (for example, if the result is
LDAP_SUCCESS), your function should return an LDAP result code. The front end will
send this result code back to the client.
If your function cannot handle the extended operation with the specified OID, your function
should return the value [SLAPI_PLUGIN_EXTENDED_NOT_HANDLED]. The front end
will send an [LDAP_PROTOCOL_ERROR] result code (with an unsupported extended
operation error message) back to the client.
Note:
Refer to the following source file for a sample plug-in function (uncompiled C code) that
implements an extended operation:
/opt/dirsrv/devel/example/testextendedop.c
10.3 Registering extended operation functions
Extended operation functions are specified in a parameter block that you can set on server startup,
in the same fashion as other server plug-in functions (refer to “Passing data with parameter
blocks”).
In your initialization function, you can call the “slapi_pblock_set()” function to set the
SLAPI_PLUGIN_EXT_OP_FN parameter to your function and the
SLAPI_PLUGIN_EXT_OP_OIDLIST parameter to the list of OIDs of the extended operations
supported by your function.
You can write your initialization function so that the OID is passed in from the directive (refer
to “Passing extra arguments to plug-ins”, for details.) For example, the following initialization
function sets the SLAPI_PLUGIN_EXT_OP_OIDLIST parameter to the additional parameters
specified.
int extended_init( Slapi_PBlock *pb )
{
int i;
char **argv;
char **oids;
/* Get the additional arguments specified in the directive */
if ( slapi_pblock_get( pb, SLAPI_PLUGIN_ARGV, &argv ) != 0 ) {
slapi_log_error( SLAPI_LOG_PLUGIN, "extended_init" , "Server could not get argv.\n" );
return( -1 );
}
if ( argv == NULL ) {
slapi_log_error( SLAPI_LOG_PLUGIN, "extended_init" , "Required argument oiD is missing\n" );
return( -1 );
}
/* Get the number of additional arguments and copy them. */
for ( i = 0; argv[i] != NULL;i++ )
;
oids = (char **) slapi_ch_malloc( (i+1) * sizeof(char *) );
for ( i = 0; argv[i] != NULL; i++ ) {
oids[i] = slapi_ch_strdup( argv[i] );
}
oids[i] = NULL;
/* Specify the version of the plug-in */
if ( slapi_pblock_set( pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01 ) != 0 ||
/* Specify the OID of the extended operation */
slapi_pblock_set( pb, SLAPI_PLUGIN_EXT_OP_OIDLISTs, (void*) oids ) != 0 ||
84 Writing extended operation plug-ins