3.4. Passing Extra Arguments to Plug-ins

The standard method for configuring plug-ins is to provide configuration parameters as attributes and values in the plug-in entry in the dse.ldif file. All plug-ins use the extensibleObject object class, so any custom attribute can be added to that object class in the schema. A better alternative is to define a custom auxiliary object class which contains the custom plug-in configuration attributes.
Use the plug-in start function (registered in the initialization function with slapi_pblock_set() using SLAPI_PLUGIN_START_FN) to use the custom configuration. One of the pblock parameters passed to the start function is the plug-in entry, as the SLAPI_ADD_TARGET parameter. The slapi_entry_attr_* family of functions can be used to get and use these values.
Plug-ins can be dynamically configured at run-time by registering DSE callbacks for the plug-in entry with slapi_config_register_callback_plugin().

Example 3.2. Extended Operation Plug-in

dn: cn=Test Extended Op,cn=plugins,cn=config
objectClass: top
objectClass: nsSlapdPlugin
objectClass: extensibleObject
cn: Test ExtendedOp
nsslapd-pluginPath: 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

Example 3.3. MemberOf Plug-in

dn: cn=MemberOf Plugin,cn=plugins,cn=config 
objectClass: top 
objectClass: nsSlapdPlugin 
objectClass: extensibleObject 
cn: MemberOf Plugin 
nsslapd-pluginPath: libmemberof-plugin
nsslapd-pluginInitfunc: memberof_postop_init 
nsslapd-pluginType: postoperation 
nsslapd-pluginEnabled: off 
nsslapd-plugin-depends-on-type: database 
memberofgroupattr: member 
memberofattr: memberOf 
nsslapd-pluginId: memberof 
nsslapd-pluginVersion: 1.1.4 
nsslapd-pluginVendor: Fedora Project 
nsslapd-pluginDescription: memberof plugin
This method allows for a much more descriptive configuration, which is easier to maintain. The attributes beginning with pam are specific to the plug-in and used for its configuration. The plug-in entry is provided to the plug-in start function as a Slapi_Entry * in the SLAPI_ADD_TARGET pblock parameter. Use the slapi_entry_attr_* family of functions to get the configuration values from that entry.
For additional information, code samples are available from the 389 Directory Server repositories at http://git.fedorahosted.org/cgit/389/ds.git/tree/ldap/servers/plugins and http://git.fedorahosted.org/cgit/389/ds.git/tree/ldap/servers/slapd/test-plugins. The plug-in samples are in the /usr/lib64/dirsrv/plugins directory.