10.2. Writing Extended Operation Functions

Like other plug-in functions, extended operation functions pass a single parameter block (Slapi_PBlock) and return an integer value, as shown in the following example declaration:
int my_ext_func( Slapi_PBlock *pb );
When the Directory Server receives an extended operation request, the front-end calls the extended operation function with the OID value specified in the request. The front-end makes the following information available to the extended function in the form of parameters in a parameter block.

Table 10.1. Extended Function Parameter Block Arguments

Parameter ID Data Type Description
SLAPI_EXT_OP_REQ_OID char * Object ID (OID) of the extended operation specified in the request.
SLAPI_EXT_OP_REQ_VALUE struct berval* Value specified in the request.
SLAPI_EXT_OP_RET_OID char * Object ID (OID) that you want sent back to the client.
SLAPI_EXT_OP_RET_VALUE struct berval* Value that you want sent back to the client.
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

Check out the testextendedop.c source file for a sample plug-in function (uncompiled C code) that implements an extended operation.