The Directory Server plug-in API allows you to develop plug-ins, libraries registered with a Directory Server instance that customize and extend server capabilities. This part provides a complete reference to the API.
This part includes the following chapters:
Chapter 15, Data Type and Structure Reference covers key data structures, not including the server parameter block
Chapter 16, Function Reference, Part I covers plug-in API functions, both by functional area and also in alphabetic order
Chapter 17, Function Reference, Part II continues coverage of the plug-in API functions, in alphabetic order
Chapter 18, Parameter Block Reference covers the server parameter block holding data pertaining to a particular operation
For help developing Directory Server plug-ins, read Part I, Directory Server Plug-In API Guide.
This chapter covers data types and structures for use in plug-in functions. Table 15–1 summarizes the list of available data structures. Table 15–2 summarizes the list of callbacks.
Data Structure or Callback |
Short Description |
---|---|
Binary data encoded using Basic Encoding Rules |
|
Information for use when handling computed attributes |
|
LDAP v3 control associated with an LDAP operation |
|
Set of modifications to a directory entry attribute |
|
Directory entry attribute |
|
Server backend |
|
Server assigned identifier, used for internal operations |
|
Condition variable for thread synchronization |
|
Client connection |
|
Distinguished Name |
|
Directory entry |
|
Search filter |
|
Matching rule handled by the plug-in |
|
A modification to an individual attribute |
|
Set of modifications to a directory entry |
|
Mutex for thread synchronization |
|
Pending LDAP operation |
|
Parameter block containing LDAP operation data |
|
Plug-in description that you provide |
|
Relative Distinguished Name |
|
Individual attribute value |
|
Set of values of an attribute |
|
Attribute that may be virtual |
Table 15–2 Quick Reference to Callbacks
Data Structure or Callback |
Short Description |
---|---|
Handles an extensible match filter |
|
Handles referrals found by internal search |
|
Handles results sent after internal search |
|
Handles entries found by internal search |
|
Determines scope of a role |
|
Modifies referrals before sending them to a client |
|
Modifies a result before sending it to a client |
|
Modifies an entry before sending it to a client |
|
Handles a computed attribute |
|
Calculates a computed attribute |
|
Handles object extension creation |
|
Handles object extension destruction |
|
Handles recursive plug-in registration |
Represents binary data encoded using simplified Basic Encoding Rules (BER).
Use a berval structure when working with binary attribute values such as a JPEG or audio file.
/* Defined in ldap.h, which is included by slapi-plugin.h */ #include "slapi-plugin.h" struct berval { unsigned long bv_len; char * bv_val; };
This structure has the following fields.
Table 15–3 berval Fields
Field |
Description |
---|---|
bv_len |
Size of the encoded data. |
bv_val |
Encoded data itself. |
An opaque structure representing information such as attribute type, current BER-encoded request and parameter block context for attributes that are computed.
#include "slapi-plugin.h" typedef struct _computed_attr_context computed_attr_context;
Before the server sends an entry to a client application, it determines whether any of the attributes are computed. If so, it generates those attributes and includes them in the entry.
As part of this process, the server creates a computed_attr_context structure to pass relevant information to functions generating the attribute values.
Represents a client or server control associated with an LDAP operation as specified by LDAP v3.
Client and server controls may be used to extend the functionality of an LDAP operation.
/* Defined in ldap.h, which is included by slapi-plugin.h */ #include "slapi-plugin.h" typedef struct ldapcontrol { char * ldctl_oid; struct berval ldctl_value; char ldctl_iscritical; } LDAPControl, * PLDAPControl;
This structure has the following fields.
Table 15–4 LDAPControl Fields
Field |
Description |
---|---|
ldctl_oid |
Object identifier (OID) for the control. |
ldctl_value |
berval structure containing the value used by the control for the operation. |
ldctl_iscritical |
LDAP_OPT_ON indicates the control is critical to the operation. If the control is critical to the operation but not supported, the server returns LDAP_UNAVAILABLE_CRITICAL_EXTENSION. LDAP_OPT_OFF indicates the control is not critical. |
Represents a modification to an attribute in a directory entry.
/* Defined in ldap.h, which is included by slapi-plugin.h */ #include "slapi-plugin.h" typedef struct ldapmod { int mod_op; char * mod_type; union { char ** modv_strvals; struct berval ** modv_bvals; } mod_vals; } LDAPMod; #define mod_values mod_vals.modv_strvals #define mod_bvalues mod_vals.modv_bvals
This structure has the following fields.
Table 15–5 LDAPMod Fields
Field |
Description |
---|---|
mod_op |
Operation to perform and data type of attribute values. The mod_op field takes the following values specifying the operation to perform.
|
mod_type |
Attribute type to modify. |
mod_values |
Pointer to NULL terminated array of string values for the attribute. |
mod_bvalues |
Pointer to NULL terminated array of berval structures for the attribute. |
Example 15–1 sets up an LDAPMod to change an mail address.
#include "slapi-plugin.h" /* Declare the appropriate structures. */ LDAPMod mod_attr; /* Attribute to modify */ LDAPMod * mods[2]; /* Array of modifications */ char * mail_vals[] = /* New mail address */ {"quentin@example.com", NULL}; /* Set up the LDAPMod structure used to modify the entry. */ mod_attr.mod_type = "mail"; mod_attr.mod_op = LDAP_MOD_REPLACE; mod_attr.mod_values = mail_vals; /* "quentin@example.com" */ mods[0] = &mod_attr; mods[1] = NULL; /* Modify the entry using slapi_modify_internal_set_pb()... */
Example 15–2 optionally adds additional modifications to those present in the parameter block. This code might be part of a pre-operation modify plug-in function, for example.
#include "slapi-plugin.h" /* * Set up an LDAPMod array, modify_mods, of additional modifications. */ if (modify_mods != NULL) { LDAPMod ** mods; Slapi_Mods smods; int i; slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods); slapi_mods_init_passin(&smods, mods); for (i = 0; modify_mods[i] != NULL; i++) { /* Do not copy mods. */ slapi_mods_add_ldapmod(&smods, modify_mods[i]); } mods = slapi_mods_get_ldapmods_passout(&smods); slapi_pblock_set(pb, SLAPI_MODIFY_MODS, mods); slapi_mods_done(&smods); /* Release container only. Content is still pointed to by mods. */ slapi_ch_free((void **)&modify_mods); }
Specifies a filter matching callback function. The server calls this function when processing a search operation, once for each candidate that matches an extensible match search filter.
#include "slapi-plugin.h" typedef int (*mrFilterMatchFn) (void* filter, Slapi_Entry* entry, Slapi_Attr* vals);
The callback takes the following parameters.
Table 15–6 mrFilterMatchFn Parameters
Parameter |
Description |
---|---|
filter |
Filter created by your filter factory function. |
entry |
Slapi_Entry representing the candidate entry checked by the server. |
vals |
Slapi_Attr representing the first attribute in the entry. Call slapi_entry_next_attr() to iterate through the rest of the attributes. |
The server calls this filter matching function when processing an extensible match filter using a matching rule plug-in. An extensible match filter specifies either the OID of a matching rule, or an attribute type, or both, that indicates how matching entries are found. For example, a sound-alike matching rule could be implemented to find all entries that sound like a given value.
To handle the extensible match filter for a matching rule, implement both this callback and a filter factor that creates the filter structure, filter. The callback retrieves information about the filter from this structure, such as the attribute type and value, then compares this information with attribute types and values in the candidate entry.
The callback must return 0 if the filter matches, -1 if the filter does not match. On error, it may return an LDAP error code as specified in the Result Message section of RFC 4511, Lightweight Directory Access Protocol (v3).
Specifies a referral callback function. The server calls this function when the internal search implemented to trigger this callback finds LDAP v3 referrals.
#include "slapi-plugin.h" typedef int (*plugin_referral_entry_callback)(char * referral, void *callback_data);
The callback takes the following parameters.
Table 15–7 plugin_referral_entry_callback Parameters
Parameter |
Description |
---|---|
referral |
URL of a reference found by the search. |
callback_data |
Pointer passed to the internal search operation. Use this to pass your own data between the callback function and the body of the plug-in. |
Pass this as the prec parameter of slapi_search_internal_callback_pb(). Each time the internal search finds a referral entry, it calls this function.
The server does not use the callback return value.
Specifies a search result callback function. The server calls this function when the internal search implemented to trigger this callback returns an LDAP result.
#include "slapi-plugin.h" typedef void (*plugin_result_callback)(int rc, void *callback_data);
The callback takes the following parameters.
Table 15–8 plugin_result_callback Parameters
Parameter |
Description |
---|---|
rc |
LDAP result code returned by the search. |
callback_data |
Pointer passed to the internal search operation. Use this to pass your own data between the callback function and the body of the plug-in. |
Pass this as the prc parameter of slapi_search_internal_callback_pb(). The server calls this function once for each search operation, unless the search is abandoned, in which case the function is not called.
Specifies an entry callback function. The server calls this function when the internal search implemented to trigger this callback finds an LDAP entry.
#include "slapi-plugin.h" typedef int (*plugin_search_entry_callback)(Slapi_Entry *e, void *callback_data);
The callback takes the following parameters.
Table 15–9 plugin_search_entry_callback Parameters
Parameter |
Description |
---|---|
e |
Pointer to the entry found by the search. |
callback_data |
Pointer passed to the internal search operation. Use this to pass your own data between the callback function and the body of the plug-in. |
Pass this as the psec parameter of slapi_search_internal_callback_pb(). Each time the internal search finds a referral entry, it calls this function.
The callback must return 0 to continue the search, -1 to interrupt the search.
Specifies a callback function to determine the role of a scope. The plug-in triggers this callback using slapi_role_get_scope().
#include "slapi-plugin.h" typedef int (*roles_get_scope_fn_type)(Slapi_Entry *role_entry, Slapi_DN ***scope, int *nb_scope);
The callback takes the following parameters.
Table 15–10 roles_get_scope_fn_type Parameters
Parameter |
Description |
---|---|
role_entry |
Entry defining the role |
scope |
Set this to the Distinguished Name of the entry at the base of the scope |
nb_scope |
Set this to a value such as LDAP_SCOPE_BASE, LDAP_SCOPE_ONELEVEL , or LDAP_SCOPE_SUBTREE |
This callback determines the role of a scope identified by role_entry. Register the callback with the server using slapi_register_role_get_scope() .
The callback returns 0 if successful, -1 otherwise.
Specifies a callback triggered before the server sends a result to the client.
#include "slapi-plugin.h" typedef int (*send_ldap_referral_fn_ptr_t)( Slapi_PBlock *pb, Slapi_Entry *e, struct berval **refs, struct berval ***urls );
The callback takes the following parameters.
Table 15–11 send_ldap_referral_fn_ptr_t Parameters
Parameter |
Description |
---|---|
pb |
Current parameter block for the operation. |
e |
Current entry for the operation. |
refs |
Pointer to the NULL terminated array of berval structures containing the LDAP v3 referrals (search result references) found in the entry. |
urls |
Pointer to the array of berval structures used to collect LDAP referrals for LDAP v2 clients. |
This callback lets you modify referrals returned to the client. Register the callback with the server using slapi_search_internal_callback_pb() .
The callback should return 0 if successful, -1 otherwise.
Specifies a callback triggered before the server sends a result to the client.
#include "slapi-plugin.h" typedef void (*send_ldap_result_fn_ptr_t)( Slapi_PBlock *pb, int err, char *matched, char *text, int nentries, struct berval **urls );
The callback takes the following parameters.
Table 15–12 send_ldap_result_fn_ptr_t Parameters
Parameter |
Description |
---|---|
pb |
Current parameter block for the operation. |
err |
Result code. |
matched |
When sending back an LDAP_NO_SUCH_OBJECT result code, use this argument to specify the portion of the target DN that could be matched. (Pass NULL in other situations.) |
text |
Error message that you want sent back to the client. (Pass NULL if you do not want an error message sent back.) |
nentries |
When sending back the result code for an LDAP search operation, use this argument to specify the number of matching entries found. |
urls |
When sending back an LDAP_PARTIAL_RESULTS result code to an LDAP v2 client or an LDAP_REFERRAL result code to an LDAP v3 client, use this argument to specify the array of berval structures containing the referral URLs. (Pass NULL in other situations.) |
This callback lets you modify the result returned to the client. Register the callback with the server using slapi_search_internal_callback_pb() .
The callback should return 0 if successful, -1 otherwise.
Specifies a callback triggered before the server sends an entry returned by a search to the client.
#include "slapi-plugin.h" typedef int (*send_ldap_search_entry_fn_ptr_t)( Slapi_PBlock *pb, Slapi_Entry *e, LDAPControl **ectrls, char **attrs, int attrsonly );
The callback takes the following parameters.
Table 15–13 send_ldap_search_entry_fn_ptr_t Parameters
This callback lets you modify what is returned to the client. Register the callback with the server using slapi_search_internal_callback_pb() .
The callback should return 0 if successful, -1 otherwise.
Opaque structure representing a directory entry attribute.
#include "slapi-plugin.h" typedef struct slapi_attr Slapi_Attr;
Opaque structure representing a server backend.
#include "slapi-plugin.h" typedef struct backend Slapi_Backend;
Opaque structure representing a component identifier used by the server to identify the plug-in when processing internal operations.
#include "slapi-plugin.h" typedef struct slapi_componentid Slapi_ComponentId;
The following code excerpt sets a plug-in component identifier used during an internal search.
#include "slapi-plugin.h" /* Declare the identifier as global to the plug-in. */ static Slapi_ComponentId * postop_id; /* Assign a value as part of plug-in initialization. */ int testpostop_init(Slapi_PBlock * pb) { int rc = 0; /* Register description, other functions, and so forth. */ rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_START_FN, (void *) testpostop_set_log ); /* Assign a value to the identifier. */ rc |= slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &postop_id); return (rc); } /* The server uses the identifier when processing * internal operations, such as an internal search. */ int testpostop_set_log(Slapi_PBlock * pb) { Slapi_DN * confdn = NULL; /* DN for configuration entry */ Slapi_Entry * config = NULL; /* Configuration entry */ int rc = 0; confdn = slapi_sdn_new_dn_byval("cn=config"); rc |= slapi_search_internal_get_entry(confdn, NULL, &config, postop_id); /* Use the results of the search. */ return(rc); }
Specifies a function to determine which function should be called to provide a value for a computed attribute.
typedef int (*slapi_compute_callback_t)(computed_attr_context *c, char* type,Slapi_Entry *e,slapi_compute_output_t outputfn);
The callback takes the following parameters.
Table 15–14 slapi_compute_callback_t Parameters
Field |
Description |
---|---|
c |
Context of the callback. |
type |
Attribute type for which the outputfn computes values. |
e |
Entry including computed attributes, returned to client after this callback returns. |
outputfn |
Callback to compute the attribute value. |
This callback selects the function that provides a computed value for an attribute of type type on an entry e, given context c. The server calls this function to get a a function for calculating attribute values before returning the entry e to the client having requested the operation.
This function is registered with the server using slapi_compute_add_evaluator() in the plug-in initialization function.
This function should return 0 on success. It should return -1 if does not handle the attribute type passed in type. Otherwise, it should return an LDAP error code.
Specifies a callback function to determine the value of a computed attribute.
typedef int (*slapi_compute_output_t)(computed_attr_context *c, Slapi_Attr *a , Slapi_Entry *e);
The callback takes the following parameters.
Table 15–15 slapi_compute_output_t Parameters
Parameter |
Description |
---|---|
c |
Context of the callback. |
a |
Attribute for which the callback computes values. |
e |
Entry including computed attributes, returned to client after this callback returns. |
This callback provides a computed value for attribute a of entry e, given context c. The slapi_compute_callback_t function you register using slapi_compute_add_evaluator() calls this function to compute a value for a before returning the entry e to the server.
This function should return 0 on success. It should return -1 if does not handle the attribute type passed in a. Otherwise, it should return an LDAP error code.
Opaque structure representing a condition variable used by the plug-in to handle thread synchronization.
#include "slapi-plugin.h" typedef struct slapi_condvar Slapi_CondVar;
Opaque structure representing a connection to the server.
#include "slapi-plugin.h" typedef struct conn Slapi_Connection;
Opaque structure representing a Distinguished Name (DN). The structure retains the original DN and can also hold a normalized version after slapi_sdn_get_ndn() is called.
#include "slapi-plugin.h" typedef struct slapi_dn Slapi_DN;
Opaque structure representing a directory entry.
#include "slapi-plugin.h" typedef struct slapi_entry Slapi_Entry;
Specifies a callback function for an object extension.
#include "slapi-plugin.h" typedef void *(*slapi_extension_constructor_fnptr) (void *object, void *parent);
The callback takes the following parameters.
Table 15–16 slapi_extension_constructor_fnptr Parameters
Parameter |
Description |
---|---|
object |
Extended object |
parent |
Parent object for the extension |
This callback registers an object extension that can be retrieved using slapi_get_object_extension().
Ensure that this callback only creates the object extension if it does not already exist.
The callback is registered with the server using slapi_register_object_extension() as part of the actual plug-in initialization function.
This callback returns a pointer to the extension. Otherwise it returns NULL.
Specifies a callback function to free memory allocated for an object extension.
#include "slapi-plugin.h" typedef void (*slapi_extension_destructor_fnptr)(void *extension, void *object, void *parent);
The callback takes the following parameters.
Table 15–17 slapi_extension_destructor_fnptr Parameters
Parameter |
Description |
---|---|
extension |
Object extension |
object |
Extended object |
parent |
Parent for the extension |
This callback releases memory allocated for an object extension. The function is registered with the server using slapi_register_object_extension() in the plug-in initialization function.
Opaque structure representing a search filter.
#include "slapi-plugin.h" typedef struct slapi_filter Slapi_Filter;
Opaque structure representing an LDAP v3 matching rule handled by the plug-in.
#include "slapi-plugin.h" typedef struct slapi_matchingRuleEntry Slapi_MatchingRuleEntry;
Opaque structure representing a modification of a directory entry attribute.
Parameter blocks use LDAPMod structures rather than Slapi_Mod structures. The latter type is provided as a convenience for plug-ins dealing extensively with modifications.
#include "slapi-plugin.h" typedef struct slapi_mod Slapi_Mod;
Opaque structure representing a set of modifications to a directory entry.
Parameter blocks use arrays of LDAPMod structures rather than Slapi_Mods structures. The latter type is provided as a convenience for plug-ins dealing extensively with modifications.
#include "slapi-plugin.h" typedef struct slapi_mods Slapi_Mods;
Opaque structure representing a mutex lock used by the plug-in.
#include "slapi-plugin.h" typedef struct slapi_mutex Slapi_Mutex;
Opaque structure representing a pending operation from an LDAP client.
The structure records, among other data, the type of operation requested.
#include "slapi-plugin.h" typedef struct op Slapi_Operation;
Opaque structure representing, called a parameter block, containing name-value pairs updated in the context of a server operation.
#include "slapi-plugin.h" typedef struct slapi_pblock Slapi_PBlock;
For most types of plug-in functions, the server passes in a parameter block (Slapi_PBlock) including data relevant to the operation being processed. Access the data using slapi_pblock_get().
Plug-in initialization functions register at least the plug-in API version, plug-in descriptions, and other plug-in functions using slapi_pblock_set() .
The specific parameters available in a Slapi_PBlock structure depend on the type of plug-in function and the context of the LDAP operation. Refer to the “Parameter Block Reference,” on page 335 for details on the name-value pairs available to specific types of plug-in functions.
Chapter 15, Data Type and Structure Reference
For examples of Slapi_PBlock use, refer to the sample plug-ins under $INSTALL_DIR/examples/.
Represents a plug-in description you provide to identify your plug-in.
The plug-in initialization function must register this information with the server.
#include "slapi-plugin.h" typedef struct slapi_plugindesc { char * spd_id; char * spd_vendor; char * spd_version; char * spd_description; } Slapi_PluginDesc;
This structure has the following fields.
Table 15–18 Slapi_PluginDesc Fields
Field |
Description |
---|---|
spd_id |
Unique (server wide) identifier for the plug-in. |
spd_vendor |
Name of the vendor supplying the plug-in such as Sun Microsystems, Inc. |
spd_version |
Plug-in revision number such as 5.2, not to be confused with SLAPI_PLUGIN_VERSION, which specifies the plug-in API version supported by the plug-in. |
spd_description |
Short description of the plug-in such as Sample post-operation plug-in . |
For examples of Slapi_PluginDesc use, refer to the sample plug-ins under $INSTALL_DIR/examples/.
Specifies a callback function for registering other plug-ins.
#include "slapi-plugin.h" typedef int (*slapi_plugin_init_fnptr)( Slapi_PBlock *pb );
The callback takes the following parameter.
Table 15–19 slapi_plugin_init_fnptr Parameter
Parameter |
Description |
---|---|
pb |
Parameter block passed to the initialization function. |
This callback mimics a plug-in initialization function, permitting one plug-in to register other plug-ins. The function is registered with the server using slapi_register_plugin() as part of the actual plug-in initialization function.
This callback returns 0 on success. Otherwise, it returns -1.
For examples of plug-in initialization functions, refer to the sample plug-ins under $INSTALL_DIR/examples/.
Opaque structure representing a Relative Distinguished Name (RDN), the part of the DN that differentiates the entry from other entries having the same parent.
#include "slapi-plugin.h" typedef struct slapi_rdn Slapi_RDN;
Opaque structure representing an individual attribute value.
Use Slapi_ValueSet instead when handling all the values of an attribute at once.
#include "slapi-plugin.h" typedef struct slapi_value Slapi_Value;
Opaque structure representing the set of values of an attribute.
Use Slapi_Value instead when handling an individual attribute value.
#include "slapi-plugin.h" typedef struct slapi_value_set Slapi_ValueSet;
Opaque structure representing both real and virtual attributes of an entry.
#include "slapi-plugin.h" typedef struct _vattr_type_thang vattr_type_thang;
This chapter contains the first part of the reference to the public functions for writing plug-ins. The following chapter contains the second part of the reference. This chapter includes the following sections:
In addition to a detailed description of each function, the function descriptions detail the function header file and syntax, the function parameters, the function return value, and possible memory concerns.
This section categorizes plug-in functions by functional area.
Table 16–1 Functions for Handling Parameter Blocks
Function |
Description |
---|---|
Frees a parameter block from memory. |
|
Gets the value from a parameter block. |
|
Creates a new parameter block. |
|
Sets the value of a parameter block. |
Table 16–2 Functions for Handling Memory
Function |
Description |
---|---|
Frees an existing array. |
|
Makes a copy of an existing berval structure. |
|
Makes a copy of an array of existing berval structures. |
|
Allocates space for an array of a number of elements of a specified size. |
|
Frees space allocated by the slapi_ch_malloc(), slapi_ch_realloc(), and slapi_ch_calloc() functions. |
|
Frees an existing string. |
|
Allocates space in memory. |
|
Changes the size of a block of allocated memory. |
|
Makes a copy of an existing string. |
Table 16–3 Functions for Handling Access Control
Function |
Description |
---|---|
Determines if the user requesting the current operation has the access rights to perform an operation on a given entry, attribute, or value. |
|
Determines if a user has the rights to perform the specified modifications on an entry. |
|
Determines whether or not the access control items (ACIs) on an entry are valid. |
Table 16–4 Functions for Handling Attributes
Function |
Description |
---|---|
Adds a value to an attribute. |
|
Returns the base type of an attribute. |
|
Duplicates an attribute. |
|
Gets the first value of an attribute. |
|
Determines if certain flags are set. |
|
Frees an attribute. |
|
Puts the values contained in an attribute into an array of berval structures. |
|
Gets the flags associated with an attribute. |
|
Puts the count of values of an attribute into an integer. |
|
Searches for an attribute type and gives its OID string. |
|
Gets the name of the attribute type. |
|
Copies attribute values into a value set. |
|
Initializes an empty attribute. |
|
Creates a new attribute. |
|
Gets the next value of an attribute. |
|
Returns a copy of the normalized attribute types. |
|
Compares two attributes. |
|
Compares two attribute names to determine if they represent the same attribute. |
|
Compares two attribute values. |
|
Determines if an attribute contains a given value. |
Table 16–5 Functions for Handling Basic Encoding Rule Values
Function |
Description |
---|---|
Compares two berval structures. |
|
Makes a copy of an existing berval structure. |
|
Makes a copy of an array of existing berval structures. |
Table 16–6 Functions for Handling Controls
Function |
Description |
---|---|
Creates an LDAPControl structure based on a BerElement, an OID, and a criticality flag. |
|
Retrieves an allocated array of object identifiers (OIDs) representing the controls supported by Directory Server. |
|
Determines whether or not the specified object identification (OID) identifies a control that is present in a list of controls. |
|
Makes an allocated copy of an LDAPControl. |
|
Registers the specified control with the server. This function associates the control with an object identification (OID). |
Table 16–7 Functions for Handling Distinguished Name Strings
Function |
Description |
---|---|
Gets a copy of the DN of the parent of an entry. |
|
Converts all characters in a DN to lowercase. |
|
Determines if a DN is the suffix of the local database. |
|
Determines if a DN is the suffix of the local database. |
|
Determines if a DN is the parent of a specific DN. |
|
Determines if a DN is the root DN for the local database. |
|
Determines if a DN is equal to a specified suffix. |
|
Converts a DN to canonical format. |
|
Converts a DN to canonical format and all characters to lower case. |
|
Normalizes part of a DN value. |
|
Gets the DN of the parent of an entry. |
|
Adds an RDN to a DN. |
Table 16–8 Functions for Handling Entries
Function |
Description |
---|---|
Generates an LDIF string description. |
|
Generates an LDIF string descriptions with options. |
|
Add components in an entry’s RDN. |
|
Adds a string value to an attribute in an entry. |
|
Adds a data value to an attribute in an entry. |
|
Adds a data value to an attribute in an entry. |
|
Allocates memory for a new entry. |
|
Deletes an attribute from an entry. |
|
Checks if an entry contains a specific attribute. |
|
Gets the first value as a string. |
|
Gets the first value as an integer. |
|
Gets the first value as a long. |
|
Gets the first value as an unsigned integer. |
|
Gets the first value as an unsigned long. |
|
Checks if an attribute in an entry contains a value. |
|
Adds an array to the attribute values in an entry. |
|
Replaces the attribute values in an entry. |
|
Replaces the values of an attribute with a string. |
|
Replaces the value of an attribute with an integer. |
|
Replaces the value of an attribute with a long. |
|
Replaces the value of an attribute with an unsigned integer. |
|
Replaces the value of an attribute with an unsigned long. |
|
Deletes a string from an attribute. |
|
Removes a Slapi_Value array from an attribute. |
|
Copies an entry, its DN, and its attributes. |
|
Finds the first attribute in an entry. |
|
Frees an entry from memory. |
|
Gets the DN from an entry. |
|
Returns the DN of an entry as a constant. |
|
Returns the NDN of an entry. |
|
Returns the Slapi_DN from an entry. |
|
Returns a Slapi_DN from an entry as a constant. |
|
Gets the unique ID from an entry. |
|
Determines if the specified entry has child entries. |
|
Initializes the values of an entry. |
|
Determines whether the entry is that of a directory super user. |
|
Adds an array of data values to an attribute in an entry. |
|
Finds the next attribute in an entry. |
|
Checks if values present in an entry’s RDN are also present as attribute values. |
|
Determines if an entry complies with the schema for its object class. |
|
Determines if a set of modifications to an entry comply with the schema. |
|
Sets the DN of an entry. |
|
Sets the Slapi_DN value in an entry. |
|
Returns the size of an entry. |
|
Determines if the attributes of an entry comply with attribute syntax rules. |
|
Finds the specified virtual attribute in the entry. |
|
Determines if an entry is the root DSE. |
|
Converts an LDIF description into an entry. |
Table 16–9 Functions for Handling Extended Operations
Function |
Description |
---|---|
Gets a copy of the object IDs (OIDs) of the extended operations. |
Table 16–10 Functions for Handling Filters
Function |
Description |
---|---|
Determines if two filters are identical. |
|
Frees the specified filter. |
|
Gets the attribute type for all simple filter choices. |
|
Gets the attribute type and the value from the filter. |
|
Gets the type of the specified filter. |
|
Gets the substring values from the filter. |
|
Gets the attribute type specified in the filter. |
|
Joins two specified filters. |
|
Gets the first filter that makes up the specified filter. |
|
Gets the next filter. |
|
Determines if the specified entry matches a particular filter. |
|
Determines if an entry matches a given filter. |
|
Determines if an entry matches a filter. |
|
Converts a string description of a search filter into a filter of the Slapi_Filter type. |
Table 16–11 Functions for Handling Internal Operations
Function |
Description |
---|---|
Prepare a Slapi_PBlock structure for an internal add operation involving a Slapi_Entry structure. |
|
Adds an LDAP add operation based on a parameter block to add a new directory entry. |
|
Prepare a Slapi_PBlock structure for an internal add operation. |
|
Performs an LDAP delete operation based on a parameter block to remove a directory entry |
|
Prepare a Slapi_PBlock structure for an internal delete operation. |
|
Frees search results. |
|
Performs an LDAP modify operation based on a parameter block to modify a directory entry. |
|
Prepare a Slapi_PBlock structure for an internal modify operation. |
|
Performs an LDAP modify RDN operation based on a parameter block to rename a directory entry. |
|
Prepare a Slapi_PBlock structure for an internal modify RDN operation. |
|
Performs an LDAP search operation based on a parameter block to search the directory. |
|
Performs an internal search operation to read one entry |
|
Performs an LDAP search operation based on a parameter block to search the directory. |
|
Prepare a Slapi_PBlock structure for an internal search operation. |
Table 16–12 Functions for Handling Matching Rules
Function |
Description |
---|---|
Free a Slapi_MatchingRuleEntry after registering the matching rule. |
|
Access a Slapi_MatchingRuleEntry. |
|
Allocate a Slapi_MatchingRuleEntry structure. |
|
Register a matching rule with the server. |
|
Modify a Slapi_MatchingRuleEntry. |
|
Call a matching rule filter index function. |
|
Get a pointer to the indexer factory function for a matching rule. |
Table 16–13 Functions for Handling Modifications
Function |
Description |
---|---|
Creates an array of LDAPMod from a Slapi_Entry. |
|
Determines if the proposed modifications to an entry comply with attribute syntax rules. |
|
Adds a value to a Slapi_Mod structure. |
|
Frees internals of Slapi_Mod structure. |
|
Dumps the contents of an LDAPMod to the server log. |
|
Frees a Slapi_Mod structure. |
|
Initializes a Slapi_Mod iterator and returns the first attribute value. |
|
Increments the Slapi_Mod iterator and returns the next attribute value. |
|
Gets the number of values in a Slapi_Mod structure. |
|
Gets the operation type of Slapi_Mod structure. |
|
Gets the attribute type of a Slapi_Mod structure. |
|
Initializes a Slapi_Mod structure. |
|
Initializes a Slapi_Mod structure that is a wrapper for an existing LDAPMod. |
|
Initializes a Slapi_Mod structure with a copy of an LDAPMod. |
|
Determines whether a Slapi_Mod structure is valid. |
|
Allocates a new Slapi_Mod structure. |
|
Removes the value at the current Slapi_Mod iterator position. |
|
Sets the operation type of a Slapi_Mod structure. |
|
Sets the attribute type of a Slapi_Mod. |
|
Creates a Slapi_Entry from an array of LDAPMod. |
|
Appends a new mod with a single attribute value to Slapi_Mods structure. |
|
Appends an LDAPMod to a Slapi_Mods structure. |
|
Appends a new mod to a Slapi_Mods structure, with attribute values provided as an array of Slapi_Value. |
|
Appends a new mod to a Slapi_Mods structure, with attribute values provided as an array of berval. |
|
Appends a Slapi_Mod to a Slapi_Mods structure. |
|
Appends a new mod to Slapi_Mods structure with a single attribute value provided as a string. |
|
Frees internals of a Slapi_Mods structure. |
|
Dumps the contents of a Slapi_Mods structure to the server log. |
|
Frees a Slapi_Mods structure. |
|
Initializes a Slapi_Mods iterator and returns the first LDAPMod. |
|
Initializes a Slapi_Mods iterator and returns the first mod wrapped in a Slapi_Mods structure. |
|
Gets a reference to the array of LDAPMod in a Slapi_Mods structure. |
|
Retrieves the array of LDAPMod contained in a Slapi_Mods structure. |
|
Increments the Slapi_Mods iterator and returns the next LDAPMod. |
|
Increments the Slapi_Mods iterator and returns the next mod wrapped in a Slapi_Mods. |
|
Gets the number of mods in a Slapi_Mods structure. |
|
Initializes a Slapi_Mods. |
|
Initializes a Slapi_Mods that is a wrapper for an existing array of LDAPMod. |
|
Initializes a Slapi_Mods structure from an array of LDAPMod. |
|
Inserts an LDAPMod into a Slapi_Mods structure after the current iterator position. |
|
Inserts an LDAPMod anywhere in a Slapi_Mods. |
|
Inserts an LDAPMod into a Slapi_Mods structure before the current iterator position. |
|
Inserts a Slapi_Mod anywhere in a Slapi_Mods. |
|
Inserts a Slapi_Mod into a Slapi_Mods structure before the current iterator position. |
|
Decrements the Slapi_Mods current iterator position. |
|
Allocates a new uninitialized Slapi_Mods structure. |
|
Removes the mod at the current Slapi_Mods iterator position. |
|
Removes the mod at the specified Slapi_Mods iterator position. |
Table 16–14 Functions for Handling Operations
Function |
Description |
---|---|
Determines if the client has abandoned the current operation. |
|
Gets the type of a Slapi_Operation. |
Table 16–15 Functions for Handling Passwords
Function |
Description |
---|---|
Determines whether or not a specified password matches one of the hashed values of an attribute. |
|
Determines whether or not a specified password matches one of the hashed values of an attribute. |
Table 16–16 Functions for Handling Roles
Function |
Description |
---|---|
Register a callback to determine the scope of a role. |
|
Checks if the entry pointed to contains the role indicated. |
|
Determine the scope of a role. |
Table 16–17 Functions for Handling SASL Mechanisms
Function |
Description |
---|---|
Gets an array of the names of the supported Simple Authentication and Security Layer (SASL) mechanisms. |
|
Registers the specified Simple Authentication and Security Layer (SASL) mechanism with the server. |
Table 16–18 Functions for Handling Slapi_Backend Structures
Function |
Description |
---|---|
Checks if the backend that contains the specified DN exists. |
|
Returns the name of the specified backend. |
|
Indicates if the database associated with the backend is in read-only mode. |
|
Returns the n+1 suffix associated with the specified backend. |
|
Returns the type of the backend. |
|
Checks if a flag is set in the backend configuration. |
|
Verifies that the specified suffix matches a registered backend suffix. |
|
Indicates if the changes applied to the backend should be logged in the change log. |
|
Verifies if the backend is private. |
|
Finds the backend that should be used to service the entry with the specified DN. |
|
Find the backend used to service the database. |
|
Returns a pointer of the backend structure of the first backend. |
|
Returns a pointer to the next backend. |
|
Checks if a suffix is a root suffix of the DIT. |
Table 16–19 Functions for Handling Slapi_DN Structures
Function |
Description |
---|---|
Builds the new DN of an entry. |
|
Compares two DNs. |
|
Copies a DN. |
|
Clears a Slapi_DN structure. |
|
Duplicates a Slapi_DN structure. |
|
Frees a Slapi_DN structure. |
|
Gets the DN of the parent within a specific backend. |
|
Gets the DN from a Slapi_DN structure. |
|
Gets the normalized DN of a Slapi_DN structure. |
|
Gets the length of the normalized DN of a Slapi_DN structure. |
|
Get the parent DN of a given Slapi_DN structure. |
|
Gets the RDN from a DN. |
|
Gets the suffix holding the entry specified by DN. |
|
Checks if there is a DN value stored in a Slapi_DN structure. |
|
Checks if a DN is the parent of the parent of a DN. |
|
Checks if a DN is the parent of a DN. |
|
Checks if a Slapi_DN structure contains a suffix of another. |
|
Allocates new Slapi_DN structure. |
|
Creates a new Slapi_DN structure pointing to an existing DN string. |
|
Creates a new Slapi_DN structure copying an existing DN string. |
|
Creates a new Slapi_DN structure pointing to a new copy of a DN string. |
|
Creates a new Slapi_DN structure pointing to an existing normalized DN. |
|
Creates a new Slapi_DN structure copying an existing normalized DN. |
|
Checks if an entry is in the scope of a certain base DN. |
|
Sets a DN value in a Slapi_DN structure pointing to an existing DN string. |
|
Sets a DN value in a Slapi_DN structure copying an existing DN string. |
|
Sets a DN value in a Slapi_DN structure pointing to a new copy of a DN string. |
|
Sets a normalized DN in a Slapi_DN structure pointing to an existing normalized DN string. |
|
Sets a normalized DN in a Slapi_DN structure copying an existing normalized DN string. |
|
Sets a new parent in an entry. |
|
Sets a new RDN for an entry. |
Table 16–20 Functions for Handling Slapi_RDN Structures
Function |
Description |
---|---|
Adds a new RDN to an existing RDN structure. |
|
Compares two RDNs. |
|
Checks if a Slapi_RDN structure holds any RDN matching a given type/value pair. |
|
Checks if a Slapi_RDN structure contains any RDN matching a given type. |
|
Clears a Slapi_RDN structure. |
|
Frees a Slapi_RDN structure. |
|
Gets the type/value pair of the first RDN. |
|
Gets the index of the RDN. |
|
Gets the position and the attribute value of the first RDN. |
|
Gets the RDN type/value pair from the RDN. |
|
Gets the number of RDN type/value pairs. |
|
Gets the RDN from a Slapi_RDN structure. |
|
Initializes a Slapi_RDN structure with NULL values. |
|
Initializes a Slapi_RDN structure from an existing DN string. |
|
Initializes a Slapi_RDN structure from an existing Slapi_RDN structure. |
|
Initializes a Slapi_RDN structure from an existing Slapi_DN structure. |
|
Checks if an RDN value is stored in a Slapi_RDN structure. |
|
Creates a new Slapi_RDN structure. |
|
Creates a new Slapi_RDN structure. |
|
Creates a new Slapi_RDN structure. |
|
Creates a new Slapi_RDN structure. |
|
Determines if and RDN complies with attribute syntax rules. |
Table 16–21 Functions for Handling Slapi_Value Structures
Function |
Description |
---|---|
Compares two values. |
|
Frees internals of a value. |
|
Duplicates a value. |
|
Frees a Slapi_Value structure from memory. |
|
Gets the berval structure of the value. |
|
Converts the value of an integer. |
|
Gets the length of a value. |
|
Converts a value into a long integer. |
|
Returns the value as a string. |
|
Converts the value into an unsigned integer. |
|
Converts the value into an unsigned long. |
|
Initializes a Slapi_Value structure with no values. |
|
Initializes a Slapi_Value structure from the berval structure. |
|
Initializes a Slapi_Value structure from a string. |
|
Initializes a Slapi_Value structure with a value contained in a string. |
|
Allocates a new Slapi_Value structure. |
|
Allocates a new Slapi_Value structure from a berval structure. |
|
Allocates a new Slapi_Value structure from a string. |
|
Allocates a new Slapi_Value structure and initializes it from a string. |
|
Allocates a new Slapi_Value from another Slapi_Value structure. |
|
Sets the value. |
|
Copies the value from a berval structure into a Slapi_Value structure. |
|
Sets the integer value of a Slapi_Value structure. |
|
Copies a string into the value. |
|
Sets the value. |
|
Copies the value of a Slapi_Value structure into another Slapi_Value structure. |
Table 16–22 Functions for Handling Slapi_ValueSet Structures
Function |
Description |
---|---|
Adds a Slapi_Value in the Slapi_ValueSet structure. |
|
Returns the number of values contained in a Slapi_ValueSet structure. |
|
Frees the values contained in the Slapi_ValueSet structure. |
|
Finds the value in a value set by using the syntax of an attribute. |
|
Gets the first value of a Slapi_ValueSet structure. |
|
Frees the specified Slapi_ValueSet structure and its members from memory. |
|
Resets a Slapi_ValueSet structure to no values. |
|
Allocates a new Slapi_ValueSet structure. |
|
Gets the next value from a Slapi_ValueSet structure. |
|
Copies the values of Slapi_Mod structure into a Slapi_ValueSet structure. |
|
Initializes a Slapi_ValueSet structure from another Slapi_ValueSet structure. |
Table 16–23 Functions for Handling UTF-8 Strings
Function |
Description |
---|---|
Checks if a string has an 8-bit character. |
|
Compares two UTF-8 strings. |
|
Compares a specified number of UTF-8 characters. |
|
Verifies if a UTF-8 character is lower case. |
|
Verifies if a single UTF-8 character is upper case. |
|
Converts a UTF-8 string to lower case. |
|
Converts a string made up of UTF-8 characters and converts it to upper case. |
|
Converts a UTF-8 character to lower case. |
|
Converts a lower case UTF-8 character to an upper case character. |
Table 16–24 Functions for Writing Log Messages
Function |
Description |
---|---|
Writes an error message to the server error log |
|
Writes an informational message to the server error log |
|
Writes a warning message to the server error log |
Table 16–25 Functions for Handling Virtual Attributes
Function |
Description |
---|---|
Determines if the value of the specified attribute type is virtually generated. |
|
Compares attribute type and name in a given entry. |
|
Frees the value set and type names. |
|
Returns the values for an attribute type from an entry. |
Table 16–26 Functions for Sending Entries, Referrals, and Results to Clients
Function |
Description |
---|---|
Processes an entry’s LDAP v3 referrals. |
|
Sends a result code back to the client. |
|
Sends an entry found by a search back to the client. |
Table 16–27 Function for Registering Plug-Ins
Function |
Description |
---|---|
Register another plug-in. |
The following sections cover plug-in API functions in alphabetical order from slapi_access_allowed() to slapi_moddn_get_newdn().
Subsequent sections in the following chapter cover plug-in API functions from slapi_modify_internal_pb() to slapi_wait_condvar().
Determines if the user 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:
Parameter block passed into this function.
Entry for which you want to check the access rights.
Attribute for which you want to check the access rights.
Pointer to the berval structure containing the value for which you want to check the access rights.
Type of access rights that you want to check. For example, to check for write access, pass SLAPI_ACL_WRITE as the value of this argument.
The value of the access argument can be one of the following:
Permission to add a specified entry.
Permission to compare the specified values of an attribute in an entry.
Permission to delete a specified entry.
Permission to read a specified attribute.
Permission to search on a specified attribute or value.
Permission to write a specified attribute or value or permission to rename a specified entry.
This function returns one of the following values:
LDAP_SUCCESS if the user has the specified rights to the entry, attribute, or value.
LDAP_INSUFFICIENT_ACCESS if the user does not have the specified rights to the entry, attribute, or value.
If a problem occurs during processing, the function will return one of the following error codes:
An error occurred while executing the operation.
This error can occur if, for example, the type of access rights specified are not recognized by the server. In other words, you did not pass a value from the previous table.
Invalid syntax was specified.
This error can occur if the ACL associated with an entry, attribute, or value uses the wrong syntax.
The DSA (this Directory Server instance) is unable to perform the specified operation.
This error can occur if, for example, you are requesting write access to a read-only database.
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 preoperation 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, this function does the following:
Checks if the user requesting the operation is the root DN.
If so, the function returns LDAP_SUCCESS. (The root DN has permission to perform any operation.)
Gets information about the operation being requested, the connection to the client, and the backend database where directory information is stored.
If for some reason the function cannot determine which operation is being requested, the function returns LDAP_OPERATIONS_ERROR.
If no connection to a client exists— in other words, if the request for the operation was made by the server or its backend— the function returns LDAP_SUCCESS. (The server and its backend are not restricted by access control lists.)
If the backend database is read-only and the request is checking for write access (SLAPI_ACL_WRITE), the function returns LDAP_UNWILLING_TO_PERFORM.
Determines if the user requesting the operation is attempting to modify his or her own entry.
ACLs can be set up to allow users the rights to modify their own entries. The function checks for this condition.
The caller must ensure that the backend specified in the parameter block 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, "Obj not 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 takes the following parameters:
Parameter block passed into this function.
Entry for which you want to check the access rights.
Array of LDAPMod structures that represent the modifications to be made to the entry.
Pointer to a string containing an error message if an error occurs during the processing of this function.
Returns one of the following values:
LDAP_SUCCESS if the user has write permission to the values in the specified attributes.
LDAP_INSUFFICIENT_ACCESS if the user does not have write permission to the values of the specified attribute.
If a problem occurs during processing, the function will return one of the following error codes:
An error occurred while executing the operation.
Invalid syntax was specified.
This error can occur if the ACL associated with an entry, attribute, or value uses the wrong syntax.
The DSA (this directory server) is unable to perform the specified operation.
This error can occur if, for example, you are requesting write access to a read-only database.
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.
For example, if 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 function does the following:
Checks to access control for the directory is disabled.
If access control is disabled, the function returns LDAP_SUCCESS.
For each value in each attribute specified in the LDAPMod array, the function determines if the user has permissions to write to that value. Specifically, the function calls slapi_access_allowed() with SLAPI_ACL_WRITE as the access right to check.
If for some reason the function cannot determine which operation is being requested, the function returns LDAP_OPERATIONS_ERROR.
If no connection to a client exists (in other words, if the request for the operation was made by the server or its backend), the function returns LDAP_SUCCESS. (The server and its backend are not restricted by access control lists.)
If the backend database is read-only and the request is checking for write access (SLAPI_ACL_WRITE), the function returns LDAP_UNWILLING_TO_PERFORM.
You must free the errbuf buffer by calling slapi_ch_free() when you are finished using the error message.
Determines whether or not the access control items (ACIs) on an entry are valid.
#include "slapi-plugin.h" int slapi_acl_verify_aci_syntax (Slapi_Entry *e, char **errbuf);
This function takes the following parameters:
Entry for which you want to check the ACIs.
Pointer to the error message returned if the ACI syntax is invalid.
This function returns 0 if successful, or -1 if an error occurs.
You must free the errbuf buffer by calling slapi_ch_free() when you are finished using the error message.
Prepares a parameter block for an internal add operation involving a Slapi_Entry structure.
#include "slapi-plugin.h" int 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:
Parameter block for the internal add operation
Entry to add
Array of controls to request for the add operation; NULL if no controls
Plug-in identifier obtained from SLAPI_PLUGIN_IDENTITY during plug-in initialization
NULL or SLAPI_OP_FLAG_NEVER_CHAIN
This function returns 0 if successful. Otherwise it returns an LDAP error code.
This function prepares a parameter block for use with slapi_add_internal_pb() using the entry.
Allocate the parameter block using slapi_pblock_new() before calling this function.
The entry is consumed during the call to slapi_add_internal_pb() . The LDAPControls are not consumed.
Free the parameter block after calling slapi_add_internal_pb() .
Performs an internal add operation of a new directory entry.
#include "slapi-plugin.h" int slapi_add_internal_pb(Slapi_PBlock *pb);
This function takes the following parameter:
A parameter block that has been initialized using slapi_add_internal_set_pb().
This function returns -1 if the parameter passed is a NULL pointer. Otherwise, it returns 0.
After your code calls this function, the server sets SLAPI_PLUGIN_INTOP_RESULT in the parameter block to the appropriate LDAP result code. You can therefore check SLAPI_PLUGIN_INTOP_RESULT in the parameter block to determine whether an error has occurred.
This function performs an internal add operation based on a parameter block. The parameter block should be initialized by calling slapi_add_internal_set_pb() or slapi_add_entry_internal_set_pb().
None of the parameters that are passed to slapi_add_internal_set_pb() or slapi_add_entry_internal_set_pb() are altered or consumed by this function. The entry parameter that is passed to slapi_add_entry_internal_set_pb() is consumed by a successful call to this function.
Prepares a parameter block 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:
Parameter block for the internal add operation
Distinguished Name of the entry to add
Array of attributes of the entry to add
Array of controls to request for the add operation
Plug-in identifier obtained from SLAPI_PLUGIN_IDENTITY during plug-in initialization
NULL or SLAPI_OP_FLAG_NEVER_CHAIN
This function returns 0 if successful. Otherwise, it returns an LDAP error code.
This function prepares a parameter block for use with slapi_add_internal_pb() using the components of the entry.
If the entry has already been prepared as a Slapi_Entry structure, use slapi_add_entry_internal_set_pb() instead.
Allocate the parameter block using slapi_pblock_new() before calling this function.
Directory Server does not free the parameters passed to this function.
Free the parameter block after calling slapi_pblock_destroy() .
slapi_add_entry_internal_set_pb()
Adds a value to an attribute.
#include "slapi-plugin.h" int slapi_attr_add_value(Slapi_Attr *a, const Slapi_Value *v);
This function takes the following parameters:
The attribute that will contain the values.
Values to be added to the attribute.
This function always returns 0.
Directory Server makes a copy of the Slapi_Value to be added to the attribute.
slapi_attr_first_value_const()
Returns the base type of an attribute.
#include "slapi-plugin.h" char *slapi_attr_basetype( char *type, char *buf, size_t bufsiz );
This function takes the following parameters:
Attribute type from which you wish to get the base type.
Buffer to hold the returned base type.
Size of the buffer.
This function returns NULL if the base type fits in the buffer. If the base type is longer than the buffer, the function allocates memory for the base type and returns a pointer to it.
This function returns the base type of an attribute (for example, if given cn;lang-jp, returns cn).
You should free the returned base type when you are finished by calling slapi_ch_free().
Duplicates an attribute.
#include "slapi-plugin.h" Slapi_Attr *slapi_attr_dup(const Slapi_Attr *attr);
This function takes the following parameter:
The attribute to be duplicated.
This function returns the newly created copy of the attribute.
Use this function to make a copy of an attribute.
You must free the returned attribute using slapi_attr_free() .
Gets the first value of an attribute.
#include "slapi-plugin.h" int slapi_attr_first_value_const( const Slapi_Attr *a, const Slapi_Value **v );
This function takes the following parameters:
Attribute containing the desired value.
Holds the first value of the attribute.
This function returns one of the following values:
0, which is the index of the first value.
-1 if NULL.
Use this function to get the first value of an attribute. This is part of a set of functions to enumerate over an Slapi_Attr structure.
Do not free the value held in v.
Determines if certain flags are set for a particular attribute.
#include "slapi-plugin.h" int slapi_attr_flag_is_set( Slapi_Attr *attr, unsigned long flag );
This function takes the following parameters:
Attribute that you want to check.
Flag that you want to check in the attribute.
The value of the flag argument can be one of the following:
Flag that determines if the attribute is single-valued.
Flag that determines if the attribute is an operational attribute.
Flag that determines if the attribute is read-only.
This function returns one of the following values:
1 if the specified flag is set.
0 if the specified flag is not set.
This function determines if certain flags are set for the specified attribute. These flags can identify an attribute as a single-valued attribute, an operational attribute, or as a read-only attribute, and are set from the schema when the Slapi_Attr structure is initialized.
Frees an attribute.
#include "slapi-plugin.h" void slapi_attr_free( Slapi_Attr **a );
This function takes the following parameters:
Attribute to be freed.
Use this function to free an attribute when you are finished with it.
Puts the values contained in an attribute into an array of berval structures.
#include "slapi-plugin.h" int slapi_attr_get_bervals_copy(Slapi_Attr *a, struct berval ***vals );
This function takes the following parameters:
Attribute that contains the desired values.
Pointer to an array of berval structure pointers to hold the desired values.
This function returns one of the following values:
0 if values are found.
-1 if NULL.
This function copies the values from an attribute into an array of berval structure pointers.
Free this array using ber_bvecfree(3LDAP).
Gets the flags associated with the specified attribute.
#include "slapi-plugin.h" int slapi_attr_get_flags( Slapi_Attr *attr, unsigned long *flags );
This function takes the following parameters:
Attribute for which you wish to get the flags.
When you call this function, this parameter is set to a pointer to the flags of the specified attribute. Do not free the flags; the flags are part of the actual data in the attribute, not a copy of the data.
To determine which flags have been set, you can use bitwise AND on the value of the flags argument with one or more of the following:
Flag that determines if the attribute is single-valued.
Flag that determines if the attribute is an operational attribute.
Flag that determines if the attribute is read-only.
This function returns 0 if successful.
This function gets the flags associated with the specified attribute. These flags can identify an attribute as a single-valued attribute, an operational attribute, or as a read-only attribute.
Puts the count of values of an attribute into a provided integer.
#include "slapi-plugin.h" int slapi_attr_get_numvalues( const Slapi_Attr *a, int *numValues);
This function takes the following parameters:
Attribute containing the values to be counted.
Integer to hold the counted values.
This function always returns 0.
This function counts the number of values in an attribute and places that count in an integer.
slapi_attr_first_value_const()
Searches the syntaxes for an attribute type, and returns a copy of its OID string.
#include "slapi-plugin.h" int slapi_attr_get_oid_copy( const Slapi_Attr *attr, char **oidp );
This function takes the following parameters:
Attribute that contains the desired type.
Destination string of the copied attribute type OID.
This function returns one of the following values:
0 if the attribute type is found.
-1 if it is not.
Use this function to search the syntaxes for an attribute type’s OID.
You should free this string using slapi_ch_free().
Gets a pointer to the syntax plug-in used to handle values of the attribute type in question.
#include "slapi-plugin.h" int slapi_attr_get_plugin( Slapi_Attr *a, void **plugin );
This function takes the following parameters:
Attribute whose associated syntax plug-in you want to access.
This parameter is set to a pointer to the plug-in registered to handle attributes of the type passed to this function. Do not free this pointer as it is not a copy.
This function returns 0.
Gets the name of the attribute type from a specified attribute.
#include "slapi-plugin.h" int slapi_attr_get_type( Slapi_Attr *attr, char **type );
This function takes the following parameters:
Attribute of which you wish to get the type.
When you call this function, this parameter is set to a pointer to the type of the specified attribute. Do not free this attribute type; the type is part of the actual data in the attribute, not a copy of the data.
This function returns 0 if successful.
Copies existing values contained in an attribute into a valueset.
#include "slapi-plugin.h" int slapi_attr_get_valueset(const Slapi_Attr *a, Slapi_ValueSet **vs);
This function takes the following parameters:
Attribute containing the values to be placed into a value set. This must be a valid attribute, not NULL.
Receives values from the first parameter.
This function always returns 0.
Free the value set in vs using slapi_valueset_free() .
slapi_valueset_add_value_optimised()
slapi_valueset_first_value_const()
slapi_valueset_next_value_const()
Initializes an empty attribute with a base type.
#include "slapi-plugin.h" Slapi_Attr *slapi_attr_init(Slapi_Attr *a, const char *type);
This function takes the following parameters:
The empty attribute to be initialized.
Attribute type to be initialized.
This function returns the newly initialized attribute, or an empty attribute if the type is not specified in the schema.
Use this function to initialize an empty attribute with an attribute type.
Directory Server makes a copy of the type string.
Creates a new attribute.
#include "slapi-plugin.h" Slapi_Attr *slapi_attr_new( void );
This function takes no parameters.
This function returns the newly created attribute
Use this function to create an empty attribute.
Gets the next value of an attribute.
#include "slapi-plugin.h" int slapi_attr_next_value_const( const Slapi_Attr *a, int index, const Slapi_Value **v );
This function takes the following parameters:
Attribute contained the desired value.
Index of the value to be returned, counting from 0.
Holds the value of the attribute.
This function returns one of the following values:
hint plus 1 if the value is found
-1 if NULL, or if a value at hint is not found
Use this function to get the next value of an attribute. The value of an attribute associated with an index is placed into a value. This is part of a set of functions to enumerate over a Slapi_Attr structure.
slapi_attr_first_value_const()
Searches for an attribute type in the syntaxes, and returns a copy of the normalized attribute types.
#include "slapi-plugin.h" char * slapi_attr_syntax_normalize( const char *s );
This function takes the following parameter:
Attribute type for which you wish to search.
This function returns the copy of the desired normalized attribute, or a normalized copy of what was passed in.
Use this function to search the syntaxes for an attribute type and return its normalized form. If the attribute type is not defined in the schema, this function returns a copy of the type folded to lower case.
You should free the returned string using slapi_ch_free() .
Compares two attribute types to determine if they are the same.
#include "slapi-plugin.h" int slapi_attr_type_cmp( char *t1, char *t2, int opt );
This function takes the following parameters:
Name of the first attribute type that you want to compare.
Name of the second attribute type that you want to compare.
One of the following values:
0 - Compare the types as is.
1 - Compare only the base names of the types (for example, if the type is cn;lang-en, the function compares only the cn part of the type).
2 - Ignore any options in the second type that are not in the first type. For example, if the first type is cn and the second type is cn;lang-en, the lang-en option in the second type is not part of the first type. In this case, the function considers the two types to be the same.
This function returns 0 if the type names are equal, or a non-zero value if they are not equal.
Compares two attribute names to determine if they represent the same attribute.
#include "slapi-plugin.h" int slapi_attr_types_equivalent( const char *t1, const char *t2 );
This function takes the following parameters:
Pointer to the first attribute type that you want to compare.
Pointer to the second attribute type that you want to compare.
This function returns the one of the following values:
1 if t1 and t2 represent the same attribute.
0 if t1 and t2 do not represent the same attribute.
slapi_attr_first_value_const()
Compares two values for a given attribute to determine if they are equal.
#include "slapi-plugin.h" int slapi_attr_value_cmp( Slapi_Attr *attr, struct berval *v1, struct berval *v2 );
This function takes the following parameters:
Attribute used to determine how these values are compared (for example, if the attribute contains case-insensitive strings, the strings are compared without regard to case).
Pointer to the berval structure containing the first value that you want to compare.
Pointer to the berval structure containing the second value that you want to compare.
This function returns one of the following values:
0 if the values are equal.
-1 if they are not equal.
slapi_attr_first_value_const()
Determines if an attribute contains a given value, using the equality matching rule.
#include "slapi-plugin.h" int slapi_attr_value_find( Slapi_Attr *a, struct berval *v );
This function takes the following parameters:
Attribute that you wish to check.
Pointer to the berval structure containing the value for which you wish to search.
This function returns one of the following values:
0 if the attribute contains a match for the specified value according to the equality matching rule.
As an example for CN, BABS JENSEN and Babs Jensen match.
-1 if the attribute does not contain the specified value.
slapi_attr_first_value_const()
Checks if the backend that contains the specified DN exists.
#include "slapi-plugin.h" int slapi_be_exist(const Slapi_DN *sdn);
This function takes the following parameter:
Pointer to the DN in the backends for which you are looking.
This function returns one of the following values:
1 if the backend containing the specified DN exists.
0 if the backend does not exist.
Returns the name of the specified backend.
#include "slapi-plugin.h" char * slapi_be_get_name(Slapi_Backend * be);
This function takes the following parameter:
Pointer to the structure containing the backend configuration.
This function returns the name associated to the specified backend.
You should not free the returned pointer.
Indicates if the database associated with the backend is in read-only mode.
#include "slapi-plugin.h" int slapi_be_get_readonly(Slapi_Backend *be);
This function takes the following parameter:
Pointer to the structure containing the backend configuration.
This function returns one of the following values:
0 if the database is not in read-only mode.
1 if the database is in read-only mode.
Returns the DN of the nth suffix associated with the specified backend.
#include "slapi-plugin.h" const Slapi_DN *slapi_be_getsuffix(Slapi_Backend *be, int n);
This function takes the following parameters:
Pointer to the structure containing the backend configuration.
Index, starting from 0.
This function returns the DN of the suffix if it exists, or NULL if there is no nth suffix in the backend.
This function returns the nth suffix, counting from 0, associated with the specified backend. This function is present for compatibility purposes with previous versions of the Directory Server Plug-In API.
You should not free the returned pointer.
Returns the type of the backend.
#include "slapi-plugin.h" const char * slapi_be_gettype(Slapi_Backend *be);
This function takes the following parameter:
Pointer to the structure containing the backend configuration.
This function returns the type of the backend. Backend types include:
chaining (used for chaining, also known as database links)
default (supporting only binds, used for Pass Through Authentication)
DSE (used for configuration parameters)
ldbm database (housing your directory data)
schema-internal (used for schema configuration)
You should not free the returned pointer.
Checks if a flag is set in the backend configuration.
#include "slapi-plugin.h" int slapi_be_is_flag_set(Slapi_Backend * be, int flag);
This function takes the following parameters:
Pointer to the structure containing the backend configuration.
Flag to check (SLAPI_BE_FLAG_REMOTE_DATA, SLAPI_BE_FLAG_SUSPENDED).
This function returns one of the following values:
0 if a flag is not set in the backend configuration.
1 if a flag is set.
Verifies that the specified suffix matches a registered backend suffix.
#include "slapi-plugin.h" int slapi_be_issuffix(const Slapi_Backend *be, const Slapi_DN *suffix);
This function takes the following parameters:
Pointer to the structure containing the backend configuration.
DN of the suffix for which you are looking.
This function returns one of the following values:
0 if the suffix is not part of the specified backend.
1 if the suffix is part of the specified backend.
This function checks if the specified suffix exactly matches a registered suffix on a specified backend.
Indicates if the changes applied to the LDBM database backend should be logged in the changelog. You can only read this value, not set it.
#include "slapi-plugin.h" int slapi_be_logchanges(Slapi_Backend *be);
This function takes the following parameter:
Pointer to the structure containing the backend configuration.
This function returns one of the following values:
0 if the changes applied to the specific backend should not be logged in the changelog.
1 if the changes should be logged in the changelog.
Verifies if the backend is private.
#include "slapi-plugin.h" int slapi_be_private( Slapi_Backend * be );
This function takes the following parameter:
Pointer to the structure containing the backend configuration.
This function returns one of the following values:
0 if the backend is not hidden from the user (for backend types chaining and ldbm database)
1 if the backend is hidden from the user (for internal use only, backend types default, DSE, schema-internal).
Finds the backend that should be used to service the entry with the specified DN.
#include "slapi-plugin.h" Slapi_Backend * slapi_be_select( const Slapi_DN * sdn );
This function takes the following parameter:
Pointer to the DN of which you wish to get the backend.
This function returns a pointer to the default backend, which is an empty backend allowing only bind operations, if no backend with the appropriate suffix is configured. Otherwise, it returns a pointer to the backend structure.
You should not free the returned pointer.
slapi_be_select_by_instance_name()
Find the backend used to service the database.
#include "slapi-plugin.h" Slapi_Backend *slapi_be_select_by_instance_name( const char *name );
This function takes the following parameter:
Pointer to the value of the CN for the backend whose structure you want, such as userRoot.
This function returns NULL if no backend with the appropriate name is configured. Otherwise, it returns a pointer to the backend structure.
This function finds the backend that should used to service the database named as the parameter.
You should not free the returned pointer.
Compare two berval structures.
#include "slapi-plugin.h" int slapi_berval_cmp(const struct berval* L,const struct berval* R);
This function takes the following parameters:
This function checks whether two berval structures are equivalent.
This function returns 0 if the two berval structures are equivalent. It returns a negative value if L is shorter than R, and a positive value if L is longer than R. If L and R are of the same size but their content differs, this function returns a negative value if L is less than R, or a positive value if L is greater than R, where L and R are compared as arrays of bytes.
Creates an LDAPControl structure based on a BerElement, an OID, and a criticality flag.
#include "slapi-plugin.h" int slapi_build_control( char const *oid, BerElement const *ber, char iscritical, LDAPControl **ctrlp );
This function takes the following parameters:
The OID (object identifier) for the control that is to be created.
A BerElement that contains the control value. Pass NULL if the control has no value.
The criticality flag. If non-zero, the control will be marked as critical. If 0, it will not be marked as critical.
Pointer that will receive the allocated LDAPControl structure.
This function returns LDAP_SUCCESS (LDAP result code) if successful.
This function creates an LDAPControl structure based on a BerElement, an OID, and a criticality flag. The LDAPControl that is created can be used in LDAP client requests or internal operations.
You can construct a BerElement using ber_init(3LDAP) for example.
Directory Server makes a copy of the oid string.
The contents of the ber parameter are the responsibility of the caller.
You can free the ber parameter of the slapi_build_control() using ber_free (3LDAP).
The LDAPControl pointer that is returned in ctrlp should be freed by calling ldap_control_free(3LDAP), which is an LDAP API function.
ber_free(3LDAP) ber_init(3LDAP) ldap_control_free(3LDAP)
slapi_build_control_from_berval()
Creates an LDAPControl structure based on a berval structure, an OID, and a criticality flag.
#include "slapi-plugin.h" int slapi_build_control_from_berval( char const *oid, struct berval *bvp, char iscritical, LDAPControl **ctrlp );
This function takes the following parameters:
The OID (object identifier) for the control that is to be created.
A berval that contains the control value. Pass NULL if the control has no value.
The criticality flag. If non-zero, the control will be marked as critical. If 0, it will not be marked as critical.
Pointer that will receive the allocated LDAPControl structure.
This function always returns LDAP_SUCCESS (LDAP result code).
This function creates an LDAPControl structure based on a berval, an OID, and a criticality flag. The LDAPControl that is created can be used in LDAP client requests or internal operations.
Directory Server makes a copy of the oid string.
The contents of the bvp parameter are consumed by this function. Because of this, the caller should not free the bvp->bv_val pointer once a successful call to this function has been made.
The LDAPControl pointer that is returned in ctrlp should be freed by calling ldap_control_free(3LDAP), which is an LDAP API function.
ldap_control_free(3LDAP)
Frees an existing array.
#include "slapi-plugin.h" void slapi_ch_array_free( char **arrayp );
This function takes the following parameter:
Pointer to the array to be freed. This parameter can be NULL.
This function frees the char ** pointed to by arrayp . In the following excerpt, for example, both array and a1 are freed:
char **array; char *a1; array = malloc(2*sizeof(char *)); a1 = strdup("hello"); array[0] = a1; array[1] = NULL; slapi_ch_array_free(array);
Makes a copy of an existing berval structure.
#include "slapi-plugin.h" struct berval* slapi_ch_bvdup( const struct berval *v );
This function takes the following parameter:
Pointer to the berval structure that you want to copy.
This function returns a pointer to the new copy of the berval structure. If the structure cannot be duplicated (for example, if no more virtual memory exists), the slapd program terminates.
The contents of the v parameter are not altered by this function. The returned berval structure should be freed by calling ber_bvfree(3LDAP), which is an LDAP API function.
ber_bvfree(3LDAP)
Makes a copy of an array of existing berval structures.
#include "slapi-plugin.h" extern struct berval** slapi_ch_bvecdup (const struct berval **v);
This function takes the following parameters:
Pointer to the array of berval structures that you want to copy.
This function returns a pointer to an array of the new copy of the berval structures. If the structures cannot be duplicated (for example, if no more virtual memory exists), the slapd program terminates.
The contents of the v parameter are not altered by this function. The returned berval structure should be freed by calling ber_bvfree(3LDAP), an LDAP API function.
ber_bvfree(3LDAP)
Allocates space for an array of a number of elements of a specified size.
#include "slapi-plugin.h" char * slapi_ch_calloc( unsigned long nelem, unsigned long size );
This function takes the following parameters:
Number of elements for which you wish to allocate memory.
Size in bytes of the element for which you wish to allocate memory.
This function returns a pointer to the newly allocated space of memory. If space cannot be allocated (for example, if no more virtual memory exists), the slapd program terminates.
This function should be called instead of the standard calloc() C function, and terminates the slapd server with an “out of memory” error message if memory cannot be allocated.
You should free the returned pointer by calling slapi_ch_free() .
Frees space allocated by the slapi_ch_malloc(),slapi_ch_realloc(), and slapi_ch_calloc() functions and sets the pointer to NULL. Call this function instead of the standard free() C function.
#include "slapi-plugin.h" void slapi_ch_free( void **ptr );
This function takes the following parameter:
Address of the pointer to the block of memory that you wish to free. If NULL, no action occurs.
The ptr passed to slapi_ch_free() should be the address of a pointer to memory allocated using a call to slapi_ch_malloc(),slapi_ch_realloc(),slapi_ch_calloc(), or slapi_ch_strdup() .
Frees an existing string allocated by the slapi_ch_malloc() ,slapi_ch_realloc(), and slapi_ch_calloc(). Call this function instead of the standard free() C function.
#include "slapi-plugin.h" void slapi_ch_free_string( char **s );
This function takes the following parameter:
Address of the string that you wish to free.
This function frees an existing string, and should be used in favor of slapi_ch_free() when using strings. It will perform compile-time error checking for incorrect error arguments, as opposed to slapi_ch_free(), which defeats the compile-time checking because you must cast the argument to (void**).
Allocates space in memory.
#include "slapi-plugin.h" char * slapi_ch_malloc( unsigned long size );
This function takes the following parameter:
Size in bytes of the space for which you wish to get the memory.
This function returns a pointer to the newly allocated space of memory. If space cannot be allocated (for example, if no more virtual memory exists), the slapd program terminates.
This function should be called instead of the standard malloc() C function, and terminates the slapd server with an “out of memory” error message if memory cannot be allocated.
The returned pointer should be freed by calling slapi_ch_free() .
Changes the size of a block of allocated memory.
#include "slapi-plugin.h" char * slapi_ch_realloc( char *block, unsigned long size );
This function takes the following parameters:
Pointer to an existing block of allocated memory.
New size (in bytes) of the block of memory you want allocated.
This function returns a pointer to the reallocated space of memory. If space cannot be allocated (for example, if no more virtual memory exists), the slapd program terminates.
This function should be called instead of the standard realloc() C function, and terminates the slapd server with an “out of memory” error message if memory cannot be allocated.
The block parameter passed to this function should be the address of a pointer that was allocated using a slapi call such as slapi_ch_malloc(),slapi_ch_calloc(), or slapi_ch_strdup().
The returned pointer should be freed by calling slapi_ch_free() .
Makes a copy of an existing string.
#include "slapi-plugin.h" char * slapi_ch_strdup( char *s );
This function takes the following parameter:
Pointer to the string you want to copy.
This function returns a pointer to a copy of the string. If space cannot be allocated (for example, if no more virtual memory exists), the slapd program terminates.
This function should be called instead of the standard strdup() C function, and terminates the slapd server with an “out of memory” error message if memory cannot be allocated.
The returned pointer should be freed by calling slapi_ch_free() .
Sets a callback for use by the server in evaluating which computed attributes to generate and include in an entry before returning a result to a client.
#include "slapi-plugin.h" int slapi_compute_add_evaluator(slapi_compute_callback_t fcn);
This function takes the following parameters:
Function to call when evaluating computed attributes
This function returns 0 if successful. Otherwise, it returns ENOMEM indicating that no memory could be allocated for the callback.
For a description of the callback, refer to slapi_compute_callback_t . Register the callback as part of plug-in initialization.
Sets callbacks for use by the server in searching against computed attributes.
#include "slapi-plugin.h" int slapi_compute_add_search_rewriter_ex( slapi_search_rewrite_callback_t function, slapi_search_rewrite_callback_t cleanup_function);
This function takes the following parameters:
Function to call to rewrite a filter for the search
Function to call to cleanup after performing the rewritten search
This function returns 0 if successful. Otherwise, it returns ENOMEM indicating that no memory could be allocated for the callback.
For a description of the callbacks, refer to the Chapter 15, Data Type and Structure Reference
Determines whether or not the specified object identifier (OID) identifies a control that is present in a list of controls.
#include "slapi-plugin.h" int slapi_control_present( LDAPControl **controls, char const *oid, struct berval **val, int *iscritical );
This function takes the following parameters:
List of controls that you want to check.
OID of the control that you want to find.
If the control is present in the list of controls, this function specifies the pointer to the berval structure containing the value of the control. If you do not want to receive a pointer to the control value, pass NULL for this parameter.
If the control is present in the list of controls, this function specifies whether or not the control is critical to the operation of the server:
0 means that the control is not critical to the operation.
1 means that the control is critical to the operation.
If you do not want to receive an indication of whether the control is critical or not, pass NULL for this parameter.
This function returns one of the following values:
1 if the specified control is present in the list of controls.
0 if the control is not present in the list of controls.
The val output parameter is set to point into the controls array. A copy of the control value is not made.
slapi_register_supported_control()
Performs an LDAP delete operation based on a parameter block to remove a directory entry.
#include "slapi-plugin.h" int slapi_delete_internal_pb(Slapi_PBlock *pb);
This function takes the following parameter:
A parameter block that has been initialized using slapi_delete_internal_set_pb().
This function returns -1 if the parameter passed is a NULL pointer. Otherwise, it returns 0.
After your code calls this function, the server sets SLAPI_PLUGIN_INTOP_RESULT in the parameter block to the appropriate LDAP result code. You can therefore check SLAPI_PLUGIN_INTOP_RESULT in the parameter block to determine whether an error has occurred.
This function performs an internal delete operation based on a parameter block. The parameter block should be initialized by calling slapi_delete_internal_set_pb() .
None of the parameters that are passed to slapi_delete_internal_set_pb() are altered or consumed by this function.
slapi_delete_internal_set_pb()
Prepares a parameter block for an internal delete operation.
#include "slapi-plugin.h" int 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:
Parameter block for the internal add operation
Distinguished Name of the entry to add
Array of controls to request for the add operation
Unique identifier for the entry if using this rather than DN.
Plug-in identifier obtained from SLAPI_PLUGIN_IDENTITY during plug-in initialization
NULL or SLAPI_OP_FLAG_NEVER_CHAIN
This function returns 0 if successful. Otherwise, it returns an LDAP error code.
This function prepares a parameter block for use with slapi_delete_internal_pb() using the components of the entry.
Allocate the parameter block using slapi_pblock_new() before calling this function.
Directory Server does not free the parameters you passed to this function.
Free the parameter block after calling slapi_delete_internal_pb() .
Frees a Slapi_CondVar structure from memory.
#include "slapi-plugin.h" void slapi_destroy_condvar( Slapi_CondVar *cvar );
This function takes the following parameters:
Pointer to the Slapi_CondVar structure that you want to free from memory.
This function frees a Slapi_CondVar structure from memory. Before calling this function, you should make sure that this condition variable is no longer in use.
Frees a Slapi_Mutex structure from memory.
#include "slapi-plugin.h" void slapi_destroy_mutex( Slapi_Mutex *mutex );
This function takes the following parameters:
Pointer to the Slapi_Mutex structure that you want to free from memory.
This function frees a Slapi_Mutex structure from memory. The calling function must ensure that no thread is currently in a lock-specific function. Locks do not provide self-referential protection against deletion.
Gets a copy of the distinguished name (DN) of the parent of an entry, unless the specified entry’s DN is the suffix of the local database.
If you do not want to check if the entry’s DN is the suffix of the local database, call the slapi_dn_parent() function instead.
#include "slapi-plugin.h" char *slapi_dn_beparent( Slapi_PBlock *pb, char *dn );
This function takes the following parameters:
Parameter block.
DN of the entry for which you want to find the parent.
This function returns the DN of the parent entry; or NULL if the specified DN is NULL, if the DN is an empty string, if the DN has no parent (for example, o=example.com), or if the specified DN is the suffix of the local database.
Converts all characters in a distinguished name (DN) to lowercase.
#include "slapi-plugin.h" char *slapi_dn_ignore_case( char *dn );
This function takes the following parameters:
DN that you want to convert to lowercase.
This function returns the DN with lowercase characters. Notice that the variable passed in as the dn argument is also converted in place.
Determines whether or not the specified distinguished name (DN) is the suffix of the local database. Before calling this function, you should call slapi_dn_normalize_case() to normalize the DN and convert all characters to lowercase.
#include "slapi-plugin.h" int slapi_dn_isbesuffix( Slapi_PBlock *pb, char *dn );
This function takes the following parameters:
Parameter block.
DN that you want to check.
This function returns 1 if the specified DN is the suffix for the local database, or 0 if the DN is not the suffix.
Determines whether or not the specified distinguished name (DN) is the suffix of the local database.
#include "slapi-plugin.h" int slapi_dn_isbesuffix_norm( Slapi_PBlock *pb, const char *dn );
This function takes the following parameters:
Parameter block.
DN that you want to check.
This function returns 1 if the specified DN is the suffix for the local database, or 0 if the DN is not the suffix.
Determines whether or not a particular DN is the parent of another specified DN. Before calling this function, you should call slapi_dn_normalize_case() to normalize the DNs and convert all characters to lowercase.
#include "slapi-plugin.h" int slapi_dn_isparent( const char *parentdn, char *childdn );
This function takes the following parameters:
Determine if this DN is the parent of childdn.
Determine if this DN is the child of parentdn.
This function returns a non-zero value if parentdn is the parent of childdn, or 0 if the parentdn is not the parent of childdn.
Determines if the specified DN is the root DN for this local database. Before calling this function, you should call slapi_dn_normalize_case() to normalize the DN and convert all characters to lowercase.
#include "slapi-plugin.h" int slapi_dn_isroot( Slapi_PBlock *pb, char *dn );
This function takes the following parameters:
Parameter block.
DN that you want to check.
This function returns 1 if the specified DN is the root DN of the local database, or 0 if the DN is not the root DN.
Determines if a DN is equal to the specified suffix. Before calling this function, you should call slapi_dn_normalize_case() to normalize the DN and convert all characters to lowercase.
If you want to determine if a DN is the same as the suffix for the local database, call the slapi_dn_isbesuffix_norm() function instead.
#include "slapi-plugin.h" int slapi_dn_issuffix( const char *dn, const char *suffix );
This function takes the following parameters:
DN that you want to check.
Suffix that you want compared against the DN.
This function returns 1 if the specified DN is the same as the specified suffix, or 0 if the DN is not the same as the suffix.
Converts a distinguished name (DN) to canonical format (no leading or trailing spaces, no spaces between components, and no spaces around the equals sign). For example, given the following DN:
cn = Moxie Cross , ou = Engineering , dc = example , dc = com
the function returns:
cn=Moxie Cross,ou=Engineering,dc=example,dc=com
#include "slapi-plugin.h" char *slapi_dn_normalize( char *dn );
This function takes the following parameters:
DN that you want to normalize.
This function returns the normalized DN. Notice that the variable passed in as the dn argument is also converted in place.
Converts a distinguished name (DN) to canonical format and converts all characters to lowercase. Calling this function has the same effect as calling the slapi_dn_normalize() function followed by the slapi_dn_ignore_case() function.
#include "slapi-plugin.h" char *slapi_dn_normalize_case( char *dn );
This function takes the following parameters:
DN that you want to normalize and convert to lowercase.
This function returns the normalized DN with all lowercase characters. Notice that variable passed in as the dn argument is also converted in-place.
Normalizes part of a DN value, specifically, the part going from what is pointed to by dn to that pointed to by end.
Notice that this routine does not NULL terminate the normalized bit pointed to by dn at the return of the function.
If the argument end happens to be NULL, this routine does basically the same thing as slapi_dn_normalize(), except for NULL terminating the normalized DN.
#include "slapi-plugin.h" char *slapi_dn_normalize_to_end( char *dn, char *end );
This function takes the following parameters:
DN value to be normalized.
Pointer to the end of what will be normalized from the DN value in dn. If this argument is NULL, the DN value in dn will be wholly normalized.
This function returns a pointer to the end of the dn that has been normalized. In other words, the normalized portion is from * dn to * (returnValue - 1).
Gets a copy of the distinguished name (DN) of the parent of an entry. Before calling this function, you should call slapi_dn_normalize_case() to normalize the DN and convert all characters to lowercase.
If you want to check if the DN is the suffix of the local database, call the slapi_dn_beparent() function instead.
#include "slapi-plugin.h" char *slapi_dn_parent( char *dn );
This function takes the following parameter:
DN of the entry for which you want to find the parent.
This function returns the DN of the parent entry. If the specified DN is NULL, if the DN is an empty string, or if the DN has no parent (for example, o=example.com), the function returns NULL.
Adds an RDN to DN.
#include "slapi-plugin.h" char *slapi_dn_plus_rdn( const char *dn, const char *rdn);
This function takes the following parameters:
DN value to which a new RDN is to be added.
RDN value that is to be added to the DN value in dn.
This function returns the new DN formed by adding the RDN value in rdn to the DN value in dn.
You must free the string returned with slapi_ch_free_string().
Makes an allocated copy of an LDAPControl.
#include "slapi-plugin.h" LDAPControl * slapi_dup_control( LDAPControl const *ctrl );
This function takes the following parameter:
Pointer to an LDAPControl structure whose contents are to be duplicated.
This function returns a pointer to an allocated LDAPControl structure if successful, or NULL if an error occurs.
This function duplicates the contents of an LDAPControl structure. All fields within the LDAPControl are copied to a new, allocated structure, and a pointer to the new structure is returned.
The structure that is returned should be freed by calling ldap_control_free(3LDAP) , an LDAP API function.
ldap_control_free(3LDAP)
Creates an array of LDAPMod from a Slapi_Entry.
#include "slapi-plugin.h" int slapi_entry2mods(const Slapi_Entry *e, char **dn, LDAPMod ***attrs);
This function takes the following parameters:
Pointer to a Slapi_Entry.
Address of a char* that will be set on return to the entry DN.
Address of an array of LDAPMod that will be set on return to a copy of the entry attributes.
This function returns one of the following values:
0 if successful.
non-0 if not successful.
This function creates an array of LDAPMod of type LDAP_MOD_ADD from a Slapi_Entry. Such structures may be useful for example when performing LDAP add and modify operations as a client from inside a plug-in.
Generates an LDIF string description of an LDAP entry.
#include "slapi-plugin.h" char *slapi_entry2str( Slapi_Entry const *e, int *len );
This function takes the following parameters:
Entry that you want to convert into an LDIF string.
Length of the returned LDIF string.
Returns the LDIF string representation of the entry you specify. If an error occurs, the function returns NULL.
This function generates an LDIF string value conforming to the following format:
dn: dn\n [attr: value\n]*
For example:
dn: uid=jdoe, ou=People, o=example.com cn: Jane Doe sn: Doe ...
To convert a string description in LDIF format to an entry of the Slapi_Entry data type, call the slapi_str2entry() function.
When you no longer need to use the string, you should free it from memory by calling the slapi_ch_free_string() function.
slapi_entry2str_with_options()
Generates a description of an entry as an LDIF string. This function behaves much like slapi_str2entry(). You can however specify output options with this function.
#include "slapi-plugin.h" char *slapi_entry2str_with_options( Slapi_Entry const *e, int *len, int options );
This function takes the following parameters:
Entry that you want to convert into an LDIF string.
Length of the LDIF string returned by this function.
An option set that specifies how you want the string converted.
You can OR together any of the following options when you call this function:
This function returns the LDIF string representation of the entry you specify or NULL if an error occurs.
This function generates an LDIF string value conforming to the following syntax:
dn: dn\n [attr: value\n]*
For example:
dn: uid=jdoe, ou=People, o=example.com cn: Jane Doe sn: Doe ...
To convert an entry described in LDIF string format to an LDAP entry using the Slapi_Entry data type, call the slapi_str2entry() function.
When you no longer need to use the string, you should free it from memory by calling the slapi_ch_free_string() function.
Adds the components in an entry’s relative distinguished name (RDN) to the entry as attribute values. (For example, if the entry’s RDN is uid=bjensen, the function adds uid=bjensen to the entry as an attribute value.)
#include "slapi-plugin.h" int slapi_entry_add_rdn_values( Slapi_Entry *e );
This function takes the following parameter:
Entry to which you want to add the RDN attributes.
This function returns one of the following values:
LDAP_SUCCESS if the values were successfully added to the entry. The function also returns LDAP_SUCCESS if the entry is NULL, if the entry’s DN is NULL, or if the entry’s RDN is NULL.
LDAP_INVALID_DN_SYNTAX if the DN of the entry cannot be parsed.
If the attribute type corresponding to the RDN already has a value matching the RDN value for equality, the value is not added. This function does not however examine other attrbute types not in the RDN, whose values may match the RDN value for equality.
Free the entry from memory by using slapi_entry_free() if the entry was allocated by the user.
Adds a string value to an attribute in an entry.
#include "slapi-plugin.h" int slapi_entry_add_string (Slapi_Entry *e, const char *type, const char *value);
This function takes the following parameters:
Entry to which you want to add a string value.
Attribute to which you want to add a string value.
String value you want to add.
This function returns 0 when successful; any other value returned signals failure.
This function adds a string value to the existing attribute values in an entry. If the specified attribute does not exist in the entry, the attribute is created with the string value specified.
This function does not check whether the value is already present for the attribute. Use slapi_entry_attr_delete() before using this function.
This function also does not check whether the value added is a duplicate of an existing value.
This routine makes a copy of the parameter value. If value is NULL, the entry is not changed.
Adds a specified Slapi_Value data value to an attribute in an entry.
#include "slapi-plugin.h" int slapi_entry_add_value (Slapi_Entry *e, const char *type, const Slapi_Value *value);
This function takes the following parameters:
Entry to which you want to add a value.
Attribute to which you want to add a value.
The Slapi_Value data value you want to add to the entry.
Returns 0 when successful; any other value returned signals failure.
This function adds a Slapi_Value data value to the existing attribute values in an entry. If the specified attribute does not exist in the entry, the attribute is created with the Slapi_Value specified.
This function does not check whether the value added is a duplicate of an existing value.
This routine makes a copy of the parameter value. If value is NULL, the entry is not changed.
Adds an array of Slapi_Value data values to the specified attribute in an entry.
#include "slapi-plugin.h" int slapi_entry_add_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
This function takes the following parameters:
Entry to which you want to add values.
Attribute type to which you want to add values.
Array of Slapi_Value data values that you want to add.
Returns one of the following values:
LDAP_SUCCESS if the Slapi_Value array is successfully added to the attribute.
LDAP_TYPE_OR_VALUE_EXISTS if any values you are trying to add duplicate an existing value in the attribute.
LDAP_OPERATIONS_ERROR if there are pre-existing duplicate values in the attribute.
This function adds an array of Slapi_Value data values to an attribute. If the attribute does not exist, it is created and given the value contained in the Slapi_Value array.
This function replaces the deprecated slapi_entry_add_values() function. This function uses Slapi_Value attribute values instead of the berval attribute values.
This routine makes a copy of the parameter vals. vals can be NULL.
Add a Slapi_ValueSet data value to the specified attribute in an entry.
#include "slapi-plugin.h" int slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs);
This function takes the following parameters:
Entry to which you want to add values.
Attribute type to which you want to add values.
Slapi_ValueSet data value that you want to add to the entry.
Returns 0 when successful; any other value returned signals failure.
This function adds a set of values to an attribute in an entry. The values added are in the form of a Slapi_ValueSet data type. If the entry does not contain the attribute specified, it is created with the specified Slapi_ValueSet value.
This routine makes a copy of the parameter vs. vs can be NULL.
Allocates memory for a new entry of the data type Slapi_Entry .
#include "slapi-plugin.h" Slapi_Entry *slapi_entry_alloc();
Returns a pointer to the newly allocated entry of the data type Slapi_Entry. If space cannot be allocated (for example, if no more virtual memory exists), the slapd program terminates.
This function returns an empty Slapi_Entry structure.
When you are no longer using the entry, you should free it from memory by calling the slapi_entry_free() function.
Deletes an attribute (and all its associated values) from an entry.
#include "slapi-plugin.h" int slapi_entry_attr_delete( Slapi_Entry *e, const char *type );
This function takes the following parameters:
Entry from which you want to delete the attribute.
Attribute type that you want to delete.
This function returns one of the following values:
0 if successful.
1 if the specified attribute is not part of the entry.
-1 if an error occurred.
Determines if an entry contains the specified attribute. If the entry contains the attribute, the function returns a pointer to the attribute.
#include "slapi-plugin.h" int slapi_entry_attr_find( const Slapi_Entry *e, const char *type, Slapi_Attr **attr );
This function takes the following parameters:
Entry that you want to check.
Name of the attribute that you want to check.
Pointer to the attribute, if the attribute is in the entry.
This function returns 0 if the entry contains the specified attribute; otherwise it returns -1.
Do not free the returned attr. It is a pointer to the internal entry data structure. It is usually wise to make a copy of the returned attr, using slapi_attr_dup(), to avoid dangling pointers if the entry is freed while the pointer to attr is still being used.
Gets the first value of an attribute in an entry as a string.
#include "slapi-plugin.h" char *slapi_entry_attr_get_charptr(const Slapi_Entry* e, const char *type);
This function takes the following parameters:
Entry from which you want to get the string value.
Attribute type from which you want to get the value.
This function returns a copy of the first value in the attribute, or NULL if the entry does not contain the attribute.
When you are done working with this value, you should free it from memory by calling the slapi_ch_free() function.
Gets the first value of an attribute in an entry as an integer.
#include "slapi-plugin.h" int slapi_entry_attr_get_int(const Slapi_Entry* e,const char *type);
This function takes the following parameters:
Entry from which you want to get the integer value.
Attribute type from which you want to get the value.
Returns the first value in the attribute converted to an integer or 0 if the entry does not contain the attribute.
Gets the first value of an attribute in an entry as a long data type.
#include "slapi-plugin.h" long slapi_entry_attr_get_long( const Slapi_Entry* e, const char *type);
This function takes the following parameters:
Entry from which you want to get the long value.
Attribute type from which you want to get the value.
This function returns the first value in the attribute converted to a long type. The function returns 0 if the entry does not contain the attribute specified.
Gets the first value of an attribute in an entry as a unsigned integer data type.
#include "slapi-plugin.h" unsigned int slapi_entry_attr_get_uint( const Slapi_Entry* e, const char *type);
This function takes the following parameters:
Entry from which you want to get the value.
Attribute type from which you want to get the value.
This function returns the first value in the attribute converted to an unsigned integer. The function returns 0 if the entry does not contain the attribute specified.
Gets the first value of an attribute in an entry as a unsigned long data type.
#include "slapi-plugin.h" unsigned long slapi_entry_attr_get_ulong( const Slapi_Entry* e, const char *type);
This function takes the following parameters:
Entry from which you want to get the value.
Attribute type from which you want to get the value.
This function returns the first value in the attribute converted to an unsigned long. The function returns 0 if the entry does not contain the attribute specified.
This function is deprecated. It determines if an attribute in an entry contains a specified value by comparing the specified value as a string with the existing values, and does not compare using the equality matching rule.
#include "slapi-plugin.h" int slapi_entry_attr_hasvalue(Slapi_Entry *e, const char *type, const char *value);
This function takes the following parameters:
Entry that you want to check.
Attribute type that you want to test for the value specified.
Value that you want to find in the attribute.
Returns one of the following values:
1 if the attribute contains the specified value.
0 if the attribute does not contain the specified value.
value must not be NULL.
Adds an array of Slapi_Value data values to the existing attribute values in an entry. If the attribute does not exist, it is created with the Slapi_Value specified.
#include "slapi-plugin.h" int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
This function takes the following parameters:
Entry to which you want to add values.
Attribute to which you want to add values.
Array of Slapi_Value data values you want to add.
Returns 0 if successful; any other value returned signals failure.
This function replaces the deprecated slapi_entry_attr_merge() function. This function uses Slapi_Value attribute values instead of the berval attribute values.
This function makes a copy of the parameter vals. vals can be NULL.
Replaces the values of an attribute with the Slapi_Value data value you specify.
#include "slapi-plugin.h" int slapi_entry_attr_replace_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
This function takes the following parameters:
Entry in which you want to replace values.
Attribute type which will receive the replaced values.
Array containing the Slapi_Value values that should replace the existing values of the attribute.
This function returns 0 when successful; any other value returned signals failure.
This function replaces existing attribute values in a specified entry with a single Slapi_Value data value. The function first deletes the existing attribute from the entry, then replaces it with the new value specified.
This function replaces the deprecated slapi_entry_attr_replace() function. This function uses Slapi_Value attribute values instead of the berval attribute values.
This function makes a copy of the parameter vals. vals can be NULL.
Replaces the value or values of an attribute in an entry with a specified string value.
#include "slapi-plugin.h" void slapi_entry_attr_set_charptr(Slapi_Entry* e, const char *type, const char *value);
This function takes the following parameters:
Entry in which you want to set the value.
Attribute type in which you want to set the value.
String value that you want to assign to the attribute.
This function makes a copy of the parameter values. values can be NULL, and if so, this function is roughly equivalent to slapi_entry_attr_delete().
Replaces the value or values of an attribute in an entry with a specified integer data value.
#include "slapi-plugin.h" void slapi_entry_attr_set_int(Slapi_Entry* e, const char *type, int l);
This function takes the following parameters:
Entry in which you want to set the value.
Attribute type in which you want to set the value.
Integer value that you want assigned to the attribute.
This function will replace the value or values of an attribute with the integer value that you specify. If the attribute does not exist, it is created with the integer value that you specify.
Replaces the value or values of an attribute in an entry with a specified long data type value.
#include "slapi-plugin.h" void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, unsigned long l);
This function takes the following parameters:
Entry in which you want to set the value.
Attribute type in which you want to set the value.
Long integer value that you want assigned to the attribute.
Replaces the value or values of an attribute in an entry with a specified unsigned integer data type value.
#include "slapi-plugin.h" void slapi_entry_attr_set_uint(Slapi_Entry* e, const char *type, unsigned int l);
This function takes the following parameters:
Entry in which you want to set the value.
Attribute type in which you want to set the value.
Unsigned integer value that you want assigned to the attribute.
This function will replace the value or values of an attribute with the unsigned integer value that you specify. If the attribute does not exist, it is created with the unsigned integer value you specify.
Replaces the value or values of an attribute in an entry with a specified unsigned long data type value.
#include "slapi-plugin.h" void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l);
This function takes the following parameters:
Entry in which you want to set the value.
Attribute type in which you want to set the value.
Unsigned long value that you want assigned to the attribute.
This function will replace the value or values of an attribute with the unsigned long value that you specify. If the attribute does not exist, it is created with the unsigned long value that you specify.
Deletes a string value from an attribute in an entry.
#include "slapi-plugin.h" int slapi_entry_delete_string(Slapi_Entry *e, const char *type, const char *value);
This function takes the following parameters:
Entry from which you want the string deleted.
Attribute type from which you want the string deleted.
Value of string to delete.
Returns 0 when successful; any other value returned signals failure.
Removes an array of Slapi_Value data values from an attribute in an entry.
#include "slapi-plugin.h" int slapi_entry_delete_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
This function takes the following parameters:
Entry from which you want to delete values.
Attribute from which you want to delete values.
Array of Slapi_Value data values that you want to delete.
Returns LDAP_SUCCESS if the specified attribute and the array of Slapi_Value data values are deleted from the entry.
If the specified attribute contains a NULL value, the attribute is deleted from the attribute list and the function returns LDAP_NO_SUCH_ATTRIBUTE . Additionally, if the attribute is not found in the list of attributes for the specified entry, the function returns LDAP_NO_SUCH_ATTRIBUTE.
If there is an operational error during the processing of this call (such as a duplicate value found), the function will return LDAP_OPERATIONS_ERROR . If this occurs, please report the problem to Sun support services.
This function removes an attribute/value set from an entry. Notice that both the attribute and its Slapi_Value data values are removed from the entry. If you supply a Slapi_Value whose value is NULL, the function will delete the specified attribute from the entry. In either case, the function returns LDAP_SUCCESS.
This function replaces the deprecated slapi_entry_delete_values() function. This function uses Slapi_Value attribute values instead of the berval attribute values.
The vals parameter can be NULL, in which case, this function does nothing.
Makes a copy of an entry, its DN, and its attributes.
#include "slapi-plugin.h" Slapi_Entry *slapi_entry_dup( const Slapi_Entry *e );
This function takes the following parameter:
Entry that you want to copy.
This function returns the new copy of the entry. If the structure cannot be duplicated (for example, if no more virtual memory exists), the slapd program terminates.
This function returns a copy of an existing Slapi_Entry structure. You can call other front-end functions to change the DN and attributes of this entry.
When you are no longer using the entry, you should free it from memory by calling the slapi_entry_free() function.
Finds the first attribute in an entry. If you want to iterate through the attributes in an entry, use this function in conjunction with the slapi_entry_next_attr() function.
#include "slapi-plugin.h" int slapi_entry_first_attr( Slapi_Entry *e, Slapi_Attr **attr );
This function takes the following parameters:
Entry from which you want to get the attribute.
Pointer to the first attribute in the entry.
Returns 0 when successful; any other value returned signals failure.
Do not free the returned attr. This is a pointer into the internal entry data structure. If you need a copy, use slapi_attr_dup() .
Frees an entry, its DN, and its attributes from memory.
#include "slapi-plugin.h" void slapi_entry_free( Slapi_Entry *e );
This function takes the following parameter:
Entry that you want to free. If NULL, no action occurs.
Call this function to free an entry that you have allocated by using the slapi_entry_alloc() function or the slapi_entry_dup() function.
To free entries, always use this function, as opposed to using slapi_ch_free(), or free().
Gets the distinguished name (DN) of the specified entry.
#include "slapi-plugin.h" char *slapi_entry_get_dn( Slapi_Entry *e );
This function takes the following parameter:
Entry from which you want to get the DN.
This function returns the DN of the entry. Notice that this returns a pointer to the actual DN in the entry, not a copy of the DN. You should not free the DN unless you plan to replace it by calling slapi_entry_set_dn().
Use slapi_ch_free() if you are replacing the DN with slapi_entry_set_dn().
Returns as a const the DN value of the entry that you specify.
#include "slapi-plugin.h" const char *slapi_entry_get_dn_const( const Slapi_Entry *e );
This function takes the following parameter:
Entry from which you want to get the DN as a constant.
This function returns the DN of the entry that you specify. The DN is returned as a const; you are not able to modify the DN value. If the DN of the Slapi_DN object is NULL, the NDN value of Slapi_DN is returned.
Never free this value.
Returns the normalized DN from the entry that you specify.
#include "slapi-plugin.h" char *slapi_entry_get_ndn( Slapi_Entry *e );
This function takes the following parameter:
Entry from which you want to obtain the normalized DN.
This function returns the normalized DN from the entry that you specify. If the entry you specify does not contain a normalized DN, one is created through the processing of this function.
Never free this value.
Returns the Slapi_DN object from the entry that you specify.
#include "slapi-plugin.h" Slapi_DN *slapi_entry_get_sdn( Slapi_Entry *e );
This function takes the following parameter:
Entry from which you want to get the Slapi_DN object.
This function returns the Slapi_DN object from the entry that you specify.
Never free this value. If you need a copy, use slapi_sdn_dup() .
Returns as a const the value of the Slapi_DN object from the entry that you specify.
#include "slapi-plugin.h" const Slapi_DN *slapi_entry_get_sdn_const ( const Slapi_Entry *e );
This function takes the following parameter:
Entry from which you want to get the Slapi_DN object.
Returns as a const the value of the Slapi_DN object from the entry that you specify.
Never free this value. If you need a copy, use slapi_sdn_dup() .
Gets the unique ID value of the entry.
#include "slapi-plugin.h" const char *slapi_entry_get_uniqueid( const Slapi_Entry *e );
This function takes the following parameter:
Entry from which you want obtain the unique ID.
This function returns the unique ID value of the entry specified.
Never free this value. If you need a copy, use slapi_ch_strdup() .
This function determines if the specified entry has child entries in the backend where it resides.
#include "slapi-plugin.h" int slapi_entry_has_children( const Slapi_Entry *e );
This function takes the following parameter:
Entry that you want to test for child entries.
This function returns 1 if the entry you supply has child entries in the backend where it resides; otherwise it returns 0. Notice that if a subsuffix is in another backend, this function does not find children contained in that subsuffix.
Initializes the values of an entry with the DN and attribute value pairs you supply.
#include "slapi-plugin.h" void slapi_entry_init(Slapi_Entry *e, char *dn, Slapi_Attr *a);
This function takes the following parameters:
The entry you want to initialize.
The DN of the entry you are initializing.
Initialization list of attribute value pairs, supplied as a Slapi_Attr data value.
This function initializes the attributes and the corresponding attribute values of an entry. Also, during the course of processing, the unique ID of the entry is set to NULL and the flag value is set to 0.
Use this function to initialize a Slapi_Entry pointer.
This function should always be used after slapi_entry_alloc() , and never otherwise. For example:
Slapi_Entry *e = slapi_entry_alloc(); slapi_entry_init(e, NULL, NULL);
To set the DN in the entry:
slapi_sdn_set_dn_passin(slapi_entry_get_sdn(e), dn);
In this case, the dn argument is not copied, but is consumed by the function. To copy the argument, see the following example:
char *dn = slapi_ch_strdup(some_dn); Slapi_Entry *e = slapi_entry_alloc(); slapi_entry_init(e, dn, NULL);
dn is not freed in this context, but is eventually be freed when slapi_entry_free() is called.
Identifies whether the entry having the specified DN is a root DN (directory super user).
#include "slapi-plugin.h" into slapi_entry_isroot( const char *dn );
This function takes the following parameter:
The DN of the entry to check.
This function returns one of the following values:
The entry with the specified DN is that of a root user (directory super user).
The entry with the specified DN is not that of a root user.
Merges (adds) an array of Slapi_Value data values to a specified attribute in an entry. If the entry does not contain the attribute specified, the attribute is created with the value supplied.
#include "slapi-plugin.h" int slapi_entry_merge_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals );
This function takes the following parameters:
Entry into which you want to merge values.
Attribute type that contains the values you want to merge.
Values that you want to merge into the entry. Values are of type Slapi_Value.
This function returns either LDAP_SUCCESS or LDAP_NO_SUCH_ATTRIBUTE .
This function adds additional Slapi_Value data values to the existing values contained in an attribute. If the attribute type does not exist, it is created.
If the specified attribute exists in the entry, the function merges the value specified and returns LDAP_SUCCESS. If the attribute is not found in the entry, the function creates it with the Slapi_Value specified and returns LDAP_NO_SUCH_ATTRIBUTE.
Notice that if this function fails, it leaves the values for type within a pointer to e in an indeterminate state. The present value set may be truncated.
This function makes a copy of vals. vals can be NULL.
Finds the next attribute after prevattr in an entry. To iterate through the attributes in an entry, use this function in conjunction with the slapi_entry_first_attr() function.
#include "slapi-plugin.h" int slapi_entry_next_attr( Slapi_Entry *e, Slapi_Attr *prevattr, Slapi_Attr **attr );
This function takes the following parameters:
Entry from which you want to get the attribute.
Previous attribute in the entry.
Pointer to the next attribute after prevattr in the entry.
This function returns 0 if successful or -1 if prevattr was the last attribute in the entry.
Never free the returned attr. Use slapi_attr_dup() to make a copy if a copy is needed.
Determines if the values in an entry’s relative distinguished name (RDN) are also present as attribute values. (For example, if the entry’s RDN is cn=Barbara Jensen, the function determines if the entry has the cn attribute with the value Barbara Jensen.)
#include "slapi-plugin.h" int slapi_entry_rdn_values_present( Slapi_Entry *e );
This function takes the following parameter:
Entry from which you want to get the attribute.
This function returns 1 if the values in the RDN are present in attributes of the entry or 0 if the values are not present.
Determines whether or not the specified entry complies with the schema for its object class.
#include "slapi-plugin.h" int slapi_entry_schema_check( Slapi_PBlock *pb, Slapi_Entry *e );
This function takes the following parameters:
Parameter block.
Entry of which you want to check the schema.
Returns one of the following values:
0 if the entry complies with the schema or if schema checking is turned off. The function also returns 0 if the entry has additional attributes not allowed by the schema and has the object class extensibleObject.
1 if the entry is missing the objectclass attribute, if it is missing any required attributes, if it has any attributes not allowed by the schema (but does not have the object class extensibleObject ), or if the entry has multiple values for a single-valued attribute.
The pb argument can be NULL. It is used only to get the SLAPI_IS_REPLICATED_OPERATION flag. If that flag is present, no schema checking is done.
Determines whether or not the proposed modifications to the specified entry comply with the schema for the entry's object class. This function does not check existing attributes not affected by the modifications.
#include "slapi-plugin.h" int slapi_entry_schema_check_ext( Slapi_PBlock *pb, Slapi_Entry *e, LDAPMod **mods );
This function takes the following parameters:
Parameter block.
Entry of which you want to check the schema.
Pointer to the modify structure whose attribute values are to be checked.
Returns one of the following values:
0 if the proposed modifications to the entry comply with the schema or if schema checking is turned off. The function also returns 0 if the entry has additional attributes not allowed by the schema and has the object class extensibleObject.
1 if the modifications cause the objectclass attribute or other required attributes to be missing, if the modifications add any attributes not allowed by the schema, or if the modifications result in multiple values for a single-valued attribute.
The pb argument can be NULL. It is used only to get the SLAPI_IS_REPLICATED_OPERATION flag. If that flag is present, no schema checking is done.
Sets the distinguished name (DN) of an entry.
#include "slapi-plugin.h" void slapi_entry_set_dn( Slapi_Entry *e, char *dn );
This function takes the following parameters:
Entry to which you want to assign the DN.
Distinguished name you want assigned to the entry.
This function sets a pointer to the DN supplied in the specified entry.
dn is freed when slapi_entry_free() is called.
A copy of dn should be passed, for example:
char *dn = slapi_ch_strdup(some_dn); slapi_entry_set_dn(e, dn);
The old dn is freed as a result of this call. Do not pass in a NULL value.
Sets the Slapi_DN value in an entry.
#include "slapi-plugin.h" void slapi_entry_set_sdn( Slapi_Entry *e, const Slapi_DN *sdn );
This function takes the following parameters:
Entry to which you want to set the value of the Slapi_DN.
The specified Slapi_DN value that you want to set.
This function sets the value for the Slapi_DN object in the entry you specify.
This function makes a copy of the sdn argument.
This function returns the approximate size of an entry, rounded to the nearest 1k. This can be useful for checking cache sizes, estimating storage needs, and so on.
#include "slapi-plugin.h" size_t slapi_entry_size(Slapi_Entry *e);
This function takes the following parameter:
Entry from which you want the size returned.
This function returns the size of the entry, rounded to the nearest 1k. The value returned is a size_t data type, with is a u_long value. If the entry is empty, a size of 1k is returned.
When determining the size of an entry, only the sizes of the attribute values are counted; the size of other entry values (such as the size of attribute names, variously-normalized DNs, or any metadata) are not included in the size returned. It is assumed that the size of the metadata is well enough accounted for by the rounding of the size to the next largest 1k (this holds true especially in larger entries, where the actual size of the attribute values far outweighs the size of the metadata).
Notice that when determining the size of the entry, both deleted values and deleted attributes are included in the count.
This function determines whether the values of attributes present on the specified entry comply with attribute syntax rules.
#include "slapi-plugin.h" int slapi_entry_syntax_check( Slapi_PBlock *pb, Slapi_Entry *e );
This function takes the following parameters:
Parameter block.
Entry whose attributes to check for syntax compliance.
Returns one of the following values:
0 if the entry attribute values comply or if syntax checking is turned off.
1 if the entry attribute values do not comply with attribute syntax rules.
The pb argument can be NULL. It is used only to get the SLAPI_IS_REPLICATED_OPERATION flag. If that flag is present, no syntax checking is done.
This function determines whether the specified virtual attribute is present, and returns that attribute if available.
#include "slapi-plugin.h" int slapi_entry_vattr_find(const Slapi_Entry *e, const char *type, Slapi_Attr **a, int *buffer_flags);
This function takes the following parameters:
Entry to check for the virtual attribute.
Attribute type of the virtual attribute.
Structure to hold the virtual attribute.
Bitmask indicated whether the caller needs to free the attribute.
Returns one of the following values:
0 if the entry contains the virtual attribute specified by type.
In this case a points to the virtual attribute, and buffer_flags holds SLAPI_VIRTUALATTRS_RETURNED_COPIES meaning the structure a must be freed, or SLAPI_VIRTUALATTRS_RETURNED_POINTERS and it should not be freed.
-1 if the entry does not contain the attribute.
Determines if two filters are identical.
#include "slapi-plugin.h" int slapi_filter_compare(struct slapi_filter *f1, struct slapi_filter *f2);
This function takes the following parameters:
First filter to compare.
Second filter to compare.
This function returns 0 if the two filters are identical, or a value other than 0 if they are not.
This function allows you to determine if two filters are identical, and/or are allowed to be in a different order.
Frees the specified filter and (optionally) the set of filters that comprise it (for example, the set of filters in an LDAP_FILTER_AND type filter).
#include "slapi-plugin.h" void slapi_filter_free( Slapi_Filter *f, int recurse );
This function takes the following parameters:
Filter that you want to free.
If 1, recursively frees all filters that comprise this filter. If 0, only frees the filter specified by f.
Description
This function frees the filter in parameter f.
Filters created using slapi_str2filter() must be freed after using this function. Filters extracted from a parameter block using:
slapi_pblock_get( pb, SLAPI_SEARCH_FILTER, &filter );
must not be freed.
Gets the attribute type for all simple filter choices.
#include "slapi-plugin.h" int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type );
This function takes the following parameters:
Filter from which you wish to get the substring values.
Pointer to the attribute type of the filter.
This function returns the attribute type of the filter.
This function gets the attribute type for all simple filter choices:
LDAP_FILTER_GE
LDAP_FILTER_LE
LDAP_FILTER_APPROX
LDAP_FILTER_EQUALITY
LDAP_FILTER_SUBSTRINGS
LDAP_FILTER_PRESENT
LDAP_FILTER_EXTENDED
LDAP_FILTER_AND
LDAP_FILTER_OR
LDAP_FILTER_NOT
A filter such as (mail-foo) will return the type mail.
The attribute type is returned in type and should not be freed after calling this function. It will be freed at the same time as the Slapi_Filter structure when slapi_filter_free() is called.
(Applies only to filters of the types LDAP_FILTER_EQUALITY, LDAP_FILTER_GE, LDAP_FILTER_LE, LDAP_FILTER_APPROX ) Gets the attribute type and the value from the filter.
#include "slapi-plugin.h" int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **bval );
This function takes the following parameters:
Filter from which you wish to get the attribute and value.
Pointer to the attribute type of the filter.
Pointer to the address of the berval structure containing the value of the filter.
This function returns 0 if successful, or -1 if the filter is not one of the types listed above.
Filters of the type LDAP_FILTER_EQUALITY, LDAP_FILTER_GE , LDAP_FILTER_LE, and LDAP_FILTER_APPROX generally compare a value against an attribute. For example:
(cn=Barbara Jensen)
This filter finds entries in which the value of the cn attribute is equal to Barbara Jensen.
The attribute type is returned in the parameter type, and the value is returned in the parameter bval.
The strings within the parameters type and bval are direct pointers to memory inside the Slapi_Filter , and therefore should not be freed after usage. They will be freed when a server entity calls slapi_filter_free() after usage of the Slapi_Filter structure.
slapi_filter_get_attribute_type()
Gets the type of the specified filter such as LDAP_FILTER_EQUALITY, for example.
#include "slapi-plugin.h" int slapi_filter_get_choice( Slapi_Filter *f );
This function takes the following parameter:
Filter type that you wish to get.
This function returns one of the following values:
LDAP_FILTER_AND (AND filter)
For example: (&(ou=Accounting)(l=Sunnyvale))
LDAP_FILTER_OR (OR filter)
For example: (|(ou=Accounting)(l=Sunnyvale))
LDAP_FILTER_NOT (NOT filter)
For example: (!(l=Sunnyvale))
LDAP_FILTER_EQUALITY (equals filter)
For example: (ou=Accounting)
LDAP_FILTER_SUBSTRINGS (substring filter)
For example: (ou=Account*Department)
LDAP_FILTER_GE (“greater than or equal to” filter)
For example: (supportedLDAPVersion>=3)
LDAP_FILTER_LE (“less than or equal to” filter)
For example: (supportedLDAPVersion<=2)
LDAP_FILTER_PRESENT (presence filter)
For example: (mail=*)
LDAP_FILTER_APPROX (approximation filter)
For example: (ou~=Sales)
LDAP_FILTER_EXTENDED (extensible filter)
For example: (o:dn:=Example)
slapi_filter_get_attribute_type()
(Applies only to filters of the type LDAP_FILTER_SUBSTRINGS) Gets the substring values from the filter.
#include "slapi-plugin.h" int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial, char ***any, char **final );
This function takes the following parameters:
Filter from which you wish to get the substring values.
Pointer to the attribute type of the filter.
Pointer to the initial substring (“starts with”) of the filter.
Pointer to an array of the substrings (“contains”) for the filter.
Pointer to the final substring (“ends with”) of the filter.
This function returns one of the following values:
0 if successful.
-1 if the filter is not one of the types listed above.
Filters of the type LDAP_FILTER_SUBSTRINGS generally compare a set of substrings against an attribute. For example:
(cn=John*Q*Public)
This filter finds entries in which the value of the cn attribute starts with John, contains Q, and ends with Public.
Call this function to get these substring values as well as the attribute type from this filter. In the case of the example above, calling this function gets the initial substring John, the any substring Q, and the final substring Public in addition to the attribute type cn.
slapi_filter_get_attribute_type()
(Applies only to filters of the type LDAP_FILTER_PRESENT) Gets the attribute type specified in the filter.
#include "slapi-plugin.h" int slapi_filter_get_type( Slapi_Filter *f, char **type );
This function takes the following parameters:
Filter from which you want to get the substring values.
Pointer to the attribute type of the filter.
This function returns 0 if successful, or -1 if the filter is not one of the types listed above.
Filters of the type LDAP_FILTER_PRESENT generally determine if a specified attribute is assigned a value. For example:
(mail=*)
This filter finds entries that have a value assigned to the mail attribute.
Call this function to get the attribute type from this filter. In the case of the example above, calling this function gets the attribute type mail.
The string returned in the parameter type must not be freed after calling this function. It will be freed when the structure Slapi_Filter is freed by calling slapi_filter_free() .
slapi_filter_get_attribute_type()
Joins the two specified filters using one of the following filter types: LDAP_FILTER_AND, LDAP_FILTER_OR, or LDAP_FILTER_NOT . When specifying the filter type LDAP_FILTER_NOT, the second filter should be NULL.
#include "slapi-plugin.h" Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2 );
This function takes the following parameters:
Type of composite filter you want to create.
First filter that you want to join.
Second filter that you want to join. If ftype is LDAP_FILTER_NOT, specify NULL for this argument.
This function returns the new filter constructed from the other two filters.
Filters of the type LDAP_FILTER_AND, LDAP_FILTER_OR , and LDAP_FILTER_NOT generally consist of one or more other filters. For example:
(&(ou=Accounting)(l=Sunnyvale)) (|(ou=Accounting)(l=Sunnyvale)) (!(l=Sunnyvale))
Each of these examples contain one or more LDAP_FILTER_EQUALITY filters.
Call the slapi_filter_join() function to create a new filter of the type LDAP_FILTER_AND, LDAP_FILTER_OR, or LDAP_FILTER_NOT.
The f1 and f2 filters are not copied, nor freed, during the join process, but the resulting filter will have references pointing to these two filters.
(Applies only to filters of the types LDAP_FILTER_EQUALITY, LDAP_FILTER_GE, LDAP_FILTER_LE, LDAP_FILTER_APPROX ) Gets the first filter that makes up the specified filter.
#include "slapi-plugin.h" Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f );
This function takes the following parameter:
Filter of which you wish to get the first component.
The first filter that makes up the specified filter f.
To iterate through all filters that make up a specified filter, use this function in conjunction with the slapi_filter_list_next() function.
Filters of the type LDAP_FILTER_AND, LDAP_FILTER_OR , and LDAP_FILTER_NOT generally consist of one or more other filters. For example, if the filter is:
(&(ou=Accounting)(l=Sunnyvale))
the first filter in this list is:
(ou=Accounting)
Call this function to get the first filter in the list.
No duplication of the filter is done, so this filter should not be freed independently of the original filter.
(Applies only to filters of the types LDAP_FILTER_EQUALITY, LDAP_FILTER_GE, LDAP_FILTER_LE, LDAP_FILTER_APPROX ) Gets the next filter (following fprev) that makes up the specified filter f.
#include "slapi-plugin.h" Slapi_Filter *slapi_filter_list_next(Slapi_Filter *f, Slapi_Filter *fprev);
This function takes the following parameters:
Filter from which you want to get the next component (after fprev).
Filter within the specified filter f.
The next filter (after fprev) that makes up the specified filter f.
To iterate through all filters that make up a specified filter, use this function in conjunction with the slapi_filter_list_first() function.
Filters of the type LDAP_FILTER_AND, LDAP_FILTER_OR , and LDAP_FILTER_NOT generally consist of one or more other filters. For example, if the filter is:
(&(ou=Accounting)(l=Sunnyvale))
the next filter after (ou=Accounting) in this list is:
(l=Sunnyvale)
Call the slapi_filter_list_next() function to get the filters from this list.
No duplication of the filter is done, so the filter should not be freed independently of the original filter.
Determines if the specified entry matches a particular filter.
#include "slapi-plugin.h" int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f, int verify_access );
This function takes the following parameters:
Parameter block.
Entry that you want to test.
Filter that you want to test the entry against.
If 1, verifies that the current user has access rights to search the specified entry. If 0, bypasses any access control.
One of the following values:
0 if the entry matched the filter or if the specified filter is NULL.
-1 if the filter type is unknown.
A positive value (an LDAP error code) if an error occurred.
Determines if an entry matches a given filter.
#include "slapi-plugin.h" int slapi_filter_test_ext( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f, int verify_access, int only_test_access)
This function takes the following parameters:
Parameter block from which the user is extracted
The entry on which filter matching must be verified.
The filter used for filter matching.
0 when access checking is not to be done.
1 when access checking must be done.
0 when filter matching must be done.
1 when filter matching must not be done.
This function returns one of the following values:
0 if the entry matched the filter, or if the specified filter is NULL.
-1 if the filter type is unknown, or if the entry does not match the filter.
A positive value (an LDAP error code) if an error occurred, or if the current user does not have access rights to search the specified entry.
This function allows you to determine if an entry matches a given filter, or that the current user has the permission to access the entry.
Determines if an entry matches a filter.
#include "slapi-plugin.h" int slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f);
This function takes the following parameters:
Entry that you wish to test.
Filter to match the entry against.
This function returns one of the following values:
0 if the entry matched the filter, or if the specified filter is NULL.
-1 if the filter type is unknown, or if the entry does not match the filter.
A positive value (an LDAP error code) if an error occurred.
This function allows you to check if entry e matches filter f.
Find a right parenthesis matching a left parenthesis.
#include "slapi-plugin.h" char *slapi_find_matching_paren( const char *str );
This function takes the following parameters:
Pointer to a string starting with a left parenthesis
This function returns a pointer to the right parenthesis if successful. Otherwise, it returns NULL indicating that no matching right parenthesis was found.
This function takes a pointer to a string starting with a left parenthesis, (, and returns a pointer to the matching right parenthesis, ). It may be useful when evaluating complex search filter strings.
Frees search results returned by the slapi_search_internal_pb() and slapi_search_internal_callback_pb() functions.
#include "slapi-plugin.h" void slapi_free_search_results_internal(Slapi_PBlock *pb);
This function takes the following parameter:
Parameter block returned by the slapi_search_internal_pb() and slapi_search_internal_callback_pb() functions.
This function must be called when you are finished with the entries before freeing the parameter block.
Free a list of directory suffixes, such as a list obtained using slapi_get_suffix_list().
#include "slapi-plugin.h" void slapi_free_suffix_list(Slapi_DN ** suffix_list);
This function takes the following parameters:
Array of Distinguished Names for the suffixes to free.
This function frees each entry in suffix_list, and the suffix_list itself. It does not remove data from a database associated with the suffix.
Returns a pointer of the backend structure of the first backend.
#include "slapi-plugin.h" Slapi_Backend* slapi_get_first_backend(char **cookie);
This function takes the following parameter:
Output parameter containing the index of the returned backed. This is useful for calls to slapi_get_next_backend(). Contains 0 in output if no backend is returned.
This function returns a pointer to the backend structure of the first backend, and its index, in the cookie parameter, or NULL if there is no backend.
This function returns a pointer to the backend structure of the first backend. If you wish to iterate through all of the backends, use this function in conjunction with slapi_get_next_backend(). For example:
Slapi_Backend *be = NULL; char *cookie = NULL; be = slapi_get_first_backend (&cookie); while (be) { ... be = slapi_get_next_backend (cookie); } slapi_ch_free ((void**)&cookie);
Free the cookie parameter after the iteration using slapi_ch_free().
Access an object extension.
#include "slapi-plugin.h" void *slapi_get_object_extension(int objecttype, void *object, int extensionhandle);
This function takes the following parameters:
Type set by the server
Pointer to the object you extended
Handle set by the server
This function returns a pointer to the object extension registered using slapi_register_object_extension().
slapi_register_object_extension()
Returns a pointer to the next backend.
#include "slapi-plugin.h" Slapi_Backend* slapi_get_next_backend(char *cookie);
This function takes the following parameters:
Upon input, contains the index from which the search for the next backend is done. Upon output, contains the index of the returned backend.
This function returns a pointer to the next backend, if it exists, and updates the cookie parameter. Otherwise, it returns NULL and cookie is not changed.
This function returns a pointer to the next backend. If you wish to iterate through all of the backends, use this function in conjunction with slapi_get_first_backend(). For example:
Slapi_Backend *be = NULL; char *cookie = NULL; be = slapi_get_first_backend (&cookie); while (be ) { ... be = slapi_get_next_backend (cookie); } slapi_ch_free ((void**)&cookie);
Free the cookie parameter after the iteration using slapi_ch_free().
Returns an array of suffix DNs handled by the server.
#include "slapi-plugin.h" Slapi_DN ** slapi_get_suffix_list(int show_private, int *count);
This function takes the following parameters:
If set to 1, this list of DNs returned includes suffixes used by Directory Server that do not contain user data. Otherwise, only DNs of suffixes containing user data are returned.
Placeholder to contain the number of suffixes in the list.
This function returns a pointer to an array of Slapi_DN structures containing the base DNs of the suffixes. The count parameter contains the number of suffixes whose DNs are returned.
Free the list returned using slapi_free_suffix_list().
Retrieves an allocated array of object identifiers (OIDs) representing the controls supported by Directory Server. You can register new controls by calling slapi_register_supported_control().
#include "slapi-plugin.h" int slapi_get_supported_controls_copy( char ***ctrloidsp, unsigned long **ctrlopsp );
This function takes the following parameters:
Pointer to a character array that will receive the set of supported control OIDs. Pass NULL for this parameter if you do not wish to receive the OIDs.
Pointer to an unsigned long array that will receive the supported operation values for each control in the ctrloidsp array. Pass NULL for this parameter if you do not wish to receive the supported operation values.
This function returns 0 if successful, or a non-zero value if an error occurs.
This function replaces the deprecated slapi_get_supported_controls() function from previous releases, as it was not multithread safe.
When you call slapi_register_supported_control() to register a control, you specify the OID of the control and the IDs of the operations that support the control. The server records this information in two arrays; an array of control OIDs, and an array of operations that support the control. You can get copies of these arrays by calling slapi_entry_get_uniqueid() .
For each OID returned in the ctrloidsp array, the corresponding array element (with the same index) in the ctrlopsp array identifies the operations that support the control. For a list of the possible IDs for the operations, see slapi_register_supported_control().
The returned ctrloidsp array should be freed by calling slapi_ch_array_free(). The returned ctrlopsp array should be freed by calling slapi_ch_free().
slapi_register_supported_control()
Gets a copy of the object IDs (OIDs) of the extended operations.
#include "slapi-plugin.h" char **slapi_get_supported_extended_ops_copy ( void );
This function takes no parameters.
This function returns a pointer to an array of the OIDs of the extended operations supported by the server.
This function replaces the deprecated slapi_get_supported_extended_ops() function from earlier releases, as slapi_get_supported_extended_ops() was not multithread safe.
This function gets a copy of the object IDs (OIDs) of the extended operations supported by the server. You can register new extended operations by putting the OID in the SLAPI_PLUGIN_EXT_OP_OIDLIST parameter and calling slapi_pblock_set().
The array returned by this function should be freed by calling the slapi_ch_array_free() function.
Gets an array of the names of the supported Simple Authentication and Security Layer (SASL) mechanisms. You can register new SASL mechanisms by calling the slapi_register_supported_saslmechanism() function.
#include "slapi-plugin.h" char ** slapi_get_supported_saslmechanisms_copy( void );
This function returns a pointer to an array of the names of SASL mechanisms supported by the server.
Checks if a string has an 8-bit character.
#include "slapi-plugin.h" int slapi_has8thBit(unsigned char *s);
This function takes the following parameter:
Pointer to the NULL terminated string to test.
This function returns 1 if the string contains an 8-bit character, or 0 if it does not.
This function determines if an entry is the root DSE. The root DSE is a special entry that contains information about the Directory Server, including its capabilities and configuration.
#include "slapi-plugin.h" int slapi_is_rootdse ( const char *dn );
This function takes the following parameters:
The DN that you want to test to see if it is the root DSE entry.
This function returns 1 if dn is the root DSE; otherwise the function returns 0.
Checks if a suffix is a root suffix of the DIT.
#include "slapi-plugin.h" int slapi_is_root_suffix(Slapi_DN * dn);
This function takes the following parameter:
DN that you wish to check.
This function returns one of the following values:
0 if the DN is not a root suffix
1 if the DN is a root suffix
Get a thread-safe handle to an LDAP connection.
#include "slapi-plugin.h" LDAP *slapi_ldap_init(char *ldaphost, int ldapport, int secure, int shared);
This function takes the following parameters:
Host on which the LDAP server is running
Port on which the LDAP server is listening
1 for a secure connection over SSL, NULL otherwise
If not NULL, then the connection may be shared between threads
This function allows a plug-in to retrieve a thread-safe handle to an LDAP connection. When done with the handle, call slapi_ldap_unbind().
A timeout may be set for the connection using the Directory SDK for C provided as part of Directory Server Resource Kit. Example 16–1 demonstrates how to set a timeout.
#include "slapi-plugin.h" #include "ldap.h" void my_ldap_function(void) { LDAP * ld; int to = 5000; /* 5000 ms == 5 s timeout */ if ((ld = slapi_ldap_init(host, port, 0, 1)) == NULL) { /* error trying to create an LDAP session */ return -1; } if (ldap_set_option(ld, LDAP_X_OPT_CONNECT_TIMEOUT, &to) != 0) { /* error setting timeout */ slapi_ldap_unbind(ld); return -1; } /* Use the handle for a search for example. */ slapi_ldap_unbind(ld); return 0; }
This function returns an LDAP connection handle if successful. Otherwise, it returns NULL.
Release an LDAP connection obtained using slapi_ldap_init() .
#include "slapi-plugin.h" void slapi_ldap_unbind( LDAP *ld );
This function takes the following parameters:
Handle to the LDAP connection
This function allows a plug-in to release an LDAP connection obtained using slapi_ldap_init().
Determines whether the proposed modifications comply with attribute syntax rules.
#include "slapi-plugin.h" int slapi_ldapmods_syntax_check( Slapi_PBlock *pb, LDAPMod **mods );
This function takes the following parameters:
Parameter block.
Pointer to the modify structure whose attribute values are to be checked.
Returns one of the following values:
0 if the proposed modifications comply with attribute syntax rules, or if syntax checking is turned off.
1 if the modifications do not comply with attribute syntax rules.
The pb argument can be NULL. It is used only to get the SLAPI_IS_REPLICATED_OPERATION flag. If that flag is present, no syntax checking is done.
Lock a mutex.
#include "slapi-plugin.h" void slapi_lock_mutex( Slapi_Mutex *mutex );
This function takes the following parameters:
Mutex for thread synchronization
This function allows thread synchronization. Once a thread has locked a mutex using this function, other threads attempting to acquire the lock are blocked until the thread holding the mutex calls slapi_UTF-8STRTOLOWER().
Write an error message to the server error log.
#include "slapi-plugin.h" int slapi_log_error_ex(long errorId, long msgId, int connId, int opId, char const * subsystem, char const * humanReadableMsg, char const * fmt, /* args */ ...);
This function takes the following parameters:
Unique identifier you provide for this error message
Identifier for the current message obtained using SLAPI_OPERATION_MSGID
Identifier for the current connection obtained using SLAPI_CONN_ID
Identifier for the current operation obtained using SLAPI_OPERATION_ID
String indicating the context in which the warning arose such as the name of the plug-in function logging the message
String message identifying this warning
Format specification in the style of printf()
Arguments for the format specification in fmt
This function writes the specified error message to the server error log in synchronous fashion. This function does not return until the log message has been flushed to disk, thus blocking the server for the duration of the write operation. By default, the error log is $INSTANCE_PATH/logs/errors.
Unlike slapi_log_info_ex(), this function cannot be turned off.
Error messages typically concern fatal errors. For warnings, use slapi_log_warning_ex(). For informational log messages, use slapi_log_info_ex().
Example 16–2 shows a call to slapi_log_error_ex().
#include "slapi-plugin.h" #include "example-com-error-ids.h" /* example.com unique error IDs file */ int foobar(Slapi_PBlock * pb) { char * error_cause; int apocalypse = 1; /* Expect the worst. */ /* ... */ if (apocalypse) { /* Server to crash soon */ slapi_log_error_ex( EXCOM_SERVER_MORIBUND, /* Unique error ID */ SLAPI_LOG_NO_MSGID, SLAPI_LOG_NO_CONNID, SLAPI_LOG_NO_OPID, "example.com: foobar in baz plug-in", "cannot write to file system: %s\n", error_cause ); return -1; } return 0; }
This function returns 0 if successful. Otherwise, it returns -1.
Write an informational message to the server error log.
#include "slapi-plugin.h" int slapi_log_info_ex(slapi_log_info_area_t area, slapi_log_info_level_t level, long msgId, int connId, int opId, char const * subsystem, char const * fmt, /* args */, ...);
This function takes the following parameters:
Identifies the server component so logging can be turned on by adding the decimal value of the area to the value for nsslapd-infolog-area. Subtract from the value to turn informational logging off.
Identifies whether the server should log this message when informational logging is activated for area.
When informational logging is activated, setting level to:
SLAPI_LOG_INFO_LEVEL_DEFAULT means always log the message.
SLAPI_LOG_INFO_LEVEL_EXTRA means only log if the value of nsslapd-infolog-level is greater than 0.
Identifier for the current message obtained using SLAPI_OPERATION_MSGID
Identifier for the current connection obtained using SLAPI_CONN_ID
Identifier for the current operation obtained using SLAPI_OPERATION_ID
String indicating the context in which the warning arose such as the name of the plug-in function logging the message
Format specification in the style of printf()
Arguments for the format specification in fmt
This function writes the specified error message to the server error log in synchronous fashion. This function does not return until the log message has been flushed to disk, thus blocking the server for the duration of the write operation. By default, the error log is $INSTANCE_PATH/logs/errors.
This function is turned off by default. Activate logging of the message with the dsconf set-log-prop command.
You can also manage logs using Directory Service Control Center.
Informational message are typically those that system administrators may ignore unless trying to debug server behavior. For errors, use slapi_log_error_ex() . For warnings, use slapi_log_warning_ex().
Example 16–3 shows a call to slapi_log_info_ex().
#include "slapi-plugin.h" int hello() { slapi_log_info_ex( SLAPI_LOG_INFO_AREA_PLUGIN, SLAPI_LOG_INFO_LEVEL_DEFAULT, SLAPI_LOG_NO_MSGID, SLAPI_LOG_NO_CONNID, SLAPI_LOG_NO_OPID, "hello() from a plug-in", "Hello, World!\n" ); return 0; }
This function returns 0 if successful. Otherwise, it returns -1.
Write a warning message to the server error log.
#include "slapi-plugin.h" int slapi_log_warning_ex(long warningId, long msgId, int connId, int opId, char const * subsystem, char const * humanReadableMsg, char const * fmt, /* args */ ...);
This function takes the following parameters:
Unique identifier you provide for this warning message
Identifier for the current message obtained using SLAPI_OPERATION_MSGID
Identifier for the current connection obtained using SLAPI_CONN_ID
Identifier for the current operation obtained using SLAPI_OPERATION_ID
String indicating the context in which the warning arose such as the name of the plug-in function logging the message
String message identifying this warning
Format specification in the style of printf()
Arguments for the format specification in fmt
This function writes the specified error message to the server error log in synchronous fashion. This function does not return until the log message has been flushed to disk, thus blocking the server for the duration of the write operation. By default, the error log is $INSTANCE_PATH/logs/errors.
Unlike slapi_log_info_ex(), this function cannot be turned off.
Warning messages typically concern potentially serious situations, but not fatal errors. For fatal errors, use slapi_log_error_ex(). For informational log messages, use slapi_log_info_ex().
Example 16–4 shows a call to slapi_log_warning_ex().
#include "slapi-plugin.h" #include "example-com-warning-ids.h" /* example.com unique warning IDs file */ int foobar() { int disk_use_percentage; /* ... */ if (disk_use_percentage >= 95){ slapi_log_warning_ex( EXCOM_DISK_FULL_WARN, /* unique warning ID */ SLAPI_LOG_NO_MSGID, SLAPI_LOG_NO_CONNID, SLAPI_LOG_NO_OPID, "example.com: foobar in baz plug-in", "disk %.0f%% full, find more space\n", (float)disk_use_percentage ); } return 0; } |
This function returns 0 if successful. Otherwise, it returns -1.
Free a Slapi_MatchingRuleEntry after registering the matching rule.
#include "slapi-plugin.h" void slapi_matchingrule_free(Slapi_MatchingRuleEntry **mrEntry, int freeMembers);
This function takes the following parameters:
Matching rule registration object
Whether to free the members of the Slapi_MatchingRuleEntry
If 0, do not free the members of the Slapi_MatchingRuleEntry.
This function frees memory allocated to a Slapi_MatchingRuleEntry after the structure has been used to register a matching rule.
Access a Slapi_MatchingRuleEntry member.
#include "slapi-plugin.h" int slapi_matchingrule_get(Slapi_MatchingRuleEntry *mr, int arg, void *value);
This function takes the following parameters:
Matching rule registration object
Identifier for the Slapi_MatchingRuleEntry member:
SLAPI_MATCHINGRULE_DESC, a string describing the matching rule
SLAPI_MATCHINGRULE_NAME, a string identifying the matching rule
SLAPI_MATCHINGRULE_OID, a string representing the matching rule object identifier
SLAPI_MATCHINGRULE_SYNTAX, the matching rule syntax OID string 1.3.6.1.4.1.1466.115.121.1.15
SLAPI_MATCHINGRULE_OBSOLETE, an int identifying whether the rule is obsolete
Value retrieved from the member
This function accesses a Slapi_MatchingRuleEntry member based on the identifier in arg.
This function returns 0 if successful. Otherwise, it returns -1.
Allocate a Slapi_MatchingRuleEntry.
#include "slapi-plugin.h" Slapi_MatchingRuleEntry *slapi_matchingrule_new(void);
This function allocates a Slapi_MatchingRuleEntry used to register a matching rule.
This function returns a pointer to the matching rule registration object if successful. Otherwise, it returns NULL.
Register a matching rule with the server.
#include "slapi-plugin.h" int slapi_matchingrule_register(Slapi_MatchingRuleEntry *mrEntry);
This function takes the following parameters:
Matching rule registration object
This function registers a Slapi_MatchingRuleEntry with the server. Register matching rules as part of the plug-in initialization function.
First, allocate the structure using slapi_matchingrule_new() . Next, set the members of the matching rule entry using slapi_matchingrule_set(). After setting the members, register the matching rule with the server using this function. Finally, free the memory allocated using slapi_matchingrule_free().
This function returns 0 if successful. Otherwise, it returns -1.
Modify a Slapi_MatchingRuleEntry member.
#include "slapi-plugin.h" int slapi_matchingrule_set(Slapi_MatchingRuleEntry *mr, int arg, void *value);
This function takes the following parameters:
Matching rule registration object
Identifier for the Slapi_MatchingRuleEntry member:
SLAPI_MATCHINGRULE_DESC, a string describing the matching rule
SLAPI_MATCHINGRULE_NAME, a string identifying the matching rule
SLAPI_MATCHINGRULE_OID, a string representing the matching rule object identifier
SLAPI_MATCHINGRULE_SYNTAX, the matching rule syntax OID string 1.3.6.1.4.1.1466.115.121.1.15
SLAPI_MATCHINGRULE_OBSOLETE, an int identifying whether the rule is obsolete
Value to affect to the member
This function modifies a Slapi_MatchingRuleEntry member based on the identifier in arg.
This function returns 0 if successful. Otherwise, it returns -1.
Adds a value to a Slapi_Mod structure.
#include "slapi-plugin.h" void slapi_mod_add_value(Slapi_Mod *smod, const struct berval *val);
This function takes the following parameters:
Adds a copy of a given attribute to the Slapi_Mod.
Frees the internals of Slapi_Mod structure.
#include "slapi-plugin.h" void slapi_mod_done(Slapi_Mod *mod);
This function takes the following parameter:
Pointer to a Slapi_Mod.
This function frees the internals of a Slapi_Mod, leaving it in the uninitialized state.
Use this function on a stack-allocated Slapi_Mod when you have finished with it, or wish to reuse it.
Dumps the contents of an LDAPMod to the server log.
#include "slapi-plugin.h" void slapi_mod_dump(LDAPMod *mod, int n);
This function takes the following parameters:
Pointer to an LDAPMod.
Numeric label that will be included in the log.
This function uses the LDAP_DEBUG_ANY log level to dump the contents of an LDAPMod to $INSTANCE_PATH/logs/errors for debugging.
Frees a Slapi_Mod structure.
#include "slapi-plugin.h" void slapi_mod_free(Slapi_Mod **smod);
This function takes the following parameter:
Pointer to an initialized Slapi_Mod.
This function frees a Slapi_Mod structure that was allocated by slapi_mod_new().
Initializes a Slapi_Mod iterator and returns the first attribute value.
#include "slapi-plugin.h" struct berval *slapi_mod_get_first_value(Slapi_Mod *smod);
This function takes the following parameter:
Pointer to an initialized Slapi_Mod.
This function returns a pointer to the first attribute value in the Slapi_Mod, or NULL if no values exist.
Use this function with slapi_mod_get_next_value() to iterate through the attribute values in a Slapi_Mod structure.
Gets a reference to the LDAPMod in a Slapi_Mod structure.
#include "slapi-plugin.h" const LDAPMod *slapi_mod_get_ldapmod_byref(const Slapi_Mod *smod);
This function takes the following parameter:
Pointer to an initialized Slapi_Mod.
This function returns a pointer to a read-only LDAPMod owned by the Slapi_Mod.
Use this function to get direct access to the LDAPMod contained in a Slapi_Mod.
Responsibility for the LDAPMod remains with the Slapi_Mod.
slapi_mod_get_ldapmod_passout()
Retrieves the LDAPMod contained in a Slapi_Mod structure.
#include "slapi-plugin.h" LDAPMod *slapi_mod_get_ldapmod_passout(Slapi_Mod *smod);
This function takes the following parameter:
Pointer to an initialized Slapi_Mod.
This function returns a pointer to an LDAPMod owned by the caller.
Use this function to get the LDAPMod out of a Slapi_Mod.
Responsibility for the LDAPMod transfers to the caller. The Slapi_Mod is left in the uninitialized state.
Increments the Slapi_Mod iterator and returns the next attribute value.
#include "slapi-plugin.h" struct berval *slapi_mod_get_next_value(Slapi_Mod *smod);
This function takes the following parameter:
Pointer to an initialized Slapi_Mod.
This function returns a pointer to the next attribute value in the Slapi_Mod, or NULL if there are no more.
Use this function with slapi_mod_get_first_value() to iterate through the attribute values in a Slapi_Mod.
Gets the number of values in a Slapi_Mod structure.
#include "slapi-plugin.h" int slapi_mod_get_num_values(const Slapi_Mod *smod);
This function takes the following parameter:
Pointer to an initialized Slapi_Mod.
This function returns the number of attribute values in the Slapi_Mod.
Gets the operation type of Slapi_Mod structure.
#include "slapi-plugin.h" int slapi_mod_get_operation(const Slapi_Mod *smod);
This function takes the following parameter:
Pointer to an initialized Slapi_Mod.
This function returns one of LDAP_MOD_ADD, LDAP_MOD_DELETE , LDAP_MOD_REPLACE, combined using the bitwise or operator with LDAP_MOD_BVALUES.
Gets the attribute type of a Slapi_Mod structure.
#include "slapi-plugin.h" const char *slapi_mod_get_type(const Slapi_Mod *smod);
This function takes the following parameter:
Pointer to an initialized Slapi_Mod.
This function returns a read-only pointer to the attribute type in the Slapi_Mod.
Gets the LDAP attribute type of a Slapi_Mod.
Initializes a Slapi_Mod structure.
#include "slapi-plugin.h" void slapi_mod_init(Slapi_Mod *smod, int initCount);
This function takes the following parameters:
Pointer to an uninitialized Slapi_Mod.
Suggested number of attribute values for which to make room. Minimum value is 0.
This function initializes a Slapi_Mod so that it is empty, but initially has room for the given number of attribute values.
If you are unsure of the room you will need, you may use an initCount of 0. The Slapi_Mod expands as necessary.
Initializes a Slapi_Mod structure that is a wrapper for an existing LDAPMod.
#include "slapi-plugin.h" void slapi_mod_init_byref(Slapi_Mod *smod, LDAPMod *mod);
This function takes the following parameters:
This function initializes a Slapi_Mod containing a reference to an LDAPMod. Use this function when you have an LDAPMod and would like the convenience of the Slapi_Mod functions to access it.
Initializes a Slapi_Mod structure with a copy of an LDAPMod.
#include "slapi-plugin.h" void slapi_mod_init_byval(Slapi_Mod *smod, const LDAPMod *mod);
This function takes the following parameters:
Initializes a Slapi_Mod from an LDAPMod.
#include "slapi-plugin.h" void slapi_mod_init_passin(Slapi_Mod *smod, LDAPMod *mod);
This function takes the following parameters:
This function initializes a Slapi_Mod by passing in an LDAPMod. Use this function to convert an LDAPMod to a Slapi_Mod.
Responsibility for the LDAPMod is transferred to the Slapi_Mod. The LDAPMod is destroyed when the Slapi_Mod is destroyed.
Determines whether a Slapi_Mod structure is valid.
#include "slapi-plugin.h" int slapi_mod_isvalid(const Slapi_Mod *mod);
This function takes the following parameters:
Pointer to a Slapi_Mod.
This function returns one of the following values:
Use this function to verify that the contents of Slapi_Mod are valid. It is considered valid if the operation type is one of LDAP_MOD_ADD, LDAP_MOD_DELETE, LDAP_MOD_REPLACE , combined using the bitwise or operator with LDAP_MOD_BVALUES ; the attribute type is not NULL; and there is at least one attribute value for add and replace operations.
Allocates a new Slapi_Mod structure.
#include "slapi-plugin.h" Slapi_Mod* slapi_mod_new( void );
This function takes no parameters.
This function returns a pointer to an allocated, uninitialized Slapi_Mod.
This function allocates a new uninitialized Slapi_Mod . Use this function when you need to a Slapi_Mod allocated from the heap, rather than from the stack.
Removes the value at the current Slapi_Mod iterator position.
#include "slapi-plugin.h" void slapi_mod_remove_value(Slapi_Mod *smod);
This function takes the following parameter:
Pointer to an initialized Slapi_Mod.
Sets the operation type of a Slapi_Mod structure.
#include "slapi-plugin.h" void slapi_mod_set_operation(Slapi_Mod *smod, int op);
This function takes the following parameters:
Pointer to an initialized Slapi_Mod.
One of LDAP_MOD_ADD, LDAP_MOD_DELETE, LDAP_MOD_REPLACE, combined using the bitwise or operator with LDAP_MOD_BVALUES.
Sets the attribute type of a Slapi_Mod.
#include "slapi-plugin.h" void slapi_mod_set_type(Slapi_Mod *smod, const char *type);
This function takes the following parameters:
Pointer to an initialized Slapi_Mod.
An attribute type.
Sets the attribute type of the Slapi_Mod to a copy of the given value.
Builds the new DN of an entry.
#include "slapi-plugin.h" char * slapi_moddn_get_newdn(Slapi_DN *dn_olddn, char *newrdn, char *newsuperiordn);
This function takes the following parameters:
The old DN value.
The new RDN value.
If not NULL, will be the DN of the future superior entry of the new DN, which will be worked out by adding the value in newrdn in front of the content of this parameter.
This function returns the new DN for the entry whose previous DN was dn_olddn.
This function is used for moddn operations and builds a new DN out of a new RDN and the DN of the new parent.
The new DN is worked out by adding the new RDN in newrdn to a parent DN. The parent will be the value in newsuperiordn, if different from NULL, and will otherwise be taken from dn_olddn by removing the old RDN. (The parent of the entry will still be the same as the new DN).
You must free the DN returned using slapi_ch_free_string() .
This chapter contains the second part of the reference to the public functions for writing plug-ins. The previous chapter contains the first part of the reference.
Sections in the previous chapter cover plug-in API functions from slapi_access_allowed() to slapi_moddn_get_newdn().
The following sections cover plug-in API functions in alphabetical order from slapi_modify_internal_pb() to slapi_wait_condvar().
Performs an LDAP modify operation based on a parameter block to modify a directory entry.
#include "slapi-plugin.h" int slapi_modify_internal_pb(Slapi_PBlock *pb);
This function takes the following parameter:
A parameter block that has been initialized using slapi_modify_internal_set_pb().
This function returns -1 if the parameter passed is a NULL pointer. Otherwise, it returns 0.
After your code calls this function, the server sets SLAPI_PLUGIN_INTOP_RESULT in the parameter block to the appropriate LDAP result code. You can therefore check SLAPI_PLUGIN_INTOP_RESULT in the parameter block to determine whether an error has occurred.
This function performs an internal modify operation based on a parameter block. The parameter block should be initialized by calling slapi_modify_internal_set_pb() .
None of the parameters that are passed to slapi_modify_internal_set_pb() are altered or consumed by this function.
Prepares a parameter block for an internal modify operation.
#include "slapi-plugin.h" int 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:
Parameter block for the internal modify operation
Distinguished Name of the entry to modify
Array of modifications to apply
Array of controls to request for the modify operation
Unique identifier for the entry if using this rather than DN
Plug-in identifier obtained from SLAPI_PLUGIN_IDENTITY during plug-in initialization
NULL or SLAPI_OP_FLAG_NEVER_CHAIN
This function returns 0 if successful. Otherwise, it returns an LDAP error code.
This function prepares a parameter block for use with slapi_modify_internal_pb().
Allocate the parameter block using slapi_pblock_new() before calling this function.
Directory Server does not free the parameters you passed to this function.
Free the parameter block after calling slapi_modify_internal_pb() .
Performs an LDAP modify RDN operation based on a parameter block to rename a directory entry.
#include "slapi-plugin.h" int slapi_modrdn_internal_pb(Slapi_PBlock *pb);
This function takes the following parameter:
A parameter block that has been initialized using slapi_rename_internal_set_pb().
This function returns -1 if the parameter passed is a NULL pointer. Otherwise, it returns 0.
After your code calls this function, the server sets SLAPI_PLUGIN_INTOP_RESULT in the parameter block to the appropriate LDAP result code. You can therefore check SLAPI_PLUGIN_INTOP_RESULT in the parameter block to determine whether an error has occurred.
This function performs an internal modify RDN operation based on a parameter block. The parameter block should be initialized by calling slapi_rename_internal_set_pb().
None of the parameters that are passed to slapi_rename_internal_set_pb() are altered or consumed by this function.
slapi_rename_internal_set_pb()
Creates a Slapi_Entry from an array of LDAPMod.
#include "slapi-plugin.h" int slapi_mods2entry(Slapi_Entry **e, const char *dn, LDAPMod **attrs);
This function takes the following parameters:
Address of a pointer that will be set on return to the created entry.
The LDAP DN of the entry.
An array of LDAPMod of type LDAP_MOD_ADD representing the entry attributes.
This function returns LDAP_SUCCESS if successful, or an LDAP return code if not successful.
This function creates a Slapi_Entry from a copy of an array of LDAPMod of type LDAP_MODD_ADD .
Appends a new mod with a single attribute value to Slapi_Mods structure.
#include "slapi-plugin.h" void slapi_mods_add( Slapi_Mods *smods, int modtype, const char *type, unsigned long len, const char *val);
This function takes the following parameters:
Pointer to an initialized Slapi_Mods.
One of LDAP_MOD_ADD, LDAP_MOD_DELETE, LDAP_MOD_REPLACE.
The LDAP attribute type.
The length in bytes of the attribute value.
The attribute value.
This function appends a new mod with a single attribute value to a Slapi_Mods. The mod is constructed from copies of the values of modtype, type, len, and val.
This function must not be used on Slapi_Mods initialized with slapi_mods_init_byref().
Appends an LDAPMod to a Slapi_Mods structure.
#include "slapi-plugin.h" void slapi_mods_add_ldapmod(Slapi_Mods *smods, LDAPMod *mod);
This function takes the following parameters:
Pointer to an initialized Slapi_Mods.
Pointer to a the LDAPMod to be appended.
Appends an LDAPMod to a Slapi_Mods.
Responsibility for the LDAPMod is transferred to the Slapi_Mods.
This function must not be used on a Slapi_Mods initialized with slapi_mods_init_byref().
Appends a new mod to a Slapi_Mods structure, with attribute values provided as an array of Slapi_Value.
#include "slapi-plugin.h" void slapi_mods_add_mod_values( Slapi_Mods *smods, int modtype, const char *type, Slapi_Value **va );
This function takes the following parameters:
Pointer to an initialized Slapi_Mods.
One of LDAP_MOD_ADD, LDAP_MOD_DELETE, LDAP_MOD_REPLACE.
The LDAP attribute type.
A NULL terminated array of Slapi_Value representing the attribute values.
This function appends a new mod to a Slapi_Mods. The mod is constructed from copies of the values of modtype, type and va. Use this function when you have the attribute values to hand as an array of Slapi_Value.
This function must not be used on a Slapi_Mods initialized with slapi_mods_init_byref().
See Also
Appends a new mod to a Slapi_Mods structure, with attribute values provided as an array of berval.
#include "slapi-plugin.h" void slapi_mods_add_modbvps( Slapi_Mods *smods, int modtype, const char *type, struct berval **bvps );
This function takes the following parameters:
Pointer to an initialized Slapi_Mods.
One of LDAP_MOD_ADD, LDAP_MOD_DELETE, LDAP_MOD_REPLACE.
The LDAP attribute type.
A NULL terminated array of berval representing the attribute values.
This function appends a new mod to Slapi_Mods. The mod is constructed from copies of the values of modtype, type and bvps. Use this function when you have the attribute values to hand as an array of berval
This function must not be used on a Slapi_Mods initialized with slapi_mods_init_byref().
Appends a Slapi_Mod to a Slapi_Mods structure.
#include "slapi-plugin.h" void slapi_mods_add_smod(Slapi_Mods *smods, Slapi_Mod *smod);
This function takes the following parameters:
Pointer to an initialized Slapi_Mods.
Pointer to a the Slapi_Mod to be appended.
Appends a Slapi_Mod to a Slapi_Mods.
Responsibility for the Slapi_Mod is transferred to the Slapi_Mods.
This function must not be used on a Slapi_Mods initialized with slapi_mods_init_byref().
Appends a new mod to Slapi_Mods structure with a single attribute value provided as a string.
#include "slapi-plugin.h" void slapi_mods_add_string( Slapi_Mods *smods, int modtype, const char *type, const char *val);
This function takes the following parameters:
Pointer to an initialized Slapi_Mods.
One of LDAP_MOD_ADD, LDAP_MOD_DELETE, LDAP_MOD_REPLACE.
The LDAP attribute type.
The attribute value represented as a NULL terminated string.
This function appends a new mod with a single string attribute value to a Slapi_Mods. The mod is constructed from copies of the values of modtype, type and val.
This function must not be used on a Slapi_Mods initialized with slapi_mods_init_byref().
Frees internals of a Slapi_Mods structure.
#include "slapi-plugin.h" void slapi_mods_done(Slapi_Mods *smods);
This function takes the following parameter:
Pointer to a Slapi_Mods structure.
This function frees the internals of a Slapi_Mods, leaving it in the uninitialized state. Use this function on a stack-allocated Slapi_Mods when you are finished with it, or when you wish to reuse it.
Dumps the contents of a Slapi_Mods structure to the server log.
#include "slapi-plugin.h" void slapi_mods_dump(const Slapi_Mods *smods, const char *text);
This function takes the following parameters:
Pointer to a Slapi_Mods
Descriptive text that will be included in the log, preceding the Slapi_Mods content.
This function uses the LDAP_DEBUG_ANY log level to dump the contents of a Slapi_Mods to $INSTANCE_PATH/logs/errors for debugging.
Frees a Slapi_Mods structure.
#include "slapi-plugin.h" void slapi_mods_free(Slapi_Mods **smods);
This function takes the following parameter:
Pointer to an allocated Slapi_Mods.
This function frees a Slapi_Mods that was allocated by slapi_mods_new().
Initializes a Slapi_Mods iterator and returns the first LDAPMod.
#include "slapi-plugin.h" LDAPMod *slapi_mods_get_first_mod(Slapi_Mods *smods);
This function takes the following parameter:
Pointer to an initialized Slapi_Mods.
This function returns a pointer to the first LDAPMod in the Slapi_Mods, or NULL if there are no mods.
Initializes a Slapi_Mods iterator and returns the first mod wrapped in a Slapi_Mods structure.
#include "slapi-plugin.h" Slapi_Mod *slapi_mods_get_first_smod(Slapi_Mods *smods, Slapi_Mod *smod);
This function takes the following parameters:
A pointer to an initialized Slapi_Mods.
Pointer to a Slapi_Mod that used to hold the mod.
This function returns a pointer to the Slapi_Mod, wrapping the first mod, or NULL if no mod exists.
Use this function in conjunction with slapi_mods_get_next_smod() to iterate through the mods in a Slapi_Mods using a Slapi_Mods wrapper.
Only one thread may be iterating through a particular Slapi_Mods at any given time.
Gets a reference to the array of LDAPMod in a Slapi_Mods structure.
#include "slapi-plugin.h" LDAPMod **slapi_mods_get_ldapmods_byref(Slapi_Mods *smods);
This function takes the following parameter:
Pointer to an initialized Slapi_Mods.
This function returns a NULL terminated array of LDAPMod owned by the Slapi_Mods.
Use this function to get direct access to the array of LDAPMod contained in a Slapi_Mods.
Responsibility for the array remains with the Slapi_Mods .
slapi_mods_get_ldapmods_passout()
Retrieves the array of LDAPMod contained in a Slapi_Mods structure.
#include "slapi-plugin.h" LDAPMod **slapi_mods_get_ldapmods_passout(Slapi_Mods *smods);
This function takes the following parameter:
Pointer to an initialized Slapi_Mods.
A NULL terminated array LDAPMod owned by the caller.
Gets the array of LDAPMod out of a Slapi_Mods. Responsibility for the array transfers to the caller. The Slapi_Mods is left in the uninitialized state.
slapi_mods_get_ldapmods_byref()
Increments the Slapi_Mods iterator and returns the next LDAPMod.
#include "slapi-plugin.h" LDAPMod *slapi_mods_get_next_mod(Slapi_Mods *smods);
This function takes the following parameter:
Pointer to an initialized Slapi_Mods.
This function returns a pointer to the next LDAPMod , or NULL if there are no more.
Use this function in conjunction with slapi_mods_get_first_mod() to iterate through the mods in a Slapi_Mods. This will return an LDAPMod each time until the end.
Only one thread may be iterating through a particular Slapi_Mods at any given time.
Increments the Slapi_Mods iterator and returns the next mod wrapped in a Slapi_Mods.
#include "slapi-plugin.h" Slapi_Mod *slapi_mods_get_next_smod(Slapi_Mods *smods, Slapi_Mod *smod);
This function takes the following parameters:
A pointer to a an initialized Slapi_Mods.
Pointer to a Slapi_Mod that used to hold the mod.
This function returns a pointer to the Slapi_Mod, wrapping the next mod, or NULL if there are no more mods.
Use this function in conjunction with slapi_mods_get_first_smod() to iterate through the mods in a Slapi_Mods using a Slapi_Mods wrapper.
Only one thread may be iterating through a particular Slapi_Mods at any given time.
Gets the number of mods in a Slapi_Mods structure.
#include "slapi-plugin.h" int slapi_mods_get_num_mods(const Slapi_Mods *smods);
This function takes the following parameter:
Pointer to an initialized Slapi_Mods.
The number of mods in the Slapi_Mods .
Initializes a Slapi_Mods.
#include "slapi-plugin.h" void slapi_mods_init(Slapi_Mods *smods, int initCount);
This function takes the following parameters:
Pointer to an initialized Slapi_Mods.
Number of modifications to allocate initially.
Initializes a Slapi_Mods so that it is empty, but initially has room for the given number of mods.
If you are unsure of how much room you will need, you may use an initCount of 0. The Slapi_Mods expands as necessary.
Initializes a Slapi_Mods that is a wrapper for an existing array of LDAPMod.
#include "slapi-plugin.h" void slapi_mods_init_byref(Slapi_Mods *smods, LDAPMod **mods);
This function takes the following parameters:
Pointer to an uninitialized Slapi_Mods.
A NULL terminated array of LDAPMod.
Initializes a Slapi_Mods containing a reference to an array of LDAPMod. This function provides the convenience of using Slapi_Mods functions to access LDAPMod array items.
The array is not destroyed when the Slapi_Mods is destroyed. Notice that you cannot insert new mods in a Slapi_Mods that has been initialized by reference.
Initializes a Slapi_Mods structure from an array of LDAPMod.
#include "slapi-plugin.h" void slapi_mods_init_passin(Slapi_Mods *smods, LDAPMod **mods);
This function takes the following parameters:
Pointer to an uninitialized Slapi_Mods.
A NULL terminated array of LDAPMod.
This function initializes a Slapi_Mods by passing in an array of LDAPMod. This function converts an array of LDAPMod to a Slapi_Mods .
The responsibility for the array and its elements is transferred to the Slapi_Mods. The array and its elements are destroyed when the Slapi_Mods is destroyed.
Inserts an LDAPMod into a Slapi_Mods structure after the current iterator position.
#include "slapi-plugin.h" void slapi_mods_insert_after(Slapi_Mods *smods, LDAPMod *mod);
This function takes the following parameters:
Pointer to an initialized Slapi_Mods with a valid iterator position.
Pointer to the LDAPMod to be inserted.
This function inserts an LDAPMod in a Slapi_Mods immediately after the current position of the Slapi_Mods iterator. The iterator position is unchanged.
Responsibility for the LDAPMod is transferred to the Slapi_Mods.
This function must not be used on a Slapi_Mods initialized with slapi_mods_init_byref().
Inserts an LDAPMod anywhere in a Slapi_Mods.
#include "slapi-plugin.h" void slapi_mods_insert_at(Slapi_Mods *smods, LDAPMod *mod, int pos);
This function takes the following parameters:
Pointer to an initialized Slapi_Mods.
Pointer to the LDAPMod to be inserted.
Position at which to insert the new mod. Minimum value is 0. Maximum value is the current number of mods .
This function inserts an LDAPMod at a given position in Slapi_Mods. Position 0 (zero) refers to the first mod. A position equal to the current number of mods causes an append. mods at and above the specified position are moved up by one, and the given position refers to the newly inserted mod.
Responsibility for the LDAPMod is transferred to the Slapi_Mods.
This function must not be used on a Slapi_Mods initialized with slapi_mods_init_byref().
Inserts an LDAPMod into a Slapi_Mods structure before the current iterator position.
#include "slapi-plugin.h" void slapi_mods_insert_before(Slapi_Mods *smods, LDAPMod *mod);
This function takes the following parameters:
Pointer to an initialized Slapi_Mods with a valid iterator position.
Pointer to the LDAPMod to be inserted.
Inserts an LDAPMod into a Slapi_Mods immediately before the current position of the Slapi_Mods iterator. The iterator position is unchanged.
The responsibility for the LDAPMod is transferred to the Slapi_Mods.
This function must not be used on a Slapi_Mods initialized with slapi_mods_init_byref().
Inserts a Slapi_Mod anywhere in a Slapi_Mods.
#include "slapi-plugin.h" void slapi_mods_insert_smod_at(Slapi_Mods *smods, Slapi_Mod *smod, int pos);
This function takes the following parameters:
Pointer to an initialized Slapi_Mods.
Pointer to the Slapi_Mod to be inserted.
Position at which to insert the Slapi_Mod . Minimum value is 0. Maximum value is the current number of mods.
This function inserts a Slapi_Mod at a given position in Slapi_Mods. Position 0 (zero) refers to the first mod. A position equal to the current number of mods causes an append. mods at and above the specified position are moved up by one, and the given position refers to the newly inserted mod.
Responsibility for the Slapi_Mod is transferred to the Slapi_Mods.
This function must not be used on a Slapi_Mods initialized with slapi_mods_init_byref().
Inserts a Slapi_Mod into a Slapi_Mods structure before the current iterator position.
#include "slapi-plugin.h" void slapi_mods_insert_smod_before(Slapi_Mods *smods, Slapi_Mod *smod);
This function takes the following parameters:
Pointer to an initialized Slapi_Mods with a valid iterator position.
Pointer to the Slapi_Mod to be inserted.
Inserts a Slapi_Mod into a Slapi_Mods immediately before the current position of the Slapi_Mods iterator. The iterator position is unchanged.
The responsibility for the Slapi_Mod is transferred to the Slapi_Mods.
This function must not be used on a Slapi_Mods initialized with slapi_mods_init_byref().
Decrements the Slapi_Mods current iterator position.
#include "slapi-plugin.h" void slapi_mods_iterator_backone(Slapi_Mods *smods);
This function takes the following parameter:
Pointer to an initialized Slapi_Mods.
This function moves the iterator back one position.
Allocates a new uninitialized Slapi_Mods structure.
#include "slapi-plugin.h" Slapi_Mods* slapi_mods_new( void );
This function takes no parameters.
A pointer to an allocated uninitialized Slapi_Mods.
This function allocates a new initialized Slapi_Mods .
Use this function when you need a Slapi_Mods allocated from the heap, rather than from the stack.
Removes the mod at the current Slapi_Mods iterator position.
#include "slapi-plugin.h" void slapi_mods_remove(Slapi_Mods *smods);
This function takes the following parameter:
Pointer to an initialized Slapi_Mods.
This function removes the mod at the current iterator position.
Removes the mod at the specified Slapi_Mods iterator position.
#include "slapi-plugin.h" void slapi_mods_remove_at(Slapi_Mods *smods, int pos);
This function takes the following parameters:
Pointer to an initialized Slapi_Mods.
Position of the mod to remove.
This function removes the mod at the pos iterator position, obtained by counting as you iterate through the modifications in a Slapi_Mods.
Call a matching rule filter index function.
#include "slapi-plugin.h" int slapi_mr_filter_index(Slapi_Filter* f, Slapi_PBlock* pb);
This function takes the following parameters:
Filter containing the matching rule OID
Parameter block to pass to the filter index function
This function enables plug-ins to call matching rule filter index functions.
This function returns 0 if successful. It returns LDAP_UNAVAILABLE_CRITICAL_EXTENSION if no filter index function is available for the rule in the filter. It returns -1 if something goes horribly wrong setting the parameter block arguments.
Set a pointer in the parameter block to the indexer factory function for a matching rule.
#include "slapi-plugin.h" int slapi_mr_indexer_create(Slapi_PBlock * pb);
This function takes the following parameters:
Parameter block containing the matching rule object identifier affected to SLAPI_PLUGIN_MR_OID
This function enables plug-ins to call matching rule indexer factory functions. If successful, the function sets SLAPI_PLUGIN_MR_INDEXER_CREATE_FN in pb to point to the indexer factory function.
This function returns 0 if successful. It returns LDAP_UNAVAILABLE_CRITICAL_EXTENSION if no indexer factory function is available for the matching rule. It returns -1 if something goes horribly wrong getting or setting the parameter block arguments.
Allocate a condition variable.
#include "slapi-plugin.h" Slapi_CondVar *slapi_new_condvar( Slapi_Mutex *mutex );
This function takes the following parameter:
Mutex used for the lock
This function enables thread synchronization using a wait/notify mechanism.
This function returns a pointer to the new condition variable if successful. Otherwise, it returns NULL.
Call this function to create the condition variable and slapi_destroy_condvar() to free the condition variable.
Allocate a mutex.
#include "slapi-plugin.h" Slapi_Mutex *slapi_new_mutex( void );
This function returns a pointer to the new mutex if successful. Otherwise, it returns NULL.
This function enables thread synchronization. Once a thread has locked the mutex using slapi_lock_mutex(), other threads attempting to acquire the lock are blocked until the thread holding the mutex calls slapi_UTF-8STRTOLOWER().
Call slapi_destroy_mutex() to free the mutex.
Notify a change in a condition variable.
#include "slapi-plugin.h" int slapi_notify_condvar( Slapi_CondVar *cvar, int notify_all );
This function takes the following parameter:
Condition variable changed
NULL means notify only the next thread waiting for notification. Otherwise, all threads are notified.
This function enables thread synchronization using a wait/notify mechanism.
This function returns 1 if successful. Otherwise, it returns NULL.
Call slapi_wait_condvar() to wait on a change to the condition variable.
Determines whether or not the client has abandoned the current operation (the operation that passes in the parameter block).
#include "slapi-plugin.h" int slapi_op_abandoned( Slapi_PBlock *pb );
This function takes the following parameter:
Parameter block passed in from the current operation.
This function allows you to verify if the operation associated to the PBlock in the parameter has been abandoned. This function is useful to periodically check the operations status from long-running plug-ins.
This function returns one of the following values:
1 if the operation has been abandoned.
0 if the operation has not been abandoned.
Gets the type of a Slapi_Operation.
#include "slapi-plugin.h" unsigned long slapi_op_get_type(Slapi_Operation * op);
This function takes the following parameter:
The operation of which you wish to get the type.
This function returns the type of an operation. The Slapi_Operation structure can be extracted from a pblock structure using slapi_pblock_get() with the Slapi_Operation parameter. For example:
slapi_pblock_get (pb, SLAPI_OPERATION, &op);
This function will return one of the following operation types:
SLAPI_OPERATION_BIND
SLAPI_OPERATION_UNBIND
SLAPI_OPERATION_SEARCH
SLAPI_OPERATION_MODIFY
SLAPI_OPERATION_ADD
SLAPI_OPERATION_DELETE
SLAPI_OPERATION_MODDN
SLAPI_OPERATION_MODRDN
SLAPI_OPERATION_COMPARE
SLAPI_OPERATION_ABANDON
SLAPI_OPERATION_EXTENDED
Frees the specified parameter block from memory.
#include "slapi-plugin.h" void slapi_pblock_destroy( Slapi_PBlock *pb );
This function takes the following parameters:
Parameter block that you wish to free.
The parameter block that you wish to free must have been created using slapi_pblock_new(). Use of this function with parameter blocks allocated on the stack, with Slapi_PBlock pb;, or using another memory allocator, is not supported and may lead to memory errors and memory leaks. For example:
Slapi_PBlock *pb = malloc(sizeof(Slapi_PBlock));
After calling this function, you should set the parameter block pointer to NULL to avoid reusing freed memory in your function context, as in the following:
slapi_pblock_destroy(pb); pb = NULL;
If you reuse the pointer in this way, it makes it easier to identify a Segmentation Fault, rather than using some difficult method to detect memory leaks or other abnormal behavior.
It is safe to call this function with a NULL pointer. For example:
Slapi_PBlock *pb = NULL; slapi_pblock_destroy(pb);
This saves the trouble of checking for NULL before calling slapi_pblock_destroy().
Gets the value of a name-value pair from a parameter block.
#include "slapi-plugin.h" int slapi_pblock_get( Slapi_PBlock *pb, int arg, void *value );
This function takes the following parameters:
Parameter block.
ID of the name-value pair that you want to get. For a list of IDs that you can specify, see Chapter 15, Data Type and Structure Reference
Pointer to the value retrieved from the parameter block.
This function returns one of the following values:
0 if successful.
-1 if an error occurs (for example, if an invalid ID is specified).
The void *value argument should always be a pointer to the type of value you are retrieving:
int connid = 0; ... retval = slapi_pblock_get(pb, SLAPI_CONN_ID, &connid);
SLAPI_CONN_ID is an integer value, so you will pass in a pointer to/address of an integer to get the value. Similarly, for a char * value (a string), pass in a pointer to/address of the value. For example:
char *binddn = NULL; ... retval = slapi_pblock_get(pb, SLAPI_CONN_DN, &binddn);
With certain compilers on some platforms, you may have to cast the value to (void *).
We recommend that you set the value to 0 or NULL before calling slapi_pblock_get() to avoid reading from uninitialized memory, in case the call to slapi_pblock_get() fails.
In most instances, the caller should not free the returned value. The value will usually be freed internally or through the call to slapi_pblock_destroy() . The exception is if the value is explicitly set by the caller through slapi_pblock_set(). In this case, the caller is responsible for memory management. If the value is freed, it is strongly recommended that the free is followed by a call to slapi_pblock_set() with a value of NULL. For example:
char *someparam = NULL; ... someparam = slapi_ch_strdup(somestring); slapi_pblock_set(pb, SOME_PARAM, someparam); someparam = NULL; /* avoid dangling reference */ ... slapi_pblock_get(pb, SOME_PARAM, &someparam); slapi_pblock_set(pb, SOME_PARAM, NULL); /* Make sure no one else references this. */ slapi_ch_free_string(&someparam); ...
Some internal functions may change the value passed in, so it is recommended to use slapi_pblock_get() to retrieve the value again, rather than relying on a potential dangling pointer. This is shown in the previous example, which sets someparam to NULL after setting it in the parameter block.
Creates a new parameter block.
#include "slapi-plugin.h" Slapi_PBlock *slapi_pblock_new();
Pointer to the new parameter block.
The parameter block pointer allocated with slapi_pblock_new() must always be freed by slapi_pblock_destroy(). The use of other memory liberators such as free() is not supported and may lead to crashes or memory leaks.
Sets the value of a name-value pair in a parameter block.
#include "slapi-plugin.h" int slapi_pblock_set( Slapi_PBlock *pb, int arg, void *value );
This function takes the following parameters:
Parameter block.
ID of the name-value pair that you want to set. For a list of IDs that you can specify, see Chapter 15, Data Type and Structure Reference
Pointer to the value that you want to set in the parameter block.
This function returns 0 if successful, or -1 if an error occurs (for example, if an invalid ID is specified).
The value to be passed in must always be a pointer, even for integer arguments. For example, if you wanted to do a search with the ManageDSAIT control:
int managedsait = 1; ... slapi_pblock_set(pb, SLAPI_MANAGEDSAIT, &managedsait);
A call similar to the following example will cause a crash:
slapi_pblock_set(pb, SLAPI_MANAGEDSAIT, 1);
However, for values which are already pointers such as char * strings , char **arrays,Slapi_Backend *, and so forth, you can pass in the value directly. For example:
char *target_dn = slapi_ch_strdup(some_dn); slapi_pblock_set(pb, SLAPI_TARGET_DN, target_dn);
or
slapi_pblock_set(pb, SLAPI_TARGET_DN, NULL);
With some compilers, you will have to cast the value argument to (void *).
If the caller allocates the memory passed in, the caller is responsible for freeing that memory. Also, it is recommended to use slapi_pblock_get() to retrieve the value to free rather than relying on a potentially dangling pointer. See the slapi_pblock_get() example for more details.
When setting parameters to register a plug-in, the plug-in type must always be set first, since many of the plug-in parameters depend on the type. For example, set the SLAPI_PLUGIN_TYPE to extended operation before setting the list of extended operation OIDs for the plug-in.
Determines whether a specified password matches one of the hashed values of an attribute. For example, you can call this function to determine if a given password matches a value in the userpassword attribute.
#include "slapi-plugin.h" int slapi_pw_find_sv( Slapi_Value **vals, const Slapi_Value *v );
This function takes the following parameters:
Pointer to the array of Slapi_Value structure pointers to hold the values of an attribute that stores passwords such as userpassword.
Pointer to the Slapi_Value structure containing the password that you wish to check.
For example, you can get this value from the SLAPI_BIND_CREDENTIALS parameter in the parameter block and create the Slapi_Value using slapi_value_init_berval().
This function returns 0 if the password specified by v was found in vals, or a non-zero value if the password v was not found in vals.
You must allocate and release an array of Slapi_Value structures for vals sized to hold the exact number of password values for the userpassword attribute on the entry to check. The resulting array is not NULL terminated. For a simpler memory allocation model, use slapi_pw_find_valueset() instead.
When the server stores the password for an entry in the userpassword attribute, it hashes the password using different schemes.
Use this function to determine if a given password is one of the values of the userpassword attribute. This function determines which password scheme was used to store the password and uses the appropriate comparison function to compare a given value against the hashed values of the userpassword attribute.
Determines whether or not a specified password matches one of the hashed values of an attribute. For example, you can call this function to determine if a given password matches a value in the userpassword attribute.
#include "slapi-plugin.h" int slapi_pw_find_valueset(Slapi_Valueset *valset, const Slapi_Value *v);
This function takes the following parameters:
Pointer to the Slapi_ValueSet structure containing the values of an attribute that stores passwords such as userpassword .
Pointer to the Slapi_Value structure containing the password to check.
For example, you can get this value from the SLAPI_BIND_CREDENTIALS parameter in the parameter block and create the Slapi_Value using slapi_value_init_berval().
This function returns 0 if the password specified by v was found in valset, or a non-zero value if the password v was not found in valset.
When the server stores the password for an entry in the userpassword attribute, it hashes the password using different schemes.
Use this function to determine if a given password is one of the values of the userpassword attribute. This function determines which password scheme was used to store the password and uses the appropriate comparison function to compare a given value against the hashed values of the userpassword attribute.
Adds a new RDN to an existing Slapi_RDN structure.
#include "slapi-plugin.h" int slapi_rdn_add(Slapi_RDN *rdn, const char *type, const char *value);
This function takes the following parameters:
The target Slapi_RDN structure.
The type (cn, o, ou , etc.) of the RDN to be added. This parameter cannot be NULL.
The value of the RDN to be added. This parameter cannot be NULL.
This function always returns 1.
This function adds a new type/value pair to an existing RDN, or sets the type/value pair as the new RDN if rdn is empty. This function resets the FLAG_RDNS flags, which means that the RDN array within the Slapi_RDN structure is no longer current with the new RDN.
slapi_rdn_get_num_components()
Compares two RDNs.
#include "slapi-plugin.h" int slapi_rdn_compare(Slapi_RDN *rdn1, Slapi_RDN *rdn2);
This function takes the following parameters:
The first RDN to compare.
The second RDN to compare.
This function returns 0 if rdn1 and rdn2 have the same RDN components, or -1 if they do not.
This function compares rdn1 and rdn2. For rdn1 and rdn2 to be considered equal RDNs, their components do not necessarily have to be in the same order.
Checks whether a Slapi_RDN structure holds any RDN matching a given type/value pair.
#include "slapi-plugin.h" int slapi_rdn_contains(Slapi_RDN *rdn, const char *type, const char *value,size_t length);
This function takes the following parameters:
The Slapi_RDN structure containing the RDN value(s).
The type (cn, o, ou , etc.) of the RDN searched.
The value of the RDN searched.
Gives the length of value that should be taken into account for the string operation when searching for the RDN.
This function returns 1 if rdn contains an RDN that matches the type, value and length, or 0 if no RDN matches the desired type/value.
This function searches for an RDN inside of the Slapi_RDN structure rdn that matches both type and value as given in the parameters. This function makes a call to slapi_rdn_get_index() and verifies that the returned value is anything but -1.
Checks whether a Slapi_RDN structure contains any RDN matching a given type, and if true, gets the corresponding attribute value.
#include "slapi-plugin.h" int slapi_rdn_contains_attr(Slapi_RDN *rdn, const char *type, char **value);
This function takes the following parameters:
The Slapi_RDN structure containing the RDN value(s).
Type (cn, o, ou, etc.) of the RDN searched.
Repository that will hold the value of the first RDN whose type matches the content of the parameter type. If this parameter is NULL at the return of the function, no RDN with the desired type exists within rdn.
This function returns 1 if rdn contains a RDN that matches the given type, or 0 if there is no match.
This function looks for an RDN inside the Slapi_RDN structure rdn that matches the type given in the parameters. This function makes a call to slapi_rdn_get_index_attr() and verifies that the returned value is anything but -1. If successful, it also returns the corresponding attribute value.
Clears an instance of a Slapi_RDN structure.
#include "slapi-plugin.h" void slapi_rdn_done(Slapi_RDN *rdn);
This function takes the following parameter:
Pointer to the structure to be cleared.
This function clears the contents of a Slapi_RDN structure. It frees both the RDN value and the array of split RDNs. Those pointers are then set to NULL.
Frees a Slapi_RDN structure.
#include "slapi-plugin.h" void slapi_rdn_free(Slapi_RDN **rdn);
This function takes the following parameter:
Pointer to the pointer of the Slapi_RDN structure to be freed.
This function frees both the contents of the Slapi_RDN structure and the structure itself pointed to by the content of rdn.
Gets the type/value pair corresponding to the first RDN stored in a Slapi_RDN structure.
#include "slapi-plugin.h" int slapi_rdn_get_first(Slapi_RDN *rdn, char **type, char **value);
This function takes the following parameters:
The Slapi_RDN structure containing the RDN value(s).
Repository that will hold the type of the first RDN. If this parameter is NULL at the return of the function, it means rdn is empty.
Repository that will hold the type of the first RDN. If this parameter is NULL at the return of the function, it means rdn is empty.
This function returns -1 if rdn is empty, or 1 if the operation is successful.
This function gets the type/value pair corresponding to the first RDN stored in rdn. For example, if the RDN is cn=Joey, the function will place cn in the type return parameter, and Joey in value.
Gets the index of the RDN that follows the RDN with a given type and value.
#include "slapi-plugin.h" int slapi_rdn_get_index(Slapi_RDN *rdn, const char *type, const char *value, size_t length);
This function takes the following parameters:
The Slapi_RDN structure containing the RDN value(s).
Type (cn, o, ou, etc.) of the RDN that is searched.
Value of the RDN searched.
Gives the length of value that should be taken into account for the string comparisons when searching for the RDN. A matching RDN value must not exceed the length specified.
This function returns the index of the RDN that follows the RDN matching the contents of the parameters type and value. If no RDN stored in rdn matches the given type/value pair, -1 is returned.
This function searches for an RDN inside the Slapi_RDN structure rdn that matches both type and value as given in the parameters. If it succeeds, the position of the matching RDN is returned.
Gets the position and the attribute value of the first RDN in a Slapi_RDN structure that matches a given type.
#include "slapi-plugin.h" int slapi_rdn_get_index_attr(Slapi_RDN *rdn, const char *type, char **value);
This function takes the following parameters:
The Slapi_RDN structure containing the RDN value(s).
Type (cn, o, ou, etc.) of the RDN searched.
Repository that will hold the value of the first RDN whose type matches the content of the parameter type. If this parameter is NULL at the return of the function, no RDN exists within rdn.
This function returns -1 if there is no RDN that matches the content type, or the real position of the first RDN within RDN that matches the content of type.
This function searches for an RDN inside of the Slapi_RDN structure rdn that matches the type given in the parameters. If successful, the position of the matching RDN, as well as the corresponding attribute value, is returned.
Gets a certain RDN type/value pair from within the RDNs stored in a Slapi_RDN structure.
#include "slapi-plugin.h" int slapi_rdn_get_next(Slapi_RDN *rdn, int index, char **type, char **value);
This function takes the following parameters:
The Slapi_RDN structure containing the RDN value(s).
Indicates the position of the RDN that precedes the currently desired RDN.
Repository that will hold the type (cn, o, ou, etc.) of the next (index+1) RDN. If this parameter is NULL at the return of the function, the RDN does not exist.
Repository that will hold the value of the next (index+1) RDN. If this parameter is NULL, the RDN does not exist.
This function returns -1 if there is no RDN in the index position, or the real position of the retrieved RDN if the operation was successful.
This function gets the type/value pair corresponding to the RDN stored in the next (index+1) position inside rdn. Notice that the index of an element within an array of values is always one unit below its real position in the array.
Gets the number of RDN type/value pairs present in a Slapi_RDN structure.
#include "slapi-plugin.h" int slapi_rdn_get_num_components(Slapi_RDN *rdn);
This function takes the following parameter:
The target Slapi_RDN structure.
This function returns the number of RDN type/value pairs present in rdn.
Gets the RDN from a Slapi_RDN structure.
#include "slapi-plugin.h" const char *slapi_rdn_get_rdn(const Slapi_RDN *rdn);
This function takes the following parameter:
The Slapi_RDN structure holding the RDN value.
This function returns the RDN value.
Initializes a Slapi_RDN structure with NULL values.
#include "slapi-plugin.h" void slapi_rdn_init(Slapi_RDN *rdn);
This function takes the following parameter:
The Slapi_RDN structure to be initialized.
This function initializes a given Slapi_RDN structure with NULL values (both the RDN value and the array of split RDNs are set to NULL).
Initializes a Slapi_RDN structure with an RDN value taken from a given DN.
#include "slapi-plugin.h" void slapi_rdn_init_dn(Slapi_RDN *rdn,const char *dn);
This function takes the following parameters:
The Slapi_RDN structure to be initialized.
The DN value whose RDN will be used to initialize the new Slapi_RDN structure.
This function initializes a given Slapi_RDN structure with the RDN value taken from the DN passed in the dn parameter.
Initializes a Slapi_RDN structure with an RDN value.
#include "slapi-plugin.h" void slapi_rdn_init_rdn(Slapi_RDN *rdn,const Slapi_RDN *fromrdn);
This function takes the following parameters:
The Slapi_RDN structure to be initialized.
The RDN value to be set in the new Slapi_RDN structure.
This function initializes a given Slapi_RDN structure with the RDN value in fromrdn.
Initializes a Slapi_RDN structure with an RDN value taken from the DN contained in a given Slapi_DN structure.
#include "slapi-plugin.h" void slapi_rdn_init_sdn(Slapi_RDN *rdn,const Slapi_DN *sdn);
This function takes the following parameters:
The Slapi_RDN structure to be initialized.
The Slapi_DN structure containing the DN value whose RDN will be used to initialize the new Slapi_RDN structure.
This function initializes a given Slapi_RDN structure with the RDN value taken from the DN passed within the Slapi_DN structure of the sdn parameter.
Checks whether an RDN value is stored in a Slapi_RDN structure.
#include "slapi-plugin.h" int slapi_rdn_isempty(const Slapi_RDN *rdn);
This function takes the following parameter:
The target Slapi_RDN structure.
This function returns 1 if there is no RDN value present, or 0 if rdn contains a value.
Allocates a new Slapi_RDN structure and initializes the values to NULL.
#include "slapi-plugin.h" Slapi_RDN * slapi_rdn_new();
This function takes no parameters.
This function returns a pointer to the newly allocated, and still empty,Slapi_RDN structure.
This function creates a new Slapi_RDN structure by allocating the necessary memory and initializing both the RDN value and the array of split RDNs to NULL.
Creates a new Slapi_RDN structure and sets an RDN value taken from a given DN.
#include "slapi-plugin.h" Slapi_RDN *slapi_rdn_new_dn(const char *dn);
This function takes the following parameter:
The DN value whose RDN will be used to initialize the new Slapi_RDN structure.
This function returns a pointer to the new Slapi_RDN structure initialized with the TDN taken from the DN value in dn .
This function creates a new Slapi_RDN structure and initializes its RDN with the value taken from the DN passed in the dn parameter.
The memory is allocated by the function itself.
Creates a new Slapi_RDN structure and sets an RDN value.
#include "slapi-plugin.h" Slapi_RDN * slapi_rdn_new_rdn(const Slapi_RDN *fromrdn);
This function takes the following parameters:
The RDN value to be set in the new Slapi_RDN structure.
This function returns a pointer to the new Slapi_RDN structure with an RDN set to the content of fromrdn.
This function creates a new Slapi_RDN structure and initializes its RDN with the value of fromrdn.
The memory is allocated by the function itself.
Creates a new Slapi_RDN structure and sets an RDN value taken from the DN contained in a given Slapi_RDN structure.
#include "slapi-plugin.h" vSlapi_RDN *slapi_rdn_new_sdn(const Slapi_DN *sdn);
This function takes the following parameter:
Slapi_RDN structure containing the DN value whose RDN will be used to initialize the new Slapi_RDN structure.
This function returns a pointer to the new Slapi_RDN structure initialized with the RDN taken from the DN value in dn .
This function creates a new Slapi_RDN structure and initializes its RDN with the value taken from the DN passed within the Slapi_RDN structure of the sdn parameter.
The memory is allocated by the function itself.
Removes an RDN type/value pair from a Slapi_RDN structure.
#include "slapi-plugin.h" int slapi_rdn_remove(Slapi_RDN *rdn, const char *type, const char *value, size_t length);
This function takes the following parameters:
The target Slapi_RDN structure.
Type (cn, o, ou, etc.) of the RDN searched.
The value of the RDN searched.
Gives the length of value that should be taken into account for the string comparisons when searching for the RDN.
This function returns 1 if the RND is removed from rdn, or 0 if no RDN is removed.
This function removes the RDN from rdn that matches the given criteria (type, value and length).
Removes an RDN type/value pair from a Slapi_RDN structure.
#include "slapi-plugin.h" int slapi_rdn_remove_attr(Slapi_RDN *rdn, const char *type);
This function takes the following parameters:
The target Slapi_RDN structure.
Type (cn, o, ou, etc.) of the RDN searched.
This function returns 1 of the RDN is removed from rdn, or 0 if no RDN is removed.
This function removes the first RDN from rdn that matches the given type.
Removes an RDN type/value pair from a Slapi_RDN structure.
#include "slapi-plugin.h" int slapi_rdn_remove_index(Slapi_RDN *rdn, int atindex);
This function takes the following parameters:
The target Slapi_RDN structure.
The index of the RDN type/value pair to remove.
This function returns 1 if the RDN is removed from rdn, or 0 if no RDN is removed because either rdn is empty, or the index goes beyond the number of RDNs present.
This function removes the RDN from rdn with atindex index (placed in the atindex+1 position).
Sets an RDN value in a Slapi_RDN structure.
#include "slapi-plugin.h" void slapi_rdn_set_dn(Slapi_RDN *rdn,const char *dn);
This function takes the following parameters:
The target Slapi_RDN structure.
The DN value whose RDN will be set in rdn.
This function sets an RDN value in a Slapi_RDN structure. The structure is freed from memory and freed of any previous content before setting the new RDN. The new RDN is taken from the DN value present in the dn parameter.
Sets an RDN in a Slapi_RDN structure.
#include "slapi-plugin.h" void slapi_rdn_set_rdn(Slapi_RDN *rdn,const Slapi_RDN *fromrdn);
This function takes the following parameters:
This function sets an RDN value in a Slapi_RDN structure. The structure is freed from memory and freed of any previous content before setting the new RDN.
Sets an RDN value in a Slapi_RDN structure.
#include "slapi-plugin.h" void slapi_rdn_set_sdn(Slapi_RDN *rdn,const Slapi_DN *sdn);
This function takes the following parameters:
This function sets an RDN value in a Slapi_RDN structure. The structure is freed from memory and freed of any previous content before setting the new RDN. The new RDN is taken from the DN value present inside of a Slapi_DN structure.
This function determines whether the value of the RDN complies with attribute syntax rules.
#include "slapi-plugin.h" int slapi_rdn_syntax_check( Slapi_PBlock *pb, const char *rdn );
This function takes the following parameters:
Parameter block.
Value whose compliance is to be checked.
Returns one of the following values:
0 if rdn complies or if syntax checking is turned off.
1 if rdn does not comply with attribute syntax rules.
The pb argument can be NULL. It is used only to get the SLAPI_IS_REPLICATED_OPERATION flag. If that flag is present, no syntax checking is done.
Register an object extension.
#include "slapi-plugin.h" int slapi_register_object_extension( const char *pluginname, const char *objectname, slapi_extension_constructor_fnptr constructor, slapi_extension_destructor_fnptr destructor, int *objecttype, int *extensionhandle);
This function takes the following parameters:
String identifying the plug-in
Name of the object to extend such as SLAPI_EXT_CONNECTION to add private data to a connection or SLAPI_EXT_OPERATION to add private data to an operation
Constructor to allocate memory for the object extension and create the extension
Destructor to free memory used for the object extension
Set by the server and used to retrieve the extension
Set by the server and used to retrieve the extension
This function registers an extension to an object such as a connection or an operation. This mechanism enables a plug-in to store private data with an operation that is passed from a preoperation to a postoperation plug-in for example, something not possible using parameter blocks.
Register object extensions as part of the plug-in initialization function.
This function returns 0 if successful. Otherwise, it returns -1.
slapi_extension_constructor_fnptr
slapi_extension_destructor_fnptr
Register another plug-in.
#include "slapi-plugin.h" int slapi_register_plugin( const char *plugintype, int enabled, const char *initsymbol, slapi_plugin_init_fnptr initfunc, const char *name, char **argv, void *group_identity);
This function takes the following parameters:
String identifying the plug-in type as described under Plug-In Registration
1 to enable the plug-in on registration, 0 otherwise
String representation of the plug-in initialization function initfunc such as "my_init_fcn"
Pointer to the plug-in initialization function
Common Name for the plug-in
Arguments passed to the plug-in
Plug-in group identifier, typically obtained from SLAPI_PLUGIN_IDENTITY for the plug-in calling this function
This function registers another plug-in. Register plug-ins as part of the plug-in initialization function.
This function returns 0 if successful. Otherwise, it returns -1.
Register a callback to determine the scope of a role.
#include "slapi-plugin.h" void slapi_register_role_get_scope( roles_get_scope_fn_type get_scope_fn);
This function takes the following parameters:
Callback to determine the scope of a role
This function registers the callback that evaluates the scope of a role. Register the callback as part of the plug-in initialization function.
Registers the specified control with the server. This function associates the control with an object identification (OID). When the server receives a request that specifies this OID, the server makes use of this information to determine if the control is supported by the server or its plug-ins.
#include "slapi-plugin.h" void slapi_register_supported_control( char const *controloid, unsigned long controlops );
This function takes the following parameters:
OID of the control you want to register.
Operation that the control is applicable to.
The controlops argument can have one or more of the following values:
You can specify a combination of values by bitwise ORing the values together (for example, SLAPI_OPERATION_ADD | SLAPI_OPERATION_DELETE).
Registers the specified Simple Authentication and Security Layer (SASL) mechanism with the server.
#include "slapi-plugin.h" void slapi_register_supported_saslmechanism( char *mechanism );
This function takes the following parameter:
String identifying the SASL mechanism to both the server and to clients requesting the mechanism during a SASL bind
Use this function in the plug-in initialization function to register the name of a SASL mechanism supported by the plug-in. The preoperation function handling the SASL bind can then check the SASL bind mechanism name provided by the client to determine whether to attempt to handle the bind.
The sample $INSTALL_DIR/plugins/slapd/slapi/examples/testsaslbind.c plug-in demonstrates the use of this function.
Prepares a parameter block for an internal modify RDN operation.
#include "slapi-plugin.h" int 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:
Parameter block for the internal modify RDN operation
Distinguished Name of the entry to rename
New Relative Distinguished name to apply
DN of parent after renaming
1 to delete the old RDN, 0 to retain the old RDN
Array of controls to request for the modify RDN operation
Unique identifier for the entry if using this rather than DN
Plug-in identifier obtained from SLAPI_PLUGIN_IDENTITY during plug-in initialization
NULL or SLAPI_OP_FLAG_NEVER_CHAIN
This function returns 0 if successful. Otherwise, it returns an LDAP error code.
This function prepares a parameter block for use with slapi_modrdn_internal_pb().
Allocate the parameter block using slapi_pblock_new() before calling this function.
Directory Server does not free the parameters you passed to this function.
Free the parameter block after calling slapi_modrdn_internal_pb() .
Checks if the entry pointed to by entry_to_check contains the role indicated by role_dn.
#include "slapi-plugin.h" int slapi_role_check(Slapi_Entry *entry_to_check, Slapi_DN *role_dn,int *present);
This function takes the following parameters:
The entry in which the presence of a role is to be checked.
The DN of the role for which to check.
Pointer to an integer where the result is placed. For results:
non 0 means present
0 means not present
This function returns one of the following values:
0 for success if role_dn is present in entry_to_check and present is set to non-zero. Otherwise it is 0.
non-zero (error condition) if the presence of the role is undetermined.
Determine the scope of a role.
#include "slapi-plugin.h" int slapi_role_get_scope(Slapi_Entry *role_entry, Slapi_DN ***scope_dn, int *nb_scope);
This function takes the following parameters:
Entry defining the role
Set by the callback to the Distinguished Name of the entry at the base of the scope
Set by the callback to a value such as LDAP_SCOPE_BASE, LDAP_SCOPE_ONELEVEL, or LDAP_SCOPE_SUBTREE
This function triggers a callback to evaluate the scope of a role.
Directory Server does not free or copy the parameters passed to this function.
slapi_register_role_get_scope()
Adds the RDN contained in a Slapi_RDN structure to the DN contained in a Slapi_DN structure.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_add_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn);
This function takes the following parameters:
Slapi_DN structure containing the value to which a new RDN is to be added.
Slapi_RDN structure containing the RDN value that is to be added to the DN value.
This function returns the Slapi_DN structure with the new DN formed by adding the RDN value in rdn to the DN value in dn.
Compares two DNs.
#include "slapi-plugin.h" int slapi_sdn_compare( const Slapi_DN *sdn1, const Slapi_DN *sdn2 );
This function takes the following parameters:
DN to compare with the value in sdn2.
DN to compare with the value in sdn1.
This function returns one of the following values:
0 if sdn1 is equal to sdn2.
-1 if sdn1 is NULL.
1 if sdn2 is NULL and sdn1 is not NULL.
This function compares two DNs, sdn1 and sdn2. The comparison is case sensitive.
Makes a copy of a DN.
#include "slapi-plugin.h" void slapi_sdn_copy(const Slapi_DN *from, Slapi_DN *to);
This function takes the following parameters:
The original DN.
Destination of the copied DN, containing the copy of the DN in from.
This function copies the DN in from to the structure pointed by to.
to must be allocated in advance of calling this function.
Clears an instance of a Slapi_DN structure.
#include "slapi-plugin.h" void slapi_sdn_done(Slapi_DN *sdn);
This function takes the following parameter:
Pointer to the structure to clear.
This function clears the contents of a Slapi_DN structure. It frees both the DN and the normalized DN, if any, and sets those pointers to NULL.
Duplicates a Slapi_DN structure.
#include "slapi-plugin.h" Slapi_DN * slapi_sdn_dup(const Slapi_DN *sdn);
This function takes the following parameter:
Pointer to the Slapi_DN structure to duplicate.
This function returns a pointer to a duplicate of sdn.
Frees a Slapi_DN structure.
#include "slapi-plugin.h" void slapi_sdn_free(Slapi_DN **sdn);
This function takes the following parameter:
Pointer to the Slapi_DN structure to free.
This function frees the Slapi_DN structure and its contents pointed to by the contents of sdn.
Gets the DN of the parent of an entry within a specific backend.
#include "slapi-plugin.h" void slapi_sdn_get_backend_parent(const Slapi_DN *sdn, Slapi_DN *sdn_parent,const Slapi_Backend *backend);
This function takes the following parameters:
DN of the entry whose parent is searched.
Parent DN of sdn.
Backend of which the parent of sdn is to be searched.
This function gets the parent DN of an entry within a given backend. The parent DN is returned is sdn_parent, unless sdn is empty or is a suffix of the backend itself. In this case, sdn_parent is empty.
A Slapi_DN structure for sdn_parent must be allocated before calling this function.
Gets the DN from a Slapi_DN structure.
#include "slapi-plugin.h" const char * slapi_sdn_get_dn(const Slapi_DN *sdn);
This function takes the following parameter:
The Slapi_DN structure containing the DN value.
This function returns the DN value.
This function retrieves the DN value of a Slapi_DN structure. The returned value can be the normalized DN (in a canonical format and in lower case) if no other value is present.
Gets the normalized DN of a Slapi_DN structure.
#include "slapi-plugin.h" const char * slapi_sdn_get_ndn(const Slapi_DN *sdn);
This function takes the following parameter:
The Slapi_DN structure containing the DN value.
This function returns the normalized DN value.
This function retrieves the normalized DN (in a canonical format and lower case) from a Slapi_DN structure and normalizes sdn if it has not already been normalized.
Gets the length of the normalized DN of a Slapi_DN structure.
#include "slapi-plugin.h" int slapi_sdn_get_ndn_len(const Slapi_DN *sdn);
This function takes the following parameter:
The Slapi_DN structure containing the DN value.
This function returns the length of the normalized DN.
This function contains the length of the normalized DN and normalizes sdn if it has not already been normalized.
Gets the parent DN of a given Slapi_DN structure.
#include "slapi-plugin.h" void slapi_sdn_get_parent(const Slapi_DN *sdn,Slapi_DN *sdn_parent);
This function takes the following parameters:
Pointer to the initialized Slapi_DN structure containing the DN whose parent is searched.
Pointer to the Slapi_DN structure where the parent DN is returned.
This function returns a Slapi_DN structure containing the parent DN of the DN kept in the structure pointed to by sdn.
slapi_sdn_get_backend_parent()
Gets the RDN from a DN.
#include "slapi-plugin.h" void slapi_sdn_get_rdn(const Slapi_DN *sdn, Slapi_RDN *rdn);
This function takes the following parameters:
Pointer to the Slapi_DN structure containing the DN.
Pointer to the Slapi_RDN structure where the RDN is returned.
This function takes the DN stored in the Slapi_DN structure pointed to by sdn and retrieves its returned RDN within the Slapi_RDN structure pointed to by rdn.
Returns a pointer to the DN of the suffix containing the target.
#include "slapi-plugin.h" Slapi_DN* slapi_sdn_get_suffix(const Slapi_DN *target_sdn);
This function takes the following parameter:
DN of the target entry whose suffix you want.
This function returns a pointer to a Slapi_DN structure containing the base DN of the suffix for the entry with target_sdn, or NULL if that suffix is not available.
Free the structure returned using slapi_sdn_free().
Checks whether there is a DN value stored in a Slapi_DN structure.
#include "slapi-plugin.h" int slapi_sdn_isempty( const Slapi_DN *sdn);
This function takes the following parameter:
Pointer to the Slapi_DN structure that is going to be checked.
This function returns one of the following values:
1 if there is no DN value (normalized or not) present in the Slapi_DN structure.
0 if sdn is not empty.
This function checks whether a Slapi_DN structure contains a normalized or non-normalized value.
Checks whether a DN is the parent of the parent of a given DN.
#include "slapi-plugin.h" int slapi_sdn_isgrandparent( const Slapi_DN *parent, const Slapi_DN *child );
This function takes the following parameters:
Pointer to the Slapi_DN structure containing the DN that claims to be the grandparent DN of the DN in child .
Pointer to the Slapi_DN structure containing the DN of the supposed “grandchild” of the DN in the structure pointed to by parent.
This function returns one of the following values:
1 if the DN in parent is the grandparent of the DN in child.
0 if the DN in parent does not match the DN of the grandparent of the DN in child.
Checks whether a DN is the parent of a given DN.
#include "slapi-plugin.h" int slapi_sdn_isparent(const Slapi_DN *parent, const Slapi_DN *child);
This function takes the following parameters:
Pointer to the Slapi_DN structure containing the DN that claims to be the parent of the DN in child.
Pointer to the Slapi_DN structure containing the DN of the supposed child of the DN in the structure pointed to by parent.
This function returns one of the following values:
1 if the DN in parent is the parent of the DN in child.
0 if the DN in parent does not match the DN of the parent of the DN in child.
Checks whether a Slapi_DN structure contains a suffix of another Slapi_DN structure.
#include "slapi-plugin.h" int slapi_sdn_issuffix(const Slapi_DN *sdn, const Slapi_DN *suffixsdn);
This function takes the following parameters:
Pointer to the Slapi_DN structure to be checked.
Pointer to the Slapi_DN structure of the suffix.
This function returns one of the following values:
1 if the DN is suffixsdn is the suffix of sdn.
0 if the DN in suffixsdn is not a suffix of sdn.
Allocates a new Slapi_DN structure and initializes it to NULL.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_new();
This function takes no parameters.
This function returns a pointer to the newly allocated, and still empty,Slapi_DN structure.
This function creates a new Slapi_DN structure by allocating the necessary memory and initializing both DN and normalized DN values to NULL.
Creates a new Slapi_DN structure and sets a DN value.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_new_dn_byref(const char *dn);
This function takes the following parameter:
The DN value to be set in the new Slapi_DN structure.
This function returns a pointer to the new Slapi_DN structure with a DN value set to the content of dn.
This function creates a new Slapi_DN structure and initializes its DN with the value of dn. The DN of the new structure will point to the same string pointed to by dn (the DN value is passed in to the parameter by reference). However, the FLAG_DN flag is not set and no counter is incremented.
The memory is allocated by the function itself.
Creates a new Slapi_DN structure and sets a DN value.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_new_dn_byval(const char *dn);
This function takes the following parameter:
The DN value to be set in the new Slapi_DN structure.
This function returns a pointer to the new Slapi_DN structure with a DN value set to the content of dn.
This function creates a new Slapi_DN structure and initializes its DN with the value of dn. The DN of the new structure will point to a copy of the string pointed to by dn (the DN value is passed in to the parameter by value). The FLAG_DN flag is set and the internal counter is incremented.
The memory is allocated by the function itself.
Creates a new Slapi_DN structure and sets a DN value.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_new_dn_passin(const char *dn);
This function takes the following parameter:
The DN value to be set in the new Slapi_DN structure.
This function returns a pointer to the new Slapi_DN structure with DN value set to the content of dn.
This function creates a new Slapi_DN structure and initializes its DN with the value of dn. The DN of the new structure will point to the string pointed to by dn. The FLAG_DN flag is set and the internal counter is incremented.
The memory is allocated by the function itself.
Creates a new Slapi_DN structure and sets a normalized DN value.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_new_ndn_byref(const char *ndn);
This function takes the following parameter:
The normalized DN value to be set in the new Slapi_DN structure.
This function returns a pointer to the new Slapi_DN structure with a normalized DN value set to the content of ndn.
This function creates a new Slapi_DN structure and initializes its normalized DN with the value of ndn. The normalized DN of the new structure will point to the same string pointed to by ndn (the normalized DN value is passed into the parameter by reference). However, the FLAG_NDN flag is not set and no counter is incremented.
The memory is allocated by the function itself.
Creates a new Slapi_DN structure and sets a normalized DN value.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_new_ndn_byval(const char *ndn);
This function takes the following parameter:
The normalized DN value to be set in the new Slapi_DN structure.
This function returns a pointer to the new Slapi_DN structure with a normalized DN value set to the content of ndn.
This function creates a new Slapi_DN structure and initializes its normalized DN with the value of ndn. The normalized DN of the new structure will point to a copy of the string pointed to by ndn (the normalized DN value is passed into the parameter by value). The FLAG_DND flag is set and the internal counter is incremented.
The memory is allocated by the function itself.
Checks whether an entry, given its DN, is in the scope of a certain base DN.
#include "slapi-plugin.h" int slapi_sdn_scope_test( const Slapi_DN *dn, const Slapi_DN *base, int scope );
This function takes the following parameters:
The DN of the entry subject of scope test.
The base DN to which dn is going to be tested against.
The scope tested. This parameter can take one of the following levels
LDAP_SCOPE_BASE - where the entry DN should be the same as the base DN
LDAP_SCOPE_ONELEVEL - where the base DN should be the parent of the entry DN
LDAP_SCOPE_SUBTREE - where the base DN should at least be the suffix of the entry DN
This function returns non-zero if dn matches the scoping criteria given by base and scope.
This function carries out a simple test to check whether the DN passed in the dn parameter is actually in scope of the base DN according to the values passed into the scope and base parameters.
Sets a DN value in a Slapi_DN structure.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_set_dn_byref(Slapi_DN *sdn, const char *dn);
This function takes the following parameters:
The target Slapi_DN structure.
The DN value to be set in sdn.
This function returns a pointer to the Slapi_DN structure containing the new DN value.
This function sets a DN value in a Slapi_DN structure. The DN of the new structure will point to the same string pointed to by dn (the DN value is passed into the parameter by value). However, the FLAG_DN flag is not set, and no internal counter is incremented.
Sets a DN value in a Slapi_DN structure.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_set_dn_byval(Slapi_DN *sdn, const char *dn);
This function takes the following parameters:
The target Slapi_DN structure.
The DN value to be set in sdn.
This function returns a pointer to the Slapi_DN structure containing the new DN value.
This function sets a DN value in a Slapi_DN structure. The DN of the new structure will point to a copy of the string pointed to by dn (the DN value is passed into the parameter by value). The FLAG_DN flag is set, and the internal counters are incremented.
Sets a DN value in Slapi_DN structure.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_set_dn_passin(Slapi_DN *sdn, const char *dn);
This function takes the following parameters:
The target Slapi_DN structure.
The DN value to be set in sdn.
This function returns a pointer to the Slapi_DN structure containing the new DN value.
This function sets a DN value in a Slapi_DN structure. The DN of the new structure will point to the same string pointed to by dn. The FLAG_DN flag is set, and the internal counters are incremented.
Sets a normalized DN in a Slapi_DN structure.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_set_ndn_byref(Slapi_DN *sdn, const char *ndn);
This function takes the following parameters:
The target Slapi_DN structure.
The normalized DN value to be set in sdn.
This function returns a pointer to the Slapi_DN structure containing the new normalized DN value.
This function sets a normalized DN value in a Slapi_DN structure. The normalized DN of the new structure will point to the same string pointed to by ndn (the normalized DN value is passed into the parameter by reference). However, the FLAG_DN flag is not set, and no internal counter is incremented.
Sets a normalized DN value in Slapi_DN structure.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_set_ndn_byval(Slapi_DN *sdn, const char *ndn);
This function takes the following parameters:
The target Slapi_DN structure.
The normalized DN value to be set in sdn.
This function returns a pointer to the Slapi_DN structure containing the new normalized DN value.
This function sets a normalized DN value in a Slapi_DN structure. The normalized DN of the new structure will point to a copy of the string pointed to by ndn (the normalized DN value is passed into the parameter by value). The FLAG_DN flag is set, and the internal counters are incremented.
Sets a new parent for a given entry.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_set_parent(Slapi_DN *sdn, const Slapi_DN *parentdn);
This function takes the following parameters:
The Slapi_DN structure containing the DN of the entry.
The new parent DN.
The function returns a pointer to the Slapi_DN structure that contains the DN of the entry after the new parent DN has been set.
This function sets a new parent for an entry. This is done by keeping the RDN of the original DN of the entry and by adding the DN of its new parent (the value of parentdn).
Sets a new RDN for given entry.
#include "slapi-plugin.h" Slapi_DN *slapi_sdn_set_rdn(Slapi_DN *sdn, const Slapi_RDN *rdn);
This function takes the following parameters:
The Slapi_DN structure containing the DN of the entry.
The new RDN.
This function returns a pointer to the Slapi_DN structure that keeps the DN of the entry after the new RDN has been set.
This function sets a new RDN for an entry. This is done by retrieving the DN of the entry’s parent of the origin DN of the entry and then adding it to the RDN (the value of rdn) to it.
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_search_internal_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 LDAP v3 referrals. The function must have the prototype specified by plugin_referral_entry_callback.
This function returns -1 if the parameter passed is a NULL pointer. Otherwise, it returns 0.
After your code calls this function, the server sets SLAPI_PLUGIN_INTOP_RESULT in the parameter block to the appropriate LDAP result code. You can therefore check SLAPI_PLUGIN_INTOP_RESULT in the parameter block to determine whether an error has occurred.
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:
You can write a callback function that is invoked when the search operation normally sends a result code to the client. This function must have the prototype specified by plugin_result_callback. You specify this function in the prc argument of slapi_search_internal_callback_pb() .
You can write a callback function that is invoked when the search operation normally sends a search entry to the client. This function must have the prototype specified by plugin_search_entry_callback. You specify this function in the psec argument of slapi_search_internal_callback_pb() .
You can write a callback function that is invoked when the search operation normally sends LDAP v3 search result references. This function must have the prototype specified by plugin_referral_entry_callback . You specify this function in the prec argument of slapi_search_internal_callback_pb().
You can also pass arbitrary plug-in or operation-specific data to these callback functions. Specify the data that you want to pass as the callback_data argument of slapi_search_internal_callback_pb() .
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 (that is, it performs a base object search).
#include "slapi-plugin.h" int slapi_search_internal_get_entry( Slapi_DN const *dn, char ** attrlist, Slapi_Entry **ret_entry, void *caller_identity);
This function takes the following parameters:
The DN of the entry to be read.
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 returns the LDAP result code for the search operation.
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.
#include "slapi-plugin.h" int slapi_search_internal_pb(Slapi_PBlock *pb);
This function takes the following parameter:
A parameter block that has been initialized using slapi_search_internal_set_pb().
This function returns -1 if the parameter passed is a NULL pointer. Otherwise, it returns 0.
After your code calls this function, the server sets SLAPI_PLUGIN_INTOP_RESULT in the parameter block to the appropriate LDAP result code. You can therefore check SLAPI_PLUGIN_INTOP_RESULT in the parameter block to determine whether an error has occurred.
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().
Sets a parameter block for an internal search.
#include slapi-plugin.h int 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:
Parameter block.
The base of the search.
LDAP_SCOPE_SUBTREE, LDAP_SCOPE_ONELEVEL , or LDAP_SCOPE_BASE
The search filter.
Request attribute list. The returned entry attributes depend on the value of attrs.
NULL: All attributes Null terminated array of strings representing a list of attribute types: A subset of the entry attributes, that is, the one specified in attrs if presents in the entry and a few other like the attributes used in the rdn.
Specifying 1 retrieves only the attribute types. Specifying 0 retrieves the attribute types and the attribute values.
LDAP control that you wish to attach.
Unique ID must be set to NULL.
Plug-in identifier obtained from SLAPI_PLUGIN_IDENTITY during plug-in initialization.
The only flag that is exposed in this release is SLAPI_OP_FLAG_NEVER_CHAIN . If this flag is set, then the search will not be conducted if the entry is a chained backend.
This function returns 0 if successful. Otherwise, it returns an LDAP error code.
Use this function to set the parameter block to perform an internal search. This function is needed in order to use the internal search operation function, slapi_search_internal_pb().
You would typically create a Slapi_PBlock structure using slapi_pblock_new(), pass that parameter block to slapi_search_internal_pb(), and then pass the same parameter block to actually do the search.
Returned entries are those provided to the entry callback or in the array got with slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries)().
Allocate the parameter block using slapi_pblock_new() before calling this function.
Directory Server does not free the parameters you passed to this function.
Free the parameter block after calling slapi_search_internal_pb() .
Processes an entry’s LDAP v3 referrals (which are found in the entry’s ref attribute). For LDAP v3 clients, this function sends the LDAP referrals back to the client. For LDAP v2 clients, this function copies the referrals to an array of berval structures that you can pass to slapi_send_ldap_result() function at a later time.
#include "slapi-plugin.h" int slapi_send_ldap_referral( Slapi_PBlock *pb, Slapi_Entry *e, struct berval **refs, struct berval ***urls );
This function takes the following parameters:
Parameter block.
Pointer to the Slapi_Entry structure representing the entry that you are working with.
Pointer to the NULL terminated array of berval structures containing the LDAP v3 referrals (search result references) found in the entry.
Pointer to the array of berval structures used to collect LDAP referrals for LDAP v2 clients.
This function returns 0 if successful, or -1 if an error occurs.
When you call this function, the server processes the LDAP referrals specified in the refs argument. The server processes referrals in different ways, depending on the version of the LDAP protocol supported by the client:
In the LDAP v3 protocol, references to other LDAP servers (search result references) can be sent to clients as search results. (For example, a server can send a mixture of entries found by the search and references to other LDAP servers as the results of a search.)
When you call the slapi_send_ldap_referral() function for LDAP v3 clients, the server sends the referrals specified in the refs argument back to the client as search result references. (The urls argument is not used in this case.)
In the LDAP v2 protocol, servers can send the LDAP result code LDAP_PARTIAL_RESULTS to refer the client to other LDAP server.
When you call the slapi_send_ldap_referral() function for LDAP v2 clients, the server collects the referrals specified in refs in the urls argument. No data is sent to the LDAP v2 client.
To get the referrals to an LDAP v2 client, you need to pass the urls argument (along with an LDAP_PARTIAL_RESULTS result code) to the slapi_send_ldap_result() function.slapi_send_ldap_result() concatenates the referrals specified in the urls argument and sends the resulting string to the client as part of the error message.
If you want to define your own function for sending referrals, write a function that complies with the type definition send_ldap_search_entry_fn_ptr_t and set the SLAPI_PLUGIN_DB_REFERRAL_FN parameter in the parameter block to the name of your function.
slapi_send_ldap_search_entry()
Sends an LDAP result code back to the client.
#include "slapi-plugin.h" void slapi_send_ldap_result( Slapi_PBlock *pb, int err, char *matched, char *text, int nentries, struct berval **urls );
This function takes the following parameters:
Parameter block.
LDAP result code that you want sent back to the client (for example, LDAP_SUCCESS).
When sending back an LDAP_NO_SUCH_OBJECT result code, use this argument to specify the portion of the target DN that could be matched. (Pass NULL in other situations.)
Error message that you want sent back to the client. (Pass NULL if you do not want an error message sent back.)
When sending back the result code for an LDAP search operation, use this argument to specify the number of matching entries found.
When sending back an LDAP_PARTIAL_RESULTS result code to an LDAP v2 client or an LDAP_REFERRAL result code to an LDAP v3 client, use this argument to specify the array of berval structures containing the referral URLs. (Pass NULL in other situations.)
Call slapi_send_ldap_result() to send an LDAP result code (such as LDAP_SUCCESS) back to the client.
The following arguments are intended for use only in certain situations:
matched
When sending an LDAP_NO_SUCH_OBJECT result code back to a client, use matched to specify how much of the target DN could be found in the database. For example, if the client was attempting to find the DN:
cn=Babs Jensen, ou=Product Division, o=Example, c=US
and the database contains entries for c=US and o=Example, c=US, but no entry for ou=Product Division, o=Example, c=US, you should set the matched parameter to:
o=Example, c=US
urls
When sending an LDAP_PARTIAL_RESULTS result code back to an LDAP v2 client or an LDAP_REFERRAL result code back to an LDAP v3 client, use urls to specify the referral URLs.
For LDAP v3 referrals, you can call slapi_send_ldap_result() to send referrals to LDAP v3 clients and collect them for LDAP v2 clients. You can pass the array of collected referrals to the urls argument of slapi_send_ldap_result(). For example:
struct berval **urls; ... slapi_send_ldap_referral(ld, e, &refs, &urls); slapi_send_ldap_result(ld,LDAP_PARTIAL_RESULTS,NULL,NULL,0,urls);
If you want to define your own function for sending result codes, write a function that complies with the type definition send_ldap_search_entry_fn_ptr_t and set the SLAPI_PLUGIN_DB_RESULT_FN parameter in the parameter block to the name of your function.
slapi_send_ldap_search_entry()
Sends an entry found by a search back to the client.
#include "slapi-plugin.h" int slapi_send_ldap_search_entry( Slapi_PBlock *pb, Slapi_Entry *e, LDAPControl **ectrls, char **attrs, int attrsonly );
This function takes the following parameters:
Parameter block.
Pointer to the Slapi_Entry structure representing the entry that you want to send back to the client.
Pointer to the array of LDAPControl structures representing the controls associated with the search request.
Attribute types specified in the LDAP search request
Specifies whether or not the attribute values should be sent back with the result.
If 0, the values are included.
If 1, the values are not included.
This function returns 0 if successful, 1 if the entry is not sent (for example, if access control did not allow it to be sent), or -1 if an error occurs.
Call slapi_send_ldap_search_entry() to send an entry found by a search back to the client.
attrs is the array of attribute types that you want to send from the entry. This value is equivalent to the SLAPI_SEARCH_ATTRS parameter in the parameter block.
attrsonly specifies whether you want to send only the attribute types or the attribute types and their values:
Pass 0 for this parameter if you want to send both the attribute types and values to the client.
Pass 1 for this parameter if you want to send only the attribute types (not the attribute values) to the client.
This value is equivalent to the SLAPI_SEARCH_ATTRSONLY parameter in the parameter block.
If you want to define your own function for sending entries, write a function complies with the type definition send_ldap_search_entry_fn_ptr_t and set the SLAPI_PLUGIN_DB_ENTRY_FN parameter in the parameter block to the name of your function.
Modify an object extension.
#include "slapi-plugin.h" void slapi_set_object_extension(int objecttype, void *object, int extensionhandle, void *extension);
This function takes the following parameters:
Set by the server and used to retrieve the extension
Extended object
Set by the server and used to retrieve the extension
New extension to attach to the object
This function modifies an extension to an object.
slapi_register_object_extension()
Converts an LDIF description of a directory entry (a string value) into an entry of the Slapi_Entry type.
#include "slapi-plugin.h" Slapi_Entry *slapi_str2entry( char *s, int flags );
This function takes the following parameters:
Description of an entry that you want to convert to Slapi_Entry.
One or more flags specifying how the entry should be generated
The value of the flags argument can be one of the following values:
Removes any duplicate values in the attributes of the entry.
Adds the relative distinguished name (RDN) components (for example, uid=bjensen) as attributes of the entry.
Pointer to the Slapi_Entry structure representing the entry, or NULL if the string cannot be converted (for example, if no DN is specified in the string).
A directory entry can be described by a string in LDIF format.
Calling the slapi_str2entry() function converts a string description in this format to a Slapi_Entry structure, which you can pass to other API functions.
This function modifies the string argument s. If you must use the string value again, make a copy of this string before calling slapi_str2entry().
If an error occurred during the conversion process, the function returns NULL instead of the entry.
When you are finished working with the entry, you should call the slapi_entry_free() function.
To convert an entry to a string description, call the slapi_entry2str() function.
Do not use free() or slapi_ch_free() to free the entry. Always use slapi_entry_free() instead.
Converts a string description of a search filter into a filter of the Slapi_Filter type.
#include "slapi-plugin.h" Slapi_Filter *slapi_str2filter( char *str );
This function takes the following parameter:
String description of a search filter.
Do not pass a static string to this function. Instead, create a duplicate using slapi_ch_strdup(). When you are finished working with this filter, you should free the Slapi_Filter structure by calling slapi_filter_free().
Pointer to the Slapi_Filter structure representing the search filter, or NULL if the string cannot be converted (for example, if an empty string is specified or if the filter syntax is incorrect).
Unlocks the specified mutex.
#include "slapi-plugin.h" int slapi_unlock_mutex( Slapi_Mutex *mutex );
This function takes the following parameters:
Pointer to an Slapi_Mutex structure representing the mutex that you want to unlock.
One of the following values:
A non-zero value if the mutex was successfully unlocked.
0 if the mutex was NULL or was not locked by the calling thread.
This function unlocks the mutex specified by the Slapi_Mutex structure.
Compares two UTF-8 strings.
#include "slapi-plugin.h" int slapi_UTF-8CASECMP(char *s0, char *s1);
This function takes the following parameters:
A NULL terminated UTF-8 string.
A NULL terminated UTF-8 string.
This function returns one of the following values:
positive number if s0 is after s1.
0 if the two string are identical, ignoring case.
negative number if s1 is after s0.
This function has the following rules:
If both UTF-8 strings are NULL or 0-length, 0 is returned.
If one of the strings is NULL or 0-length, the NULL or 0-length string is smaller.
If one or both of the strings are not UTF-8, system provided strcasecmp is used.
If one of the two strings contains no 8-bit characters, strcasecmp is used.
The strings are compared after they are converted to lowercase UTF-8.
Each character is compared from the beginning.
Evaluation occurs in this order:
If the length of one character is shorter then the other, the difference of the two lengths is returned.
If the length of the corresponding characters is the same, each byte in the characters is compared.
If there is a difference between two bytes, the difference is returned.
If one string is shorter then the other, the difference is returned.
Compares a specified number of UTF-8 characters.
#include "slapi-plugin.h" int slapi_UTF-8NCASECMP(char *s0, char *s1, int n);
This function takes the following parameters:
A NULL terminated UTF-8 string.
A NULL terminated UTF-8 string.
The number of UTF-8 characters (not bytes) from s0 and s1 to compare.
This function returns one of the following values:
positive number if s0 is after s1.
0 if the two string are identical, ignoring case.
negative number if s1 is after s0.
This function has the following rules:
If both UTF-8 strings are NULL or 0-length, 0 is returned.
If one of the strings is NULL or 0-length, the NULL or 0-length string is smaller.
If one or both of the strings are not UTF-8, system provided strcasecmp is used.
If one of the two strings contains no 8-bit characters, strcasecmp is used.
The strings are compared after they are converted to lower-case UTF-8.
Each character is compared from the beginning.
Evaluation occurs in this order:
If the length of one character is shorter then the other, the difference of the two lengths is returned.
If the length of the corresponding characters is the same, each byte in the characters is compared.
If there is a difference between two bytes, the difference is returned.
If one string is shorter then the other, the difference is returned.
Verifies if a UTF-8 character is lower case.
#include "slapi-plugin.h" int slapi_UTF-8ISLOWER(char *s);
This function takes the following parameter:
Pointer to a single UTF-8 character (could be multiple bytes).
This function returns 1 if the character is a lower case letter, or 0 if it is not.
Verifies if a single UTF-8 character is upper case.
#include "slapi-plugin.h" int slapi_UTF-8ISUPPER(char *s);
This function takes the following parameter:
Pointer to a single UTF-8 character (could be multiple bytes).
This function returns 1 if the character is an upper case letter, or 0 if it is not.
Converts a UTF-8 string to lower case.
#include "slapi-plugin.h" unsigned char *slapi_UTF-8STRTOLOWER(char *s);
This function takes the following parameter:
A NULL terminated UTF-8 string to be converted to lower case.
This function returns a pointer to a NULL terminated UTF-8 string whose characters are converted to lower case. Characters which are not upper case are copied as is. If the string is not found to be a UTF-8 string, this function returns NULL.
This function converts a string of multiple UTF-8 characters, and not a single character, as in slapi_UTF-8TOLOWER().
The output string is allocated, and needs to be released when it is no longer needed.
Converts a string made up of UTF-8 characters and converts it to upper case.
#include "slapi-plugin.h" unsigned char *slapi_UTF-8STRTOUPPER(char *s);
This function takes the following parameter:
A NULL terminated UTF-8 string to be converted to upper case.
This function returns a NULL terminated UTF-8 string whose characters are converted to upper case. Character which are not lower case are copied as is. If the string is not considered to be a UTF-8 string, this function returns NULL.
The output string is allocated in this function, and needs to be released when it is no longer used.
Converts a UTF-8 character to lower case.
#include "slapi-plugin.h" void slapi_UTF-8TOLOWER(char *s, char *d, int *ssz, int *dsz);
This function takes the following parameters:
A single UTF-8 character (could be multiple bytes).
Pointer to the lower case form of s. The memory for this must be allocated by the caller before calling the function.
Returns the length in bytes of the input character.
Returns the length in bytes of the output character.
Converts a lower case UTF-8 character to an upper case character.
#include "slapi-plugin.h" void slapi_UTF-8TOUPPER(char *s, char *d, int *ssz, int *dsz);
This function takes the following parameters:
Pointer to a single UTF-8 character (could be multiple bytes).
Pointer to the upper case version of s. The memory for this must be allocated by the caller before calling the function.
Returns the length in bytes of the input character.
Returns the length in bytes of the output character.
Compares two values for a given attribute to determine if they are equals.
#include "slapi-plugin.h" int slapi_value_compare(const Slapi_Attr *a, const Slapi_Value *v1, const Slapi_Value *v2);
This function takes the following parameters:
A pointer to an attribute used to determine how the two values will be compared.
Pointer to the Slapi_ValueSet structure containing the first value to compare.
Pointer to the Slapi_Value structure containing the second value to compare.
This function returns one of the following values:
0 if the two values are equal.
-1 if v1 is smaller than v2.
1 if v1 is greater than v2.
This function compares two Slapi_Values using the matching rule associated to the attribute a.
This function replaces the deprecated slapi_attr_value_cmp() function used in previous releases, and uses the Slapi_Value attribute values instead of the berval attribute values.
Frees internals of a Slapi_Value structure.
#include "slapi-plugin.h" void slapi_value_done(Slapi_Value *v);
This function takes the following parameter:
Pointer to the Slapi_Value structure whose internals you want to free.
slapi_value_init(), slapi_value_init_berval(), slapi_value_init_string()
Duplicates a value.
#include "slapi-plugin.h" Slapi_Value * slapi_value_dup(const Slapi_Value *v);
This function takes the following parameter:
Pointer to the Slapi_Value structure you wish to duplicate.
This function returns a pointer to a newly allocated Slapi_Value.
The new Slapi_Value is allocated and needs to be freed by the caller, using slapi_value_free().
Frees the specified Slapi_Value structure and its members from memory.
#include "slapi-plugin.h" void slapi_value_free(Slapi_Value **value);
This function takes the following parameter:
Address of the pointer to the Slapi_Value you wish to free.
This function frees the Slapi_Value structure and its members (if it is not NULL), and sets the pointer to NULL.
Call this function when you are finished working with the structure.
Frees the specified array of Slapi_Value structures and their members from memory.
#include "slapi-plugin.h" void slapi_valuearray_free(Slapi_Value ***value);
This function takes the following parameter:
Array of Slapi_Value structures to free.
This function frees each Slapi_Value structure and its members, and sets the pointer to NULL.
Call this function when you are finished working with the array of values.
Gets the berval structure of the value.
#include "slapi-plugin.h" const struct berval * slapi_value_get_berval( const Slapi_Value *value);
This function takes the following parameter:
Pointer to the Slapi_Value of which you wish to get the berval.
Returns a pointer to the berval structure contained in the Slapi_Value. This function returns a pointer to the actual berval structure, and not a copy of it.
You should not free the berval structure unless you plan to replace it by calling slapi_value_set_berval() .
Converts the value to an integer.
#include "slapi-plugin.h" int slapi_value_get_int(const Slapi_Value *value);
This function takes the following parameter:
Pointer to the Slapi_Value of which you wish to get as an integer.
This function returns an integer that corresponds to the value stored in the Slapi_Value structure, or 0 if there is no value.
Converts the value in the Slapi_Value to an integer.
Gets the actual length of the value.
#include "slapi-plugin.h" size_t slapi_value_get_length(const Slapi_Value *value);
This function takes the following parameter:
Pointer to the Slapi_Value of which you wish to get the length.
This function returns the length of the value contained in Slapi_Value, or 0 if there is no value.
This function returns the actual length of a value contained in the Slapi_Value structure.
Converts the value into a long integer.
#include "slapi-plugin.h" long slapi_value_get_long(const Slapi_Value *value);
This function takes the following parameter:
Pointer to the Slapi_Value of which you wish to get as a long integer.
This function returns a long integer that corresponds to the value stored in the Slapi_Value structure, or 0 if there is no value.
This function converts the value contained in the Slapi_Value structure into a long integer.
Returns the value as a string.
#include "slapi-plugin.h" const char * slapi_value_get_string(const Slapi_Value *value);
This function takes the following parameter:
Pointer to the Slapi_Value of which you wish to get as a string.
This function returns a string containing the value, or NULL if there is no value.
This function returns a pointer to the actual string value in Slapi_Value, not a copy of it.
You should not free the string unless to plan to replace it by calling slapi_value_set_string().
Converts the value to an unsigned integer.
#include "slapi-plugin.h" unsigned int slapi_value_get_uint(const Slapi_Value *value);
This function takes the following parameter:
Pointer to the Slapi_Value of which you wish to get as an unsigned integer.
This function returns an unsigned integer that corresponds to the value stored in the Slapi_Value structure, or 0 if there is no value.
Converts the value contained in Slapi_Value into an unsigned integer.
Converts the value into an unsigned long.
#include "slapi-plugin.h" unsigned long slapi_value_get_ulong(const Slapi_Value *value);
This function takes the following parameter:
Pointer to the Slapi_Value of which you wish to get as an unsigned long integer.
This function returns an unsigned long integer that corresponds to the value stored in the Slapi_Value structure, or 0 if there is no value.
Converts the value contained in the Slapi_Value structure into an unsigned long integer.
Initializes a Slapi_Value structure with no value.
#include "slapi-plugin.h" Slapi_Value * slapi_value_init(Slapi_Value *v);
This function takes the following parameter:
Pointer to the value to be initialized. The pointer must not be NULL.
This function returns a pointer to the initialized Slapi_Value structure (itself).
This function initializes the Slapi_Value structure, resetting all of its fields to zero. The value passed as the parameter must be a valid Slapi_Value.
When finished using the Slapi_Value structure, free its internal structures by using slapi_value_done().
Initializes a Slapi_Value structure from the berval structure.
#include "slapi-plugin.h" Slapi_Value * slapi_value_init_berval(Slapi_Value *v, struct berval *bval);
This function takes the following parameters:
Pointer to the value to initialize. The pointer must not be NULL.
Pointer to the berval structure to be used to initialize the value.
This function returns a pointer to the initialized Slapi_Value structure (itself).
This function initializes the Slapi_Value structure with the value contained in the berval structure. The content of the berval structure is duplicated.
When finished using the Slapi_Value structure, free its internal structures by using slapi_value_done().
Initializes a Slapi_Value structure from a string.
#include "slapi-plugin.h" Slapi_Value * slapi_value_init_string(Slapi_Value *v,const char *s);
This function takes the following parameters:
Pointer to the value to be initialized. The pointer must not be NULL.
NULL terminated string used to initialize the value.
This function returns a pointer to the initialized Slapi_Value structure (itself).
This function initializes the Slapi_Value structure with the value contained in the string. The string is duplicated.
When finished using the Slapi_Value structure, free its internal structures by using slapi_value_done().
Initializes a Slapi_Value structure with value contained in the string.
#include "slapi-plugin.h" Slapi_Value * slapi_value_init_string_passin (Slapi_value *v, char *s);
This function takes the following parameters:
Pointer to the value to be initialized. The pointer must not be NULL.
NULL terminated string used to initialize the value.
This function returns a pointer to the initialized Slapi_Value structure (itself).
This function initializes a Slapi_Value structure with the value contained in the string. The string is not duplicated and must be freed.
The string will be freed when the Slapi_Value structure is freed from memory by calling slapi_value_free().
slapi_value_new_string_passin()
slapi_value_set_string_passin()
Allocates a new Slapi_Value structure.
#include "slapi-plugin.h" Slapi_Value * slapi_value_new();
This function does not take any parameters.
This function returns a pointer to the newly allocated Slapi_Value structure. If space cannot be allocated (for example, if no more virtual memory exists), the slapd program terminates.
This function returns an empty Slapi_Value structure. You can call other functions of the API to set the value.
When you are no longer using the value, free it from memory by calling slapi_value_free().
Allocates a new Slapi_Value structure and initializes it from a berval structure.
#include "slapi-plugin.h" Slapi_Value * slapi_value_new_berval(const struct berval *bval);
This function takes the following parameter:
Pointer to the berval structure used to initialize the newly allocated Slapi_Value.
This function returns a pointer to the newly allocated Slapi_Value. If space cannot be allocated (for example, if no more virtual memory exists), the slapd program will terminate.
This function returns a Slapi_Value structure containing a value duplicated from the berval structure passed as the parameter.
When you are no longer using the value, you should free it from memory by calling slapi_value_free().
Allocates a new Slapi_Value structure and initializes it from a string.
#include "slapi-plugin.h" Slapi_Value * slapi_value_new_string(const char *s);
This function takes the following parameter:
NULL terminated string used to initialize the newly allocated Slapi_Value.
This function returns a pointer to the newly allocated Slapi_Value. If space cannot be allocated (for example, if no more virtual memory exists), the slapd program will terminate.
This function returns a Slapi_Value structure containing a value duplicated from the string passed as the parameter.
When you are no longer using the value, you should free it from memory by calling slapi_value_free().
Allocates a new Slapi_Value structure and initializes it from a string.
#include "slapi-plugin.h" Slapi_Value * slapi_value_new_string_passin ( char *s );
This function takes the following parameter:
NULL terminated string used to initialize the newly allocated Slapi_Value structure.
This function returns a pointer to a newly allocated Slapi_Value structure. If space cannot be allocated (for example, if no virtual memory exists), the slapd program terminates.
This function returns a Slapi_Value structure containing the string passed as the parameter. The string passed in must not be freed from memory.
The value should be freed by the caller, using slapi_value_free() .
Allocates a new Slapi_Value structure and initializes it from another Slapi_Value structure.
#include "slapi-plugin.h" Slapi_Value * slapi_value_new_value(const Slapi_Value *v);
This function takes the following parameter:
Pointer to the Slapi_Value structure used to initialize the newly allocated Slapi_Value.
This function returns a pointer to the newly allocated Slapi_Value. If space cannot be allocated (for example, if no more virtual memory exists), the slapd program will terminated.
This function returns a Slapi_Value structure containing a value duplicated from the Slapi_Value structure passed as the parameter. This function is identical to slapi_value_dup() .
When you are no longer using the value, you should free it from memory by calling the slapi_value_free() function/
Sets the value in a Slapi_Value structure.
#include "slapi-plugin.h" Slapi_Value * slapi_value_set(Slapi_Value *value, void *val, unsigned long len);
This function takes the following parameters:
Pointer to the Slapi_Value in which to set the value.
Pointer to the value.
Length of the value.
This function returns a pointer to the Slapi_Value with the value set.
This function sets the value in the Slapi_Value structure. The value is a duplicate of the data pointed to by val and of length len.
If the pointer to the Slapi_Value structure is NULL, then nothing is done and the function returns NULL. If the Slapi_Value structure already contains a value, it is freed from memory before the new one is set.
When you are no longer using the Slapi_Value structure, you should free it from memory by calling slapi_value_free() .
Copies the value from a berval structure into a Slapi_Value structure.
#include "slapi-plugin.h" Slapi_Value * slapi_value_set_berval(Slapi_Value *value, const struct berval *bval );
This function takes the following parameters:
Pointer to the Slapi_Value structure in which to set the value.
Pointer to the berval value to be copied.
This function returns the pointer to the Slapi_Value structure passed as the parameter, or NULL if it was NULL.
This function sets the value of Slapi_Value structure. The value is duplicated from the berval structure bval.
If the pointer to the Slapi_Value structure is NULL, nothing is done and the function returns NULL . If the Slapi_Value already contains a value, it is freed from memory before the new one is set.
When you are no longer using the Slapi_Value structure, you should free it from memory by calling slapi_value_free() .
Sets the integer value of a Slapi_Value structure.
#include "slapi-plugin.h" int slapi_value_set_int(Slapi_Value *value, int intVal);
This function takes the following parameters:
Pointer to the Slapi_Value structure in which to set the integer value.
The integer containing the value to set.
This function returns one of the following values:
0 if the value is set.
-1 if the pointer to the Slapi_Value is NULL.
This function sets the value of the Slapi_Value structure from the integer intVal.
If the pointer to the Slapi_Value structure is NULL, nothing is done and the function returns -1. If the Slapi_Value already contains a value, it is freed from memory before the new one is set.
When you are no longer using the Slapi_Value structure, you should free it from memory by calling slapi_value_free() .
Copies a string in the value of a Slapi_Value structure.
#include "slapi-plugin.h" int slapi_value_set_string(Slapi_Value *value, const char *strVal);
This function takes the following parameters:
Pointer to the Slapi_Value structure in which to set the value.
The string containing the value to set.
This function returns one of the following:
0 if value is set.
-1 if the pointer to the Slapi_Value is NULL.
This function sets the value of the Slapi_Value structure by duplicating the string strVal.
If the pointer to the Slapi_Value is NULL, nothing is done and the function returns -1. If the Slapi_Value already contains a value, it is freed from memory before the new one is set.
When you are no longer using the Slapi_Value structure, you should free it from memory by calling slapi_value_free() .
Sets the value of a Slapi_Value structure from a string.
#include "slapi-plugin.h" int slapi_value_set_string_passin(Slapi_Value *value, char *strVal);
This function takes the following parameters:
Pointer to the Slapi_Value structure in which to set the value.
The string containing the value to set.
This function returns 0 if the value is set, or -1 if the pointer to the Slapi_Value structure is NULL.
This function sets the value of Slapi_Value structure with the string strVal. If the Slapi_Value structure already contains a value, it is freed from memory before the new one is set. The string strVal must not be freed from memory.
Use slapi_value_free() when you are finished working with the structure to free it from memory.
Copies the value of a Slapi_Value structure into a Slapi_Value structure.
#include "slapi-plugin.h" Slapi_Value * slapi_value_set_value(Slapi_Value *value, const Slapi_Value *vfrom);
This function takes the following parameters:
Pointer to the Slapi_Value in which to set the value.
Pointer to the Slapi_Value from which to get the value.
This function returns the pointer to the Slapi_Value structure passed as the parameter, or NULL if it was NULL.
This function sets the value of the Slapi_Value structure. This value is duplicated from the Slapi_Value structure vfrom. vfrom must not be NULL.
If the pointer to the Slapi_Value is NULL, nothing is done and the function returns NULL. If the Slapi_Value already contains a value, it is freed from before the new one is set.
When you are no longer using the Slapi_Value structure, you should free it from memory by calling slapi_value_free() .
Adds a Slapi_Value in the Slapi_ValueSet structure.
#include "slapi-plugin.h" void slapi_valueset_add_value_optimised(Slapi_ValueSet *vs, const Slapi_Value *addval, void *syntax_plugin);
This function takes the following parameters:
Pointer to the Slapi_ValueSet structure to which to add the value.
Pointer to the Slapi_Value to add to the Slapi_ValueSet.
Pointer to the plug-in for this attribute type, obtained using slapi_attr_get_plugin().
This function adds a value in the form of a Slapi_Value structure in a Slapi_ValueSet structure.
The value is duplicated from the Slapi_Value structure, which can be freed from memory after using it without altering the Slapi_ValueSet structure.
This function does not verify if the value is already present in the Slapi_ValueSet structure. You can manually check this using slapi_valueset_first_value_const() and slapi_valueset_next_value_const() .
slapi_valueset_first_value_const()
slapi_valueset_next_value_const()
Returns the number of values contained in a Slapi_ValueSet structure.
#include "slapi-plugin.h" int slapi_valueset_count(const Slapi_ValueSet *vs);
This function takes the following parameter:
Pointer to the Slapi_ValueSet structure of which you wish to get the count.
This function returns the number of values contained in the Slapi_ValueSet structure.
Frees the values contained in the Slapi_ValueSet structure.
#include "slapi-plugin.h" void slapi_valueset_done(Slapi_ValueSet *vs);
This function takes the following parameter:
Pointer to the Slapi_ValueSet structure from which you wish to free its values.
Use this function when you are no longer using the values, but you want to reuse the Slapi_ValueSet structure for a new set of values.
Finds the value in a value set using the syntax of an attribute.
#include "slapi-plugin.h" const Slapi_Value *slapi_valueset_find(const Slapi_Attr *a, const Slapi_ValueSet *vs, const Slapi_Value *v);
This function takes the following parameters:
Pointer to the attribute. This is used to determine the syntax of the values and how to match them.
Pointer to the Slapi_ValueSet structure from which you wish to get the value.
Address of the pointer to the Slapi_Value structure for the returned value.
This function returns a pointer to the value in the value set if the value was found. Otherwise, it returns NULL.
Use this function to check for duplicate values in an attribute.
Gets the first value of a Slapi_ValueSet structure.
#include "slapi-plugin.h" int slapi_valueset_first_value_const(const Slapi_ValueSet *vs, const Slapi_Value **v);
This function takes the following parameters:
Pointer to the Slapi_ValueSet structure from which you wish to get the value.
Address of the pointer to the Slapi_Value structure for the returned value.
This function returns the index of the value in the Slapi_ValueSet, or -1 if there was no value.
Call this function when you wish to get the first value of a Slapi_ValueSet, or you wish to iterate through all of the values. The returned value is the index of the value in the Slapi_ValueSet structure and must be passed to call slapi_valueset_next_value_const() to get the next value.
This function gives a pointer to the actual value within the Slapi_ValueSet. You should not free it from memory.
slapi_valueset_next_value_const()
Frees the specified Slapi_ValueSet structure and its members from memory.
#include "slapi-plugin.h" void slapi_valueset_free(Slapi_ValueSet *vs)
This function takes the following parameter:
Pointer to the Slapi_ValueSet to free.
This function frees the Slapi_ValueSet structure and its members if it is not NULL. Call this function when you are finished working with the structure.
Resets a Slapi_ValueSet structure to no values.
#include "slapi-plugin.h" void slapi_valueset_init(Slapi_ValueSet *vs);
This function takes the following parameter:
Pointer to the Slapi_ValueSet to reset.
This function initializes the values contained in the Slapi_ValueSet structure (sets them to 0). This does not free the values contained in the structure. To free the values, use slapi_valueset_done() .
When you are no longer using the Slapi_ValueSet structure, you should free it from memory by using slapi_valueset_free() .
Allocates a new Slapi_ValueSet structure.
#include "slapi-plugin.h" Slapi_ValueSet *slapi_valueset_new( void );
This function takes no parameters.
This function returns a a pointer to the newly allocated Slapi_ValueSet structure. If no space could be allocated (for example, if no more virtual memory exists), the slapd program terminates.
This function returns an empty Slapi_ValueSet structure. You can call other slapi_valueset functions of the API to set the values in the Slapi_ValueSet structure.
When you are no longer using the value, you should free it from memory by calling slapi_valueset_free().
Gets the next value from a Slapi_ValueSet structure.
#include "slapi-plugin.h" int slapi_valueset_next_value_const(const Slapi_ValueSet *vs, int index, const Slapi_Value **v);
This function takes the following parameters:
Pointer to the Slapi_ValueSet structure from which you wish to get the value.
Value returned by the previous call to slapi_valueset_next_value_const() or slapi_valueset_first_value_const().
Address to the pointer to the Slapi_Value structure for the returned value.
This function returns the index of the value in the Slapi_ValueSet, or -1 if there was no more value or the input index is incorrect.
Call this function when you wish to get the next value of a Slapi_ValueSet, after having first called slapi_valueset_first_value_const(). The returned value is the index of the value in the Slapi_ValueSet structure and must be passed to slapi_valueset_next_value_const().
This function gives a pointer to the actual value within the Slapi_ValueSet and you should not free it from memory.
slapi_valueset_first_value_const()
Copies the values of Slapi_Mod structure into a Slapi_ValueSet structure.
#include "slapi-plugin.h" void slapi_valueset_set_from_smod(Slapi_ValueSet *vs, Slapi_Mod *smod);
This function takes the following parameters:
Pointer to the Slapi_ValueSet structure into which you wish to copy the values.
Pointer to the Slapi_Mod structure from which you wish to copy the values.
This function copies all of the values contained in a Slapi_Mod structure into a Slapi_ValueSet structure.
This function does not verify that the Slapi_ValueSet structure already contains values, so it is your responsibility to verify that there are no values prior to calling this function. If you do not verify this, the allocated memory space will leak. You can free existing values by calling slapi_valueset_done().
Initializes a Slapi_ValueSet structure from another Slapi_ValueSet structure.
#include "slapi-plugin.h" void slapi_valueset_set_valueset_optimised(Slapi_ValueSet *vs1, const Slapi_ValueSet *vs2, void *syntax_plugin);
This function takes the following parameters:
Pointer to the Slapi_ValueSet structure to which you wish to set the values.
Pointer to the Slapi_ValueSet structure from which you wish to copy the values.
Pointer to the plug-in for this attribute type, obtained using slapi_attr_type2plugin().
This function initializes a Slapi_ValueSet structure by copying the values contained in another Slapi_ValueSet structure.
The function does not verify that the Slapi_ValueSet structure contains values, so it is your responsibility to verify that there are no values prior to calling this function. If you do not verify this, the allocated memory space will leak. You can free existing values by calling slapi_valueset_done().
Free a virtual attribute.
#include "slapi-plugin.h" void slapi_vattr_attr_free(Slapi_Attr **a, int buffer_flags);
This function takes the following parameters:
Attribute to free
Bitmask of SLAPI_VIRTUALATTRS_RETURNED_POINTERS, SLAPI_VIRTUALATTRS_RETURNED_COPIES, SLAPI_VIRTUALATTRS_REALATTRS_ONLY , SLAPI_VIRTUALATTRS_RETURNED_TYPENAME_ONLY
Use this function to frees a virtual attribute when finished with it.
Free a list of virtual attributes.
#include "slapi-plugin.h" void slapi_vattr_attrs_free(vattr_type_thang **types, int flags);
This function takes the following parameters:
List of attributes to free
Bitmask of SLAPI_REALATTRS_ONLY, SLAPI_VIRTUALATTRS_ONLY , SLAPI_VIRTUALATTRS_REQUEST_POINTERS, SLAPI_VIRTUALATTRS_LIST_OPERATIONAL_ATTRS passed as flags to slapi_vattr_list_attrs()
Use this function to frees a list of virtual attributes obtained using slapi_vattr_list_attrs().
Test a filter against an entry that may contain virtual attributes.
#include "slapi-plugin.h" int slapi_vattr_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, struct slapi_filter *f, int verify_access);
This function takes the following parameters:
Parameter block containing the search request
Candidate entry
Filter to check
1 to verify access to the entry before checking, 0 otherwise
This function checks whether the candidate entry e matches the filter f. It does not support LDAP v3 extensible match filters.
This functions returns 0 if the filter matches, or if the filter is NULL. Otherwise, it returns -1.
Check whether an attribute may be virtual.
#include "slapi-plugin.h" int slapi_vattr_is_registered(const char *attrtype, const char *scopendn);
This function takes the following parameters:
Attribute type to check
Base of the scope to check
This function checks whether a virtual attribute service is registered for the attribute type in the scope specified.
The fact that a virtual attribute service is registered for an attribute type does not guarantee that the service can currently provide a value.
This functions returns 1 if the attribute may be virtual in the scope specified. Otherwise, it returns 0.
Check whether an attribute is virtually generated.
#include "slapi-plugin.h" int slapi_vattr_is_virtual( Slapi_Entry *e, const char *attrtype, Slapi_Value *v);
This function takes the following parameters:
Entry to check.
Attribute type to check.
Not currently used.
This functions returns 1 if the attribute value is virtually generated. Otherwise, it returns 0.
Get a list of the real and virtual attributes for an entry.
#include "slapi-plugin.h" int slapi_vattr_list_attrs(Slapi_Entry *e, vattr_type_thang **types, int flags, int *buffer_flags);
This function takes the following parameters:
Get attributes for this entry
List of attributes set by the server
Bitmask of SLAPI_REALATTRS_ONLY, SLAPI_VIRTUALATTRS_ONLY , SLAPI_VIRTUALATTRS_REQUEST_POINTERS, SLAPI_VIRTUALATTRS_LIST_OPERATIONAL_ATTRS determining what to set in the list
Bitmask of SLAPI_VIRTUALATTRS_RETURNED_POINTERS, SLAPI_VIRTUALATTRS_RETURNED_COPIES, SLAPI_VIRTUALATTRS_REALATTRS_ONLY , SLAPI_VIRTUALATTRS_RETURNED_TYPENAME_ONLY determining how the virtual attributes should be handled
This function sets types to point to a full list of attributes for the entry e depending on the flags parameter. Use the buffer_flags parameter when freeing the list.
Use slapi_vattr_values_type_thang_get() to access the attributes.
This functions returns 1 if the attribute may be virtual in the scope specified. Otherwise, it returns 0.
When finished with the types list, free it using slapi_vattr_attrs_free().
slapi_vattr_values_type_thang_get()
Compares attribute type and name in a given entry.
#include "slapi-plugin.h" int slapi_vattr_value_compare( Slapi_Entry *e, char *type, Slapi_Value *test_this, int *result, int flags);
This function takes the following parameters:
Entry to be compared.
Attribute type name.
Value to be tested.
0 if the compare is true, 1 if the compare is false.
Not used. You should pass 0 for this parameter.
This function returns 0 for success, in which case result contains the result of the comparison.
Otherwise, this function returns the following:
SLAPI_VIRTUALATTRS_LOOP_DETECTED (failed to evaluate a virtual attribute).
SLAPI_VIRTUAL_NOT_FOUND (type not recognized by any virtual attribute and not a real attr in entry).
ENOMEM (memory error).
There is no need to call slapi_vattr_values_free() after calling this function.
Frees the value set and type names.
#include "slapi-plugin.h" void slapi_vattr_values_free(Slapi_ValueSet **value, char **actual_type_name, int flags);
This function takes the following parameters:
Value set to be freed.
List of type names.
The buffer flags returned from slapi_vattr_values_get_ex() . This contains information that this function needs to determine which objects need to be freed.
This function should be used to free the value set and type names returned from slapi_vattr_values_get_ex().
Returns the values for an attribute type from an entry.
#include "slapi-plugin.h" int slapi_vattr_values_get_ex(Slapi_Entry *e, char *type, Slapi_ValueSet*** results, int **type_name_disposition, char ***actual_type_name, int flags, int *buffer_flags, int *subtype_count);
This function takes the following parameters:
Entry from which to get the values.
Attribute type name.
Pointer to result set.
Matching result.
Type name as found.
Bit mask of options. Valid values are as follows:
SLAPI_REALATTRS_ONLY
SLAPI_VIRTUALATTRS_ONLY
SLAPI_VIRTUALATTRS_REQUEST_POINTERS
SLAPI_VIRTUALATTRS_LIST_OPERATIONAL_ATTRS
Bit mask to be used as input flags for slapi_vattr_values_free() .
Number of subtypes matched.
This function returns 0 for success, in which case:
results contains the current values for type all of the subtypes in e.
type_name_disposition contains information on how each type was matched. Valid values are:
SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_EXACTLY_OR_ALIAS
SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_SUBTYPE
actual_type_name contains the type name as found.
buffer_flags contains the bit mask to be used as input flags for slapi_vattr_values_free().
subtype_count contains the number of subtypes matched.
Otherwise, this function returns the following
SLAPI_VIRTUALATTRS_LOOP_DETECTED (failed to evaluate a virtual attribute).
SLAPI_VIRTUAL_NOT_FOUND (type not recognized by any virtual attribute and no real attribute in entry).
ENOMEM (memory error).
This function returns the values for an attribute type from an entry, including the values for any subtypes of the specified attribute type. The routine will return the values of virtual attributes in that entry if requested to do so.
slapi_vattr_values_free() should be used to free the returned result set and type names, passing the buffer_flags value returned from this routine.
Get values from a list of the real and virtual attributes for an entry.
#include "slapi-plugin.h" int slapi_vattr_values_type_thang_get(Slapi_Entry *e, vattr_type_thang *type_thang, Slapi_ValueSet** results, int *type_name_disposition, char **actual_type_name, int flags, int *buffer_flags);
This function takes the following parameters:
Entry the attributes belong to
Real or virtual attribute type
Values for the attribute, set by the server
Set by the server to reflect how type name matched; one of SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_EXACTLY_OR_ALIAS, SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_SUBTYPE , SLAPI_VIRTUALATTRS_NOT_FOUND (type matched no real or virtual attribute on the entry), or SLAPI_VIRTUALATTRS_LOOP_DETECTED (could not evaluate the virtual attribute)
Set by the server to the actual type name found
Bitmask of SLAPI_REALATTRS_ONLY, SLAPI_VIRTUALATTRS_ONLY , SLAPI_VIRTUALATTRS_REQUEST_POINTERS, SLAPI_VIRTUALATTRS_LIST_OPERATIONAL_ATTRS applied when obtaining the list using slapi_vattr_list_attrs()
Set by the server to a bitmask of SLAPI_VIRTUALATTRS_RETURNED_POINTERS , SLAPI_VIRTUALATTRS_RETURNED_COPIES, SLAPI_VIRTUALATTRS_REALATTRS_ONLY , SLAPI_VIRTUALATTRS_RETURNED_TYPENAME_ONLY, useful for freeing the list
This function offers optimized access to values of attributes in a list set by slapi_vattr_list_attrs().
This function returns 0 for success, in which case:
results contains the current values for type all of the subtypes in e.
type_name_disposition contains information on how each type was matched. Valid values are
SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_EXACTLY_OR_ALIAS
SLAPI_VIRTUALATTRS_TYPE_NAME_MATCHED_SUBTYPE
actual_type_name contains the type name as found.
buffer_flags contains the bit mask to be used as input flags for slapi_vattr_values_free().
subtype_count contains the number of subtypes matched.
Otherwise, this function returns the following
SLAPI_VIRTUALATTRS_LOOP_DETECTED (failed to evaluate a virtual attribute).
SLAPI_VIRTUAL_NOT_FOUND (type not recognized by any virtual attribute and not a real attr in entry).
ENOMEM (memory error).
Wait for a change in a condition variable.
#include "slapi-plugin.h" int slapi_wait_condvar(Slapi_CondVar *cvar,struct timeval *timeout);
This function takes the following parameter:
Condition variable on which to wait
NULL means block until notified. Otherwise, block until the time is up, then try again to acquire the lock.
This function enables thread synchronization using a wait/notify mechanism.
This function returns 1 if successful. Otherwise, it returns NULL.
Call slapi_notify_condvar() to notify other threads of a change to the condition variable.
This chapter describes the parameters available in the parameter block, Slapi_PBlock, structure. This chapter lists data types associated with each parameter.
To read parameter values, use slapi_pblock_get(). To write parameter values, use slapi_pblock_set(). Use of other functions may crash the server.
Refer to the Part I, Directory Server Plug-In API Guide and the example plug-ins under install-path/examples/ to better grasp how to use these parameters.
This chapter categorizes parameters as follows.
Table 18–1 Slapi_PBlock Parameter Categories
Category |
Accessible to… |
---|---|
All plug-in functions |
|
Pre- and post-operation add functions |
|
All plug-in functions |
|
Pre- and post-operation bind functions |
|
Pre- and post-operation compare functions |
|
All plug-in functions |
|
Pre- and post-operation delete functions |
|
All plug-in functions |
|
Extended operation functions |
|
All plug-in functions |
|
Pre- and post-operation modify functions |
|
All plug-in functions |
|
Plug-in initialization functions and specific types as mentioned in this section |
|
Password check functions and data |
|
Post-operation plug-in functions |
|
Pre- and post-operation modify RDN functions |
|
All plug-in functions |
|
Pre- and post-operation search functions |
The following parameter allows you to configure access log output.
Table 18–2 Access Log Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
unsigned int |
Flag specifying that unindexed searches be indicated in the access log. Setting this parameter to SLAPI_OP_NOTE_UNINDEXED causes the string Notes=U to be appended to access log entries reflecting unindexed searches. |
The following parameters allow you to access an entry to add to the directory through the parameter block.
Table 18–3 Add Function Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
Slapi_Entry * |
Entry to add. |
|
char * |
DN of the entry to add. |
The following parameters allow you to access information about directory backends through the parameter block.
Table 18–4 Backend Information Parameters
The following parameters allow you to access information about the bind operation through the parameter block.
Table 18–5 Bind Function Parameters
The following parameters allow you to access an entry or attribute to use in a comparison through the parameter block.
Table 18–6 Compare Function Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
char * |
DN of the entry to use in the comparison. |
|
char * |
Attribute type to use in the comparison. |
|
struct berval * |
Attribute value to use in the comparison. |
The following parameters allow you to access information about the client connection through the parameter block.
Table 18–7 Connection Information Parameters
The following parameters allow you to access an entry to delete through the parameter block.
Table 18–8 Delete Function Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
char * |
DN of the entry to delete. |
|
char * |
Non-normalized DN of the entry to delete. |
The following parameters allow you to access information about configuration of the directory instance through the parameter block.
Table 18–9 Directory Configuration Information Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
int |
Number of command-line arguments passed to the server at startup. |
|
char ** |
Array of command-line arguments passed to the server at startup. |
|
char * |
File system directory containing configuration files for the instance. |
|
char * |
Configuration file used, such as dse.ldif. |
The following parameters allow you to access information about an extended operation through the parameter block.
Table 18–10 Extended Operation Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
char * |
Object identifier (OID) of the extended operation specified in the request. |
|
struct berval * |
Value specified in the request. |
|
char * |
Object identifier (OID) to return to the client. |
|
struct berval * |
Value to send to the client. |
The following parameters allow you to access information about internal operations through the parameter block.
Table 18–11 Internal Operation Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
int |
Result code of internal operation. |
|
Slapi_Entry ** |
Array of entries found by internal search. |
|
char ** |
Array of referrals found by internal search in LDAP URL format. |
The following parameters allow you to access an entry to modify through the parameter block.
Table 18–12 Modify Function Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
LDAPMod ** |
NULL terminated array of LDAPMod structures containing modifications to perform on the target entry. |
|
char * |
DN of the entry to modify. |
|
char * |
Non-normalized DN of the entry to modify. |
The following parameters allow you to access information about the current operation through the parameter block.
Table 18–13 Operation Information Parameters
The following parameters are for use when registering plug-ins and their functions with the server and when accessing information about plug-in type and identity.
The following table lists information accessible to all types of plug-ins.
Table 18–14 Plug-In Information Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
void * |
Internal server representation of the plug-in. |
|
int |
Number of arguments in the configuration entry. |
|
char * |
Array of arguments in the configuration entry. |
|
void * |
Plug-in identifier set and then required by the server when handling internal operations. You may cast this to Slapi_ComponentId. |
|
void * |
Private data you pass to your plug-in functions. You define this data structure. |
|
int |
Type of plug-in function, corresponding to the value of nsslapd-pluginType in the configuration entry for the plug-in. (Use the plug-in type values given here between parentheses in configuration entries.) |
|
char * |
Plug-in API version supported by the plug-in. |
Parameters for use with password check plug-ins follow.
Table 18–15 Password Verification Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
Slapi_Value ** |
Array of password values to check. |
|
void * |
Function called to check password values against quality criteria. For details, see What a Password Check Plug-In Must Do. |
Parameters for use with post-operation plug-ins follow. These parameters allow plug-ins to compare the state of an entry before an operation with the state of an entry after an operation.
Table 18–16 Post-Operation Entry Access Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
Slapi_Entry * |
Directory entry before the operation. |
|
Slapi_Entry * |
Directory entry after the operation. |
Parameters for registering generic plug-in functions follow. These function types may be registered by any plug-in.
Table 18–17 Generic Function Registration Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
void * |
Function called at server shutdown. |
|
void * |
Function called at server startup. May be called more than once. |
Parameters for registering an extendedop plug-in function and object identifier list follow.
Table 18–18 Extended Operation Registration Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
void * |
Function called upon request for an LDAP v3 extended operation. |
|
char ** |
NULL terminated list of object identifiers (OIDs) handled by the plug-in. |
Parameters for registering an internalpostoperation plug-in functions follow.
Table 18–19 Internal Postoperation Registration Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
void * |
Function called after an internal add operation completes. |
|
void * |
Function called after an internal delete operation completes. |
|
void * |
Function called after an internal modify operation completes. |
|
void * |
Function called after an internal rename (modify RDN) operation completes. |
Parameters for registering an internalpreoperation plug-in functions follow.
Table 18–20 Internal Preoperation Registration Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
void * |
Function called before an internal add operation is performed. |
|
void * |
Function called before an internal delete operation is performed. |
|
void * |
Function called before an internal modify operation is performed. |
|
void * |
Function called before an internal rename (modify RDN) operation is performed. |
Parameters for registering ldbmentryfetchstore plug-in functions follow.
Table 18–21 Entry Store/Fetch Function Registration Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
void * |
Function called upon retrieval of an entry from the backend. |
|
void * |
Function called before storing an entry through the backend. |
Parameters for registering matchingrule plug-in functions and arguments follow.
Table 18–22 Matching Rule Function and Argument Registration Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
- |
Used to signify registration of the matching rule description with slapi_matchingrule_set(). |
|
- |
Used to signify registration of the matching rule name with slapi_matchingrule_set(). |
|
- |
Used to signify the matching rule is obsolete when registering with slapi_matchingrule_set(). |
|
- |
Used to signify registration of the matching rule object identifier with slapi_matchingrule_set(). |
|
- |
Used to signify registration of the matching rule syntax with slapi_matchingrule_set(). |
|
void * |
Function called to free memory allocated to filter object. |
|
void * |
Filter factory function. |
|
void * |
Function called to set the indexer function. |
|
void * |
Function called to check for a match. |
|
void * |
Function called to reset the match filter. |
|
unsigned int |
Whether the filter is reusable.
|
|
void * |
Index factory function. |
|
void * |
Function called to index a single entry. |
|
struct berval ** |
Array of index keys corresponding to the attribute values. |
|
char * |
Object identifier (OID) corresponding to the extensible match rule. |
|
int |
Type of operator used to check for matches. SLAPI_OP_EQUAL SLAPI_OP_GREATER SLAPI_OP_GREATER_OR_EQUAL SLAPI_OP_LESS SLAPI_OP_LESS_OR_EQUAL SLAPI_OP_SUBSTRING |
|
char * |
Matching rule filter type. |
|
unsigned int |
Whether to use the rule to index or to sort. SLAPI_PLUGIN_MR_USAGE_INDEX SLAPI_PLUGIN_MR_USAGE_SORT |
|
struct berval * |
Attribute value to match. |
|
struct berval ** |
Array of attribute values to match. |
|
void * |
Filter object for extensible match. You define this data structure to use in a matching rule plug-in. |
Parameters for registering postoperation plug-in functions follow.
Table 18–23 Postoperation Function Registration Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
void * |
Function called after an operation is abandoned. |
|
void * |
Function called after an add operation completes. |
|
void * |
Function called after a bind operation completes. |
|
void * |
Function called after a compare operation completes. |
|
void * |
Function called after a delete operation completes. |
|
void * |
Function called after an entry is sent to the client. |
|
void * |
Function called after a modify operation completes. |
|
void * |
Function called after an rename (modify RDN) operation completes. |
|
void * |
Function called after a referral is sent to the client. |
|
void * |
Function called after a result is sent to the client. |
|
void * |
Function called after a search operation completes. For persistent search operations, this function is called after the client interrupts the search. |
|
void * |
Function called after an unbind operation completes. |
Parameters for registering preoperation plug-in functions follow.
Table 18–24 Preoperation Function Registration Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
void * |
Function called before an operation is abandoned. |
|
void * |
Function called before an add operation is performed. |
|
void * |
Function called before a bind operation is performed. |
|
void * |
Function called before a compare operation is performed. |
|
void * |
Function called before an delete operation is performed. |
|
void * |
Function called before an entry is sent to the client. |
|
void * |
Function called before a modify operation is performed. |
|
void * |
Function called before an rename (modify RDN) operation is performed. |
|
void * |
Function called before a referral is sent to the client. |
|
void * |
Function called before a result is sent to the client. |
|
void * |
Function called before a search operation is performed. |
|
void * |
Function called before an unbind operation is performed. |
Parameters for registering pwdstorage and reverpwdstorage plug-in functions follow.
Table 18–25 Password Storage Function Registration Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
void * |
Function called to encode a password for comparison with a stored, encoded password. |
|
char * |
Stored, encoded user password. |
|
void * |
(reverpwdstorage plug-ins only) Function called to decode an encrypted password. |
|
void * |
Function called to encode a password for storage. |
|
char * |
Short password storage scheme name used by the server to identify the encoding scheme. |
|
char * |
User password in clear text. |
The following parameters allow you to access an entry to rename through the parameter block.
Table 18–26 Rename (Modify RDN) Function Parameters
The following parameters allow you to access results through the parameter block.
Table 18–27 Result Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
LDAPControl * |
Lets you add a control to the set of controls to send to the client. Use slapi_pblock_set() to add a control with this parameter. |
|
LDAPControl ** |
Array of controls to send to client. If you use this with slapi_pblock_set() to change the set of controls to send to the client, you must retrieve and free the existing set of controls pointed to by SLAPI_RES_CONTROLS. |
|
int |
Result code to send to client. |
|
char * |
Portion of target DN that matched when sending LDAP_NO_SUCH_OBJECT to the client. |
|
char * |
Message to send to client. |
The following parameters allow you to access search parameters through the parameter block.
Table 18–28 Search Function Parameters
Parameter ID |
Data Type |
Description |
---|---|---|
int |
Number of entries returned by the search. |
|
char ** |
Array of attribute types to return in the search results. The asterisk, *, can be used to mean all real (non-virtual) attributes. |
|
int |
Whether to return both attribute types and attribute values.
|
|
int |
Method for handling aliases. |
|
Slapi_Filter * |
Filter to be used for the search. |
|
struct berval ** |
Array of URLs to other LDAP servers to which the client is referred. |
|
void * |
Entry returned while iterating through the result set. You may cast this to Slapi_Entry. |
|
int |
Scope of the search. |
|
int |
Maximum number of entries to return in the search results. |
|
char * |
String representation of the filter to be used for the search. |
|
char * |
DN of base entry for the search. |
|
int |
Maximum number of seconds to allow for the search. |