Last active
February 1, 2022 16:00
-
-
Save jwhite66/128aea1b186eaed4c58accfe30590d5f to your computer and use it in GitHub Desktop.
Plugin intialization code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dn: cn=Example Plug-in,cn=plugins,cn=config | |
objectclass: top | |
objectclass: nsSlapdPlugin | |
objectclass: extensibleObject | |
cn: Example Plug-in | |
nsslapd-pluginpath: libexample-plugin | |
nsslapd-plugininitfunc: init_plugin | |
nsslapd-plugintype: preoperation | |
nsslapd-pluginenabled: off | |
nsslapd-pluginid: none | |
nsslapd-pluginversion: none | |
nsslapd-pluginvendor: none | |
nsslapd-plugindescription: none | |
nsslapd-pluginPrecedence: 20 | |
/* | |
* Initialize our plugin | |
*/ | |
int init_plugin(Slapi_PBlock * pb) | |
{ | |
int rc = 0; | |
slapi_log_error(SLAPI_LOG_PLUGIN, PB_PLUGIN_SUBSYSTEM, "Example init\n"); | |
/* Seed the random system */ | |
if (!seed_random()) | |
{ | |
slapi_log_error(SLAPI_LOG_FATAL, PB_PLUGIN_SUBSYSTEM, | |
"Example: Failed to seed random number generator\n"); | |
return -1; | |
} | |
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &_g_plugin_identity); | |
/* Plugin versions and such */ | |
rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_03); | |
rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, (void *)&pb_desc); | |
rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_START_FN, (void *)pb_start); | |
rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_CLOSE_FN, (void *)pb_close); | |
/* We will want to clean up things on unbind */ | |
rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_UNBIND_FN, (void *)pb_unbind); | |
/* We want to control the entry before it is sent */ | |
rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_ENTRY_FN, (void *)pb_entry); | |
/* We want to control Modify as well */ | |
rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_MODIFY_FN, (void *)pb_modify); | |
/* We want to make sure Compare is not use to guess security data */ | |
rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_PRE_COMPARE_FN, (void *)pb_compare); | |
if (rc != 0) | |
{ | |
slapi_log_error(SLAPI_LOG_FATAL, PB_PLUGIN_SUBSYSTEM, | |
"Example init failed\n"); | |
return -1; | |
} | |
/* Register ourselves for Extend Operation also */ | |
slapi_register_plugin("extendedop", 1, "init_plugin", init_extendedop, | |
"Example Extend Operation Plug-in", NULL, | |
_g_plugin_identity); | |
slapi_log_error(SLAPI_LOG_PLUGIN, PB_PLUGIN_SUBSYSTEM, "Example success\n"); | |
return 0; | |
} | |
/* | |
* Initialize our extended operations | |
*/ | |
int init_extendedop(Slapi_PBlock * pb) | |
{ | |
int rc = 0; | |
slapi_log_error(SLAPI_LOG_PLUGIN, PB_PLUGIN_SUBSYSTEM, | |
"Example extendedop init\n"); | |
rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_VERSION_01); | |
rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_DESCRIPTION, | |
(void *)&pb_exop_desc); | |
/* Extended Operation */ | |
rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_OIDLIST, | |
(void *)extend_exop_oid_list); | |
rc |= slapi_pblock_set(pb, SLAPI_PLUGIN_EXT_OP_FN, (void *) &pb_extendedop); | |
if (rc != 0) | |
{ | |
slapi_log_error(SLAPI_LOG_FATAL, PB_PLUGIN_SUBSYSTEM, | |
"Extended init failed\n"); | |
return -1; | |
} | |
slapi_log_error(SLAPI_LOG_PLUGIN, PB_PLUGIN_SUBSYSTEM, | |
"Extended success\n"); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment