Complete Contents
Getting Started
Chapter 1 Understanding Server Plug-Ins
Chapter 2 Writing and Compiling Plug-Ins
Chapter 3 Calling the Front-End API Functions
Chapter 4 Quick Start
Chapter 5 Writing Database Plug-Ins
Chapter 6 Writing Pre/Post-Operation Plug-Ins
Chapter 7 Defining Functions for LDAP Operations
Chapter 8 Defining Functions for Database Operations
Chapter 9 Defining Functions for Authentication
Chapter 10 Writing Entry Store/Fetch Plug-Ins
Chapter 11 Writing Extended Operation Plug-Ins
Chapter 12 Writing Matching Rule Plug-Ins
Chapter 13 Data Type and Structure Reference
Chapter 14 Function Reference
Chapter 15 Parameter Reference
Glossary
Previous Next Contents Bookshelf


Chapter 6 Writing Pre/Post-Operation Plug-Ins

This chapter explains how to write functions that the server calls before and after executing an LDAP operation. These functions are called pre-operation and post-operation plug-in functions.


How Pre/Post-Operation Plug-Ins Work
The Netscape Directory Server can perform the following LDAP operations:

(Note that the Directory Server can also perform extended operations. Extended operations are defined as part of the LDAP v3 protocol. For information on implementing plug-in functions to execute extended operations, see Chapter  11, "Writing Extended Operation Plug-Ins".)

You can set up the Directory Server to call your own plug-in functions before and after executing these LDAP operations. For example, you can write a function that validates an entry before the server performs an LDAP add operation to add it to the directory. Or you can write a function that notifies a user whose entry has just been modified by an LDAP modify operation.

You can also set up the Directory Server to call your own plug-in functions before and after:

Figure 6.1 illustrates how the Directory Server front-end calls pre-operation and post-operation functions before and after executing an LDAP operation.

Figure 6.1 How the server calls pre-operation and post-operation plug-in functions


Writing Pre/Post-Operation Functions
As is the case with other server plug-in functions (see "Working with Parameter Blocks" on page  30), pre-operation functions and post-operation functions are specified in a parameter block that you can set on server startup. Each function corresponds to an ID in the parameter block. In your initialization function, you can call the slapi_pblock_set() function to specify the name of your function that corresponds to the pre-operation or post-operation function.

Types of Pre-Operation Functions

Table 6.1 lists the Directory Server pre-operation functions and the purpose of each function.

Table 6.1 Functions called before the Directory Server executes an operation

ID in Parameter Block
Description
SLAPI_PLUGIN_PRE_BIND_FN

Specifies the function called before the Directory Server executes an LDAP bind operation.
For information on writing this type of function, see "Processing an LDAP Bind Operation" on page  99.
SLAPI_PLUGIN_PRE_UNBIND_FN

Specifies the function called before the Directory Server executes an LDAP unbind operation.
For information on writing this type of function, see "Processing an LDAP Unbind Operation" on page  101.
SLAPI_PLUGIN_PRE_SEARCH_FN

Specifies the function called before the Directory Server executes an LDAP search operation.
For information on writing this type of function, see "Processing an LDAP Search Operation" on page  101.
SLAPI_PLUGIN_PRE_COMPARE_FN

Specifies the function called before the Directory Server executes an LDAP compare operation.
For information on writing this type of function, see "Processing an LDAP Compare Operation" on page  105.
SLAPI_PLUGIN_PRE_ADD_FN

Specifies the function called before the Directory Server executes an LDAP add operation.
For information on writing this type of function, see "Processing an LDAP Add Operation" on page  106.
SLAPI_PLUGIN_PRE_MODIFY_FN

Specifies the function called before the Directory Server executes an LDAP modify operation.
For information on writing this type of function, see "Processing an LDAP Modify Operation" on page  108.
SLAPI_PLUGIN_PRE_MODRDN_FN

Specifies the function called before the Directory Server executes an LDAP modify RDN operation.
For information on writing this type of function, see "Processing an LDAP Modify RDN Operation" on page  109.
SLAPI_PLUGIN_PRE_DELETE_FN

Specifies the function called before the Directory Server executes an LDAP delete operation.
For information on writing this type of function, see "Processing an LDAP Delete Operation" on page  111.
SLAPI_PLUGIN_PRE_ABANDON_FN

Specifies the function called before the Directory Server executes an LDAP abandon operation.
For information on writing this type of function, see "Processing an LDAP Abandon Operation" on page  112.
SLAPI_PLUGIN_PRE_ENTRY_FN

Specifies the function called before the Directory Server sends an entry back to the client (for example, when you call slapi_send_ldap_search_entry(), the pre-operation entry function is called before the entry is sent back to the client).
SLAPI_PLUGIN_PRE_REFERRAL_FN

Specifies the function called before the Directory Server sends a referral back to the client (for example, when you call slapi_send_ldap_referral(), the pre-operation referral function is called before the referral is sent back to the client).
SLAPI_PLUGIN_PRE_RESULT_FN

Specifies the function called before the Directory Server sends a result code back to the client (for example, when you call slapi_send_ldap_result(), the pre-operation result function is called before the result code is sent back to the client).

Types of Post-Operation Functions

Table 6.2 lists the Directory Server post-operation functions and the purpose of each function.

Table 6.2 Functions called after the Directory Server executes an operation

ID in Parameter Block
Description
SLAPI_PLUGIN_POST_BIND_FN

Specifies the function called after the Directory Server executes an LDAP bind operation.
For information on writing this type of function, see "Processing an LDAP Bind Operation" on page  99.
SLAPI_PLUGIN_POST_UNBIND_FN

Specifies the function called after the Directory Server executes an LDAP unbind operation.
For information on writing this type of function, see "Processing an LDAP Unbind Operation" on page  101.
SLAPI_PLUGIN_POST_SEARCH_FN

Specifies the function called after the Directory Server executes an LDAP search operation.
For information on writing this type of function, see "Processing an LDAP Search Operation" on page  101.
SLAPI_PLUGIN_POST_COMPARE_FN

Specifies the function called after the Directory Server executes an LDAP compare operation.
For information on writing this type of function, see "Processing an LDAP Compare Operation" on page  105.
SLAPI_PLUGIN_POST_ADD_FN

Specifies the function called after the Directory Server executes an LDAP add operation.
For information on writing this type of function, see "Processing an LDAP Add Operation" on page  106.
SLAPI_PLUGIN_POST_MODIFY_FN

Specifies the function called after the Directory Server executes an LDAP modify operation.
For information on writing this type of function, see "Processing an LDAP Modify Operation" on page  108.
SLAPI_PLUGIN_POST_MODRDN_FN

Specifies the function called after the Directory Server executes an LDAP modify RDN operation.
For information on writing this type of function, see "Processing an LDAP Modify RDN Operation" on page  109.
SLAPI_PLUGIN_POST_DELETE_FN

Specifies the function called after the Directory Server executes an LDAP delete operation.
For information on writing this type of function, see "Processing an LDAP Delete Operation" on page  111.
SLAPI_PLUGIN_POST_ABANDON_FN

Specifies the function called after the Directory Server executes an LDAP abandon operation.
For information on writing this type of function, see "Processing an LDAP Abandon Operation" on page  112.
SLAPI_PLUGIN_POST_ENTRY_FN

Specifies the function called after the Directory Server sends an entry back to the client (for example, when you call slapi_send_ldap_search_entry(), the post-operation entry function is called after the entry is sent back to the client).
SLAPI_PLUGIN_POST_REFERRAL_FN

Specifies the function called after the Directory Server sends a referral back to the client (for example, when you call slapi_send_ldap_referral(), the pre-operation referral function is called after the referral is sent back to the client).
SLAPI_PLUGIN_POST_RESULT_FN

Specifies the function called after the Directory Server sends a result code back to the client (for example, when you call slapi_send_ldap_result(), the pre-operation result function is called after the result code is sent back to the client).


Registering Pre/Post-Operation Functions
To register your pre-operation and post-operation plug-in functions, you need to write an initialization function and then configure the server to load your plug-in.

For details, follow the procedures outlined in "Writing an Initialization Function" on page  34 and "Configuring the Server" on page  39.

Note. Each pre-operation and post-operation plug-in is associated with a back-end. Make sure that the plugin directive that registers the plug-in is within the database section for that back-end in the slapd.conf file. (The plugin directive should be after the database directive and before the next database directive, if any.)

 

© Copyright 1998 Netscape Communications Corporation