This chapter contains reference information on Netscape Directory Server (Directory Server) server plug-in API. The server plug-in API includes the following functions:
Each section summarizes the front-end functions in a table followed by the function details.
This section contains
reference information
on distribution routines.
Table 15-1
Distribution Routines
Allows for backend distribution.
#include
"slapi-plugin.h"
int
distribution_plugin_entry_point (Slapi_PBlock *pb,
Slapi_DN
*target_dn, char **mtn_be_names, int be_count,
Slapi_DN *
node_dn);
This function should return the index of the backend in the mtn_be_names table that is used to resolve the current operation. For search operations, SLAPI_BE_ALL_BACKENDS can be returned to specify that backends must be searched. The use of SLAPI_BE_ALL_BACKENDS for non-search operations is not supported and may give random results.
Backend distribution is the capability to span the LDAP subtree contents under a specified DIT node into multiple backends in the same server and/or database links to other servers. Under such a configuration, this function is responsible for deciding where the database or database link under the DIT node will be applied. This function will be called for ever operation reaching a DIT node, including subtree search operations that are started above the node.
This function can only be called if the server has been configured to take advantage of such capability.
This section contains
reference information
on access control routines.
Table 15-2
Access Control Routines
Determines if a user (who is requesting the current operation) has the access rights to perform an operation on a given entry, attribute, or value.
#include
"slapi-plugin.h"
int
slapi_access_allowed( Slapi_PBlock *pb, Slapi_Entry *e,
char *attr,
struct berval *val, int access );
This function takes the following parameters:
The value of the access argument can be one of the following:
This function returns one of the following values:
Call this function to determine if a user has access rights to a specified entry, attribute, or value. The function performs this check for users who request the operation that invokes this plug-in.
For example, suppose you are writing a pre-operation plug-in for the add operation. You can call this function to determine if users have the proper access rights before they can add an entry to the directory.
As part of the process of determining if the user has access rights, the function does the following:
ACLs can be set up to allow users the rights to modify their own entries. The slapi_access_allowed() function checks for this condition.
The caller must ensure that the backend specified in the pblock is set prior to calling this function. For example:
be =
slapi_be_select(
slapi_entry_get_sdn_const( seObjectEntry ));
if ( NULL ==
be ) {
cleanup("backend
selection failed for entry: \"%s\"\n",
szObjectDN);
slapi_send_ldap_result(
pb, LDAP_NO_SUCH_OBJECT, NULL,
" Object
could not be found", 0, NULL );
return(
SLAPI_PLUGIN_EXTENDED_SENT_RESULT );
}
slapi_pblock_set(
pb, SLAPI_BACKEND, be );
nAccessResult
= slapi_access_allowed( pb, seObjectEntry,
"*", bval,
SLAPI_ACL_DELETE);
Determines if a user has the rights to perform the specified modifications on an entry.
#include
"slapi-plugin.h"
int
slapi_acl_check_mods( Slapi_PBlock *pb, Slapi_Entry *e,
LDAPMod
**mods, char **errbuf );
This function returns one of the following values:
Call this function to determine if a user has access rights to modify the specified entry. The function performs this check for users who request the operation that invokes this plug-in.
Suppose you are writing a database plug-in. You can call this function to determine if users have the proper access rights before they can add, modify, or delete entries from the database.
As part of the process of determining if the user has access rights, the slapi_access_allowed() function does the following:
You must free the errbuf buffer by calling slapi_ch_free() when you are finished using the error message.
Determines whether the access control items (ACIs) on an entry are valid.
You must free the errbuf buffer by calling slapi_ch_free() when you are finished using the error message.
This section contains
reference information
on routines for internal operations and plug-in callbacks. These
functions can be used for internal operations based on DN as well as on
unique ID. These functions should be used by all new plug-ins, and,
preferably, old plug-ins should be changed to use them to take
advantage of new plug-in configuration capabilities and to use an
extensible interface.
Table 15-3
Internal Operations and Plug-in Callback Routines
Adds an LDAP add operation based on a parameter block to add a new directory entry.
Performs an LDAP delete operation based on a parameter block to remove a directory entry.
Frees search results returned by the slapi_search_internal_pb() and slapi_search_internal_callback_pb() functions.
This function takes the following parameters:
|
Parameter block returned by the slapi_search_internal_pb() and slapi_search_internal_callback_pb() functions. |
Performs an LDAP modify operation based on a parameter block to modify a directory entry.
Performs an LDAP modify RDN operation based on a parameter block to rename a directory entry.
Performs an LDAP search operation based on a parameter block to search the directory. Unlike slapi_search_internal_pb(), this function allows you to specify callback functions that are invoked when the search operation finds matching entries or entries with referrals.
#include
"slapi-plugin.h"
int
slapi_search_internal_callback_pb(Slapi_PBlock *pb,
void
*callback_data,plugin_result_callback prc,
plugin_search_entry_callback
psec,
plugin_referral_entry_callback
prec);
This function takes the following parameters:
|
A parameter block that has been initialized using slapi_seq_internal_callback_set_pb(). |
|
|
A pointer to arbitrary plug-in or operation-specific data that you would like to pass to your callback functions. |
|
|
Callback function that the server calls to send result codes. The function must have the prototype specified by plugin_result_callback. |
|
|
Callback function that the server calls when finding a matching entry in the directory. The function must have the prototype specified by plugin_search_entry_callback. |
|
|
Callback function that the server calls when finding an entry that contains LDAPv3 referrals. The function must have the prototype specified by plugin_referral_entry_callback. |
Like slapi_search_internal_pb(), this function allows you to search the directory from a plug-in function. Unlike a search operation requested by a client, no result code, search entries, or referrals are sent to a client by slapi_search_internal_callback_pb(). However, you can write your own callback functions that are invoked when these events occur:
The entries passed to the search entry callback function do not need to be freed. If you need to access an entry after returning from the callback function, call slapi_entry_dup() to make a copy.
The referral URLs passed to the referral entry callback function do not need to be freed. If you need to access a referral string after returning from the callback function, call slapi_ch_strdup() to make a copy.
You do not need to call slapi_free_search_results_internal() after calling slapi_search_internal_callback_pb().
Performs an internal search operation to read one entry; it performs a base object search.
#include
"slapi-plugin.h"
int
slapi_search_internal_get_entry( Slapi_DN *dn,
char **
attrlist, Slapi_Entry **ret_entry, void *caller_identity);
This function takes the following parameter:
|
A NULL terminated array of attribute types to return from entries that match filter. If you specify a NULL, all attributes will be returned. |
|
|
The address of a Slapi_Entry pointer to receive the entry if it is found. |
|
|
A plug-in or component identifier. This value can be obtained from the SLAPI_PLUGIN_IDENTITY field of the parameter block that is passed to your plug-in initialization function. |
This function performs an internal search operation to read one entry; that is, it preforms a base object search. If an entry named by dn is found, the ret_entry pointer will be set to point to a copy of the entry that contains the attribute values specified by the attrlist parameter.
The returned entry (*ret_entry) should be freed by calling slapi_entry_free().
Performs an LDAP search operation based on a parameter block to search the directory.
This function performs an internal search based on a parameter block. The parameter block should be initialized by calling the slapi_search_internal_set_pb() function.
slapi_free_search_results_internal()
should be called to
dispose of any entires and other items that were allocated by a call
to slapi_search_internal_pb().
This section contains reference information on routines for
setting internal-operation flags.
Table 15-4
Internal Operation Flag Routines
|
Sets up a parameter block so that it can be used by slapi_add_internal_pb() for an internal add operation. |
|
|
Sets up a parameter block so that it can be used by slapi_add_internal_pb() for an internal add operation; the entry is constructed from a DN and a set of attributes. |
|
|
Sets up a parameter block so that it can be used by slapi_delete_internal_pb() for an internal delete operation. |
|
|
Sets up a parameter block so that it can be used by slapi_modify_internal_pb() for an internal modify operation. |
|
|
Sets up a parameter block so that it can be used by slapi_modrdn_internal_pb() for an internal rename operation. |
|
|
Sets up a parameter block so that it can be used by slapi_search_internal_pb() for an internal search operation. |
|
|
Sets up a parameter block for use by slapi_seq_internal_callback_pb() for an internal sequential-access operation. |
Sets up a parameter block so that it can be used by slapi_add_internal_pb() for an internal add operation.
#include
"slapi-plugin.h"
void
slapi_add_entry_internal_set_pb(Slapi_PBlock *pb,
Slapi_Entry
*e, LDAPControl **controls,
Slapi_ComponentId
*plugin_identity, int operation_flags);
This function takes the following parameters:
This function populates parameters in the pblock structure so that it can be used by slapi_add_internal_pb() for an internal add operation.
Sets up a parameter block so that it can be used by slapi_add_internal_pb() for an internal add operation.
#include
"slapi-plugin.h"
int
slapi_add_internal_set_pb(Slapi_PBlock *pb, const char *dn,
LDAPMod
**attrs, LDAPControl **controls,
Slapi_ComponentId
*plugin_identity, int operation_flags);
This function takes the following parameters:
This function is similar to slapi_add_entry_internal_set_pb() except that it constructs the entry from a DN and a set of attributes. The function sets pblock to contain the following data:
Sets up a parameter block so that it can be used by slapi_delete_internal_pb() for an internal delete operation.
#include
"slapi-plugin.h"
void
slapi_delete_internal_set_pb (Slapi_PBlock *pb, const char *dn,
LDAPControl
**controls, const char *uniqueid,
Slapi_ComponentId
*plugin_identity, int operation_flags);
This function takes the following parameters:
This function populates pblock to contain data for use by slapi_delete_internal_pb() for an internal delete operation.
Sets up a parameter block so that it can be used by slapi_modify_internal_pb() for an internal modify operation.
#include
"slapi-plugin.h"
void
slapi_modify_internal_set_pb(Slapi_PBlock *pb, const char *dn,
LDAPMod
**mods, LDAPControl **controls, const char *uniqueid,
Slapi_ComponentId
*plugin_identity, int operation_flags);
This function takes the following parameters:
This function populates pblock to contain data for use by slapi_modify_internal_pb() for an internal modify operation.
Sets up a parameter block so that it can be used by slapi_modrdn_internal_pb() for an internal rename operation.
#include
"slapi-plugin.h"
void
slapi_rename_internal_set_pb(Slapi_PBlock *pb,
const char
*olddn, const char *newrdn, const char *newsuperior,
int
deloldrdn, LDAPControl **controls, const char *uniqueid,
Slapi_ComponentId
*plugin_identity, int operation_flags);
This function takes the following parameters:
This function populates pblock with parameters for use by slapi_modrdn_internal_pb() for an internal rename operation. The function sets the parameter block to contain the following data.
For unique ID-based operation:
Sets up a parameter block so that it can be used by slapi_search_internal_pb() for an internal search operation.
#include
"slapi-plugin.h"
void
slapi_search_internal_set_pb(Slapi_PBlock *pb,
const char
*base, int scope, const char *filter, char **attrs,
int
attrsonly, LDAPControl **controls, const char *uniqueid,
Slapi_ComponentId
*plugin_identity, int operation_flags);
This function takes the following parameters:
This function sets up the parameter block, for subsequent use by slapi_search_internal_pb(), to contain the following data for an internal search operation.
Performs internal sequential access operation.
#include
"slapi-plugin.h"
int
slapi_seq_internal_callback_pb(Slapi_PBlock *pb,
void
*callback_data, plugin_result_callback res_callback,
plugin_search_entry_callback
srch_callback,
plugin_referral_entry_callback
ref_callback);
This function takes the following parameters:
|
Parameter block initialized with operation parameters. The easiest way to provide required parameters is by calling slapi_seq_internal_set_pb() function. Parameters can also be set directly. |
|
Sets up a parameter block for use by slapi_seq_internal_callback_pb() for an internal, sequential-access operation.
#include
"slapi-plugin.h"
void
slapi_seq_internal_set_pb(Slapi_PBlock *pb, char *ibase,
int type,
char *attrname, char *val, char **attrs, int attrsonly,
LDAPControl
**controls, Slapi_ComponentId *plugin_identity,
int
operation_flags);
This function sets up pblock for use by slapi_seq_internal_callback_pb() for an internal, sequential-access operation; the function sets up the parameter block contain the following data: