After you compile your server plug-in, you need to configure the Netscape Directory Server (Directory Server) so that it properly loads your plug-in. The following sections in this chapter show how this is done:
To add your plug-in to the Directory Server configuration, you need to create an LDIF representation of your plug-in entry, add the plug-in entry to the Directory Server configuration, and reload the server configuration. This section illustrates how to create your plug-in entry. The section Loading the Plug-in Configuration File, explains how to add the plug-in entry to the Directory Server configuration and reload the server configuration.
The plug-in configuration file must be an LDIF file written in ASCII format. Code Example 3-1 shows the contents of an example plug-in configuration file. Note that line numbers have been added for ease of reference; do not number the lines in your own LDIF file.
|
|
|
|
This example plug-in configuration file defines an example plug-in as follows:
You can specify that your plug-in is dependent on one or more different plug-ins. If you do specify any plug-in dependencies, those plug-ins that you specify must properly start before your associated plug-in will start.
There are two attributes that you can use in the plug-in configuration file to specify the dependencies of your plug-in:
Each of these attributes can take multiple
values, meaning that your plug-in depends on one or more other plug-ins.
If you specify the nsslapd-plugin-depends-on-name attribute in your plug-in configuration file, set its value to the names of one or more plug-ins. For example, in your plug-in configuration file, you could specify the following:
nsslapd-plugin-depends-on-name:
my_pluginA
nsslapd-plugin-depends-on-name:
vendor_pluginB
In this example, the plug-in depends on two
specifically named plug-ins: my_pluginA
and vendor_pluginB.
This configuration line indicates that before your plug-in can be
loaded, the two specifically named plug-ins must be loaded. If either
of these two plug-ins fail to load, the Directory Server will exit with
a
-1 error code.
If you specify the nsslapd-plugin-depends-on-type attribute in your plug-in configuration file, set its value to one or more plug-in types. For example, in your plug-in configuration file, you could specify the following:
nsslapd-plugin-depends-on-type: syntax
This configuration line indicates that your plug-in depends on any plug-in of the type syntax. If there is a configured plug-in of type syntax, it must be successfully loaded before your plug-in can be loaded; otherwise, the Directory Server will exit with a -1 error code.
Note that if you specify a plug-in type
dependency, the Directory Server will search for any and all plug-ins
of the type(s) specified. If none are found, processing will continue
without errors. However, the Directory Server must load all plug-ins of
the type(s) specified before it can load your plug-in. For a complete
list of the supported plug-in types, refer to the Summary of Plug-in Directives.
You cannot in general rely on plug-ins being called in a certain order. For example, you cannot rely on a particular pre-operation plug-in to be called before another. You should ensure that your plug-in is written in such a way as to make it independent of the order in which it will be called.
If you must use ordering, you can make use of
alphabetical order. The server loads the plug-ins in alphabetical
order--that is, the loading order is determined by standard ASCII
ordering of the
cn value of the plug-in entry, which appears under cn=plugins,cn=config
in the
dse.ldif file. Because this feature may be deprecated in a
future version of the product, it is recommended that you write your
plug-in not to rely on any specific loading order.
The following table summarizes the different types of plug-ins that you can specify in the plug-in configuration file.
After you have written the plug-in configuration file, you must load it into the dse.ldif file, which is located in the <server_root>/slapd-<instance_id>/config directory. You can do this either by using an LDAP utility, such as ldapmodify, or by editing the file directly. If you choose to edit the file directly, be sure to shut down the Directory Server first.
The following line shows an example of an LDAP command that loads the plug-in defined in the configuration file example-plugin.ldif:
ldapmodify -h my_host -p 389 -a -D "cn=
Directory Manager" \
-w adminadmin -f example-plugin.ldif
Once the plug-in configuration is loaded, you must shut down the Directory Server and then restart it before you can make calls to your plug-in. There are various ways to shut down and restart the Directory Server; for example, you can:
In the Directory Server 4.x version, you could specify additional arguments at the end of the plugin directive. For example:
plugin
preoperation /usr/lib/myplugin.so my_init_fn \
arg1 arg2
From the initialization function and the plug-in functions, you can get these arguments by getting the following parameters from the parameter block.
However, plug-ins in later releases of Directory Server must not start up in the init function. They must start up in the start function. The preferred method of communicating plug-in specific configuration is through custom attribute-value pairs in the plug-in entry (in the dse.ldif file). Two examples are shown below:
dn: cn=Test
ExtendedOp,cn=plugins,cn=config
objectClass:
top
objectClass:
nsSlapdPlugin
objectClass:
extensibleObject
cn: Test
ExtendedOp
nsslapd-pluginPath:
/usr/netscape/servers/plugins/slapd/slapi/
examples/libtest-plugin.so
nsslapd-pluginInitfunc:
testexop_init
nsslapd-pluginType:
extendedop
nsslapd-pluginEnabled:
on
nsslapd-plugin-depends-on-type:
database
nsslapd-pluginId:
test-extendedop
nsslapd-pluginarg0: 1.2.3.4
dn:
cn=Internationalization Plugin,cn=plugins,cn=config
objectClass:
top
objectClass:
nsSlapdPlugin
objectClass:
extensibleObject
cn:
Internationalization Plugin
nsslapd-pluginPath:
d:/netscape/servers/lib/liblcoll.dll
nsslapd-pluginInitfunc:
orderingRule_init
nsslapd-pluginType:
matchingRule
nsslapd-pluginEnabled:
on
nsslapd-pluginarg0:
d:/netscape/servers/slapd-host/config/slapd-collations.conf
nsslapd-pluginId: orderingrule
nsslapd-pluginVersion:
6.0
nsslapd-pluginVendor:
Netscape Communications Corporation
nsslapd-pluginDescription:
internationalized ordering rule plugin
This method allows for more descriptive configuration, which is easier to maintain. To find the plug-in entry DN, retrieve SLAPI_TARGET_DN from the pblock passed to your start function. Once the DN is known, the normal plug-in API functions for entry retrieval and manipulation can be used for configuration retrieval.
For additional information, check the code samples provided here:
<server_root>/plugins/slapd/slapi/examples
If your functions call the slapi_new_condvar() function to write messages to the error log, you need to make sure that the Directory Server is configured to log messages with the severity level you've specified. The available severity levels are fully documented in the Reference section on slapi_new_condvar().
For example, suppose you call this function in your plug-in:
slapi_log_error(
SLAPI_LOG_PLUGIN, "searchdn_preop_init",
"Plug-in
successfully registered.\n" );
You need to make sure that the Directory
Server is configured to log messages with the severity level SLAPI_LOG_PLUGIN.
This corresponded in 4.x releases to the log level of plugin.
| Previous |
Contents |
Index |
DocHome | Next |