瀏覽代碼

pass the plugin config entry to the plugin init function

A plugin init function can get the plugin config entry (that is, its own
config entry) by using the pblock parameter SLAPI_PLUGIN_CONFIG_ENTRY
int
my_plugin_init(Slapi_PBlock *pb)
{
  Slapi_Entry *my_config_entry = NULL;
  slapi_pblock_get(pb, SLAPI_PLUGIN_CONFIG_ENTRY, &my_config_entry);
Reviewed by: nkinder, nhosoi (Thanks!)
Rich Megginson 14 年之前
父節點
當前提交
b6d3ba7768
共有 3 個文件被更改,包括 19 次插入1 次删除
  1. 1 0
      ldap/servers/slapd/plugin.c
  2. 13 1
      ldap/servers/slapd/plugin_internal_op.c
  3. 5 0
      ldap/servers/slapd/slapi-plugin.h

+ 1 - 0
ldap/servers/slapd/plugin.c

@@ -2294,6 +2294,7 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group,
 	}
 
 	slapi_pblock_set(&pb, SLAPI_PLUGIN_ENABLED, &enabled);
+	slapi_pblock_set(&pb, SLAPI_PLUGIN_CONFIG_ENTRY, plugin_entry);
 
 	if ((*initfunc)(&pb) != 0)
 	{

+ 13 - 1
ldap/servers/slapd/plugin_internal_op.c

@@ -876,7 +876,7 @@ void set_common_params (Slapi_PBlock *pb)
  * copy of the entry, NULL can be passed for ret_entry.
  */
 int
-slapi_search_internal_get_entry( Slapi_DN *dn, char ** attrs, Slapi_Entry **ret_entry , void * component_identity)
+slapi_search_internal_get_entry_ext( Slapi_DN *dn, char ** attrs, Slapi_Entry **ret_entry , void * component_identity, void *txn )
 {
     Slapi_Entry **entries = NULL;
     Slapi_PBlock *int_search_pb = NULL;
@@ -892,6 +892,7 @@ slapi_search_internal_get_entry( Slapi_DN *dn, char ** attrs, Slapi_Entry **ret_
 								   0 /* attrsonly */, NULL /* controls */,
 								   NULL /* uniqueid */,
 								   component_identity, 0 /* actions */ );
+	slapi_pblock_set( int_search_pb, SLAPI_TXN, txn );
 	slapi_search_internal_pb ( int_search_pb );
     slapi_pblock_get( int_search_pb, SLAPI_PLUGIN_INTOP_RESULT, &rc );
     if ( LDAP_SUCCESS == rc ) {
@@ -913,3 +914,14 @@ slapi_search_internal_get_entry( Slapi_DN *dn, char ** attrs, Slapi_Entry **ret_
 	int_search_pb = NULL;
     return rc;
 }
+
+/*
+ * Given a DN, find an entry by doing an internal search.  An LDAP error
+ * code is returned.  To check if an entry exists without returning a
+ * copy of the entry, NULL can be passed for ret_entry.
+ */
+int
+slapi_search_internal_get_entry( Slapi_DN *dn, char ** attrs, Slapi_Entry **ret_entry , void * component_identity)
+{
+	return slapi_search_internal_get_entry_ext(dn, attrs, ret_entry, component_identity, NULL);
+}

+ 5 - 0
ldap/servers/slapd/slapi-plugin.h

@@ -5118,6 +5118,9 @@ void slapi_seq_internal_set_pb(Slapi_PBlock *pb, char *ibase, int type,
  */
 int slapi_search_internal_get_entry( Slapi_DN *dn, char ** attrlist,
 	Slapi_Entry **ret_entry , void *caller_identity);
+/* same as above but can pass in the txn to use */
+int slapi_search_internal_get_entry_ext( Slapi_DN *dn, char ** attrlist,
+	Slapi_Entry **ret_entry , void *caller_identity, void *txn );
 
 /* 
  * interface for registering object extensions.
@@ -6099,6 +6102,8 @@ typedef struct slapi_plugindesc {
 */
 #define	SLAPI_SEARCH_ENTRY_ORIG		SLAPI_ENTRY_PRE_OP
 #define	SLAPI_SEARCH_ENTRY_COPY		SLAPI_ENTRY_POST_OP
+/* for plugin init functions, this is the plugin config entry */
+#define SLAPI_PLUGIN_CONFIG_ENTRY   SLAPI_ENTRY_PRE_OP
 
 /* LDAPv3 controls to be sent with the operation result */
 #define SLAPI_RESCONTROLS			55