|
||
|
|
Chapter 9 Writing Entry Store/Fetch Plug-Ins
This chapter describes how to write entry store and entry fetch plug-ins. You can use these types of plug-ins to invoke functions before and after data is read from the default database.
The chapter contains the following sections:
- How Entry Store/Fetch Plug-Ins Work
![]()
- Writing Entry Store/Fetch Functions
![]()
- Registering Entry Store/Fetch Functions
![]()
How Entry Store/Fetch Plug-Ins Work
Entry store plug-in functions are called before data is written to the database. Entry fetch plug-in functions are called after data is read from the default database. This processing is illustrated in Figure 9-1.
Figure 9-1 How the Server Calls Entry Store and Entry Fetch Plug-In Functions
![]()
Writing Entry Store/Fetch Functions
Unlike most other types of plug-in functions, entry store and entry fetch plug-in functions are not passed a parameter block when called. Instead, entry store and entry fetch plug-in functions must have the following prototype:
void function_name( char **entry, unsigned long *len );
On Windows platforms, use the following prototype and make sure to include the function in a
.deffile:__declspec( dllexport ) \
void function_name( char **entry, unsigned long *len );The parameters are described below:
Pointer to a string specifying the entry in LDIF format; for details on this format, see slapi_filter_free().
Since the text of the entry is passed in as an argument, you can modify the entry before it gets saved to disk and modify the entry after it is read from disk.
For example entry store and entry fetch plug-in functions, check this source file in your installation:
<server_root>/plugins/slapd/slapi/examples/testentry.c
Registering Entry Store/Fetch Functions
Unlike most other types of plug-in functions, you do not register an entry store or entry fetch plug-in function by setting the function name in the parameter block. Instead, you specify the function name directly in the server configuration file.
In Directory Server 6.x, shut down the server, add the plug-in parameters to the
dse.ldiffile, and restart the server (see Chapter 3 "Configuring Plug-Ins"). For example, your plug-in entry might look like this:
dn: cn=Test entry,cn=plugins,cn=config
objectClass: top
objectClass: nsSlapdPlugin
objectClass: extensibleObject
cn: Test entry
nsslapd-pluginPath: /usr/netscape/servers/plugins/slapd/slapi/
examples/libtest-plugin.so
nsslapd-pluginInitfunc: testentry_init
nsslapd-pluginType: ldbmentryfetchstore
nsslapd-pluginEnabled: on
nsslapd-pluginId: test-entryFor example plug-in functions that implement entry store and entry fetch operations, take a look at this source file:
<server_root>/plugins/slapd/slapi/examples/testentry.cIn Directory Server 4.x, add a directive, to the
slapd.ldbm.conffile, in the following form to specify the name and location of your plug-in function:
plugin entrystore [on|off] "<name of plugin>" \
<library_name> <function_name>
plugin entryfetch [on|off] "<name of plugin>" \
<library_name> <function_name>
<library_name>is the name and path to your shared library or dynamic link library, and<function_name>is the name of your plug-in function.For example, the following directives register the function named
my_store()as the entry store plug-in function andmy_fetch()as the entry fetch plug-in function. Both functions are defined in the library/usr/nslib/myentry.so.plugin entrystore on "my entrystore plugin" \
/serverroot/myentry.so my_storeplugin entryfetch on "my entryfetch plugin" \
/serverroot/myentry.so my_fetchEach entry store and entry fetch plug-in is associated with the default
ldbmback-end. Make sure that theplugindirective that registers the plug-in is within the database section forldbmin theslapd.ldbm.conffile for Directory Server 4.x. Theplugindirective should be after thedatabaseldbmdirective and before the nextdatabasedirective, if any.
© 2001 Sun Microsystems, Inc. Portions copyright 1999, 2002-2003 Netscape Communications Corporation. All rights reserved.
Read the Full Copyright and Thrid-Party Acknowledgments.
Last Updated October 30, 2003