Plug-in Programmer’s Guide Red Hat Directory Server |
Previous |
Contents |
Index |
Next |
Chapter 14
Data Type and Structure Reference
This chapter summarizes the data types and structures that you can use when writing Red Hat Directory Server (Directory Server) plug-in functions.
Summary of Data Types and Structures
The functions in the server plug-in API use the following data types and structures:
berval
Represents binary data that is encoded using simplified Basic Encoding Rules (BER).
Syntax
typedef struct berval { unsigned long bv_len; char *bv_val; }BerValue;Parameters
This function has the following parameters:
Description
The berval data structure represents binary data that is encoded using simplified Basic Encoding Rules (BER). The data and size of the data are included in a berval structure.
Use a berval structure when working with attributes that contain binary data (such as a JPEG or audio file).
computed_attr_context
Represents information used for a computed attribute.
Syntax
typedef struct _computed_attr_context computed_attr_context;Description
computed_attr_context is the data type for an opaque structure that represents information about a computed attribute.
Before the Directory Server sends an entry back to a client, it determines if any of the attributes are computed, generates the attributes, and includes the generated attributes in the entry.
As part of this process, the server creates a computed_attr_context structure to pass relevant information to the functions generating the attribute values. Relevant information might include the attribute type, the BER-encoded request so far, and the parameter block.
LDAPControl
Represents a client or server control associated with an LDAP operation.
Syntax
typedef struct ldapcontrol { char *ldctl_oid; struct berval ldctl_value; char ldctl_iscritical; } LDAPControl;Parameters
This function has the following parameters:
Description
The LDAPControl data type represents a client or server control associated with an LDAP operation. Controls are part of the LDAPv3 protocol. You can use a client or server control to extend the functionality of an LDAP control.
For example, you can use a server control to specify that you want the server to sort search results in an LDAP search operation.
The following table summarizes the front-end API functions that you can call to work with LDAP controls.
LDAPMod
Specifies changes to an attribute in an directory entry.
Syntax
typedef struct ldapmod { int mod_op; char *mod_type; union mod_vals_u{ char **modv_strvals; struct berval **modv_bvals; } mod_vals; #define mod_values mod_vals.modv_strvals #define mod_bvalues mod_vals.modv_bvals } LDAPMod;Parameters
This function has the following parameters:
Description
LDAPMod is a type of structure that you use to specify changes to an attribute in an directory entry. Before you call the slapi_add_internal_pb() and slapi_modify_internal_pb() routines to add or modify an entry in the directory, you need to fill LDAPMod structures with the attribute values that you intend to add or change.
The following section of code sets up an LDAPMod structure to change the email address of a user's entry to [email protected]:
The following table summarizes the front-end API functions that you can call to specify changes to an attribute in an directory entry.
See Also
Slapi_Mod and Slapi_Mods.
mrFilterMatchFn
Specifies the prototype for a filter matching callback function.
Syntax
#include "slapi-plugin.h" typedef int (*mrFilterMatchFn) (void* filter, Slapi_Entry* entry, Slapi_Attr* attrs);Parameters
This function has the following parameters:
filter Pointer to the filter structure created by your filter factory function. (For details, see "Writing a Filter Factory Function," on page 145.) entry Pointer to the Slapi_Entry structure representing the candidate entry being checked by the server. attrs Pointer to the Slapi_Attr structure representing the first attribute in the entry. To iterate through the rest of the attributes in the entry, call slapi_entry_next_attr().
Returns
This function returns an integer value of 0 if the filter is matched or -1 if the filter did not match. If an LDAP error occurs, it returns a value >0.
Description
mrFilterMatchFn specifies the prototype for a filter matching function that is called by the server when processing an extensible match filter.
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 might find all entries that sound like a given value.
To handle an extensible match filter for a matching rule, you can write a matching rule plug-in.
You need to define the filter matching function, which is the function that has prototype specified by mrFilterMatchFn. The server calls this function for each potential matching candidate entry. The server passes pointers to a filter structure that you create in your filter factory function (see "Writing a Filter Factory Function"), the candidate entry, and the entry's attributes.
In your filter matching function, you can retrieve information about the filter, such as the attribute type and value specified in the filter, from the filter structure. You can then use this information to compare the value in the filter against the attribute values in the candidate entry.
For more information on writing a filter matching function, see "Writing a Filter Factory Function."
plugin_referral_entry_callback
This typedef is used for LDAP referral entry callback functions, which are plugin-defined functions that process LDAP references generated by some internal searches.
Syntax
#include "slapi-plugin.h" typedef int (*plugin_referral_entry_callback) (char *referral, void *callback_data);Parameters
The function takes the following parameters:
Returns
0 if successful or -1 if an error occurred.
Description
A function that matches this typedef can be passed as the prec parameter of slapi_search_internal_callback_pb(), or as the ref_callback parameter of the slapi_seq_internal_callback_pb() function.
The LDAP referral entry callback function will be called once for each referral entry found by a search operation, which means it could be called zero or any number of times.
The callback_data parameter can be used to pass arbitrary plug-in or operation-specific information to a referral entry callback function.
plugin_result_callback
This typedef is used for LDAP result callback functions, which are plugin-defined functions that process result messages that are generated by some internal search functions.
Syntax
#include "slapi-plugin.h" typedef void (*plugin_result_callback)(int rc, void *callback_data);Parameters
The function takes the following parameters:
rc The LDAP result code of the internal operation; for example, LDAP_SUCCESS. callback_data This value matches the callback_data pointer that was passed to the original internal operation function.
Returns
0 if successful or -1 if an error occurred.
Description
A function that matches this typedef can be passed as the prc parameter of slapi_search_internal_callback_pb() or as the res_callback parameter of slapi_seq_internal_callback_pb().
The LDAP result callback function should be called once for each search operation, unless the search is abandoned, in which case it will not be called.
The callback_data parameter can be used to pass arbitrary plug-in or operation-specific information to a result callback function.
plugin_search_entry_callback
This typedef is used for LDAP search entry callback functions, which are plug-in defined functions that process LDAP entries that are located by an internal search.
Syntax
#include "slapi-plugin.h" typedef int (*plugin_search_entry_callback)(Slapi_Entry *e, void *callback_data);Parameters
The function has the following parameters:
Returns
0 if successful or -1 if an error occurred.
Description
A function that matches this typedef can be passed as the psec parameter of slapi_search_internal_callback_pb() or as the srch_callback parameter of slapi_seq_internal_callback_pb().
The LDAP referral entry callback function will be called once for each referral entry found by a search operation, which means it could be called zero or any number of times.
The callback_data parameter can be used to pass arbitrary plug-in or operation-specific information to a referral entry callback function.
send_ldap_referral_fn_ptr_t
send_ldap_referral_fn_ptr_t specifies the prototype for a callback function that you can write to send LDAPv3 referrals (search result references) back to the client. You can register your function so that it is called whenever the slapi_send_ldap_result() function is called.
Syntax
#include "slapi-plugin.h" typedef int (*send_ldap_referral_fn_ptr_t)( Slapi_PBlock *pb, Slapi_Entry *e, struct berval **refs, struct berval ***urls);Parameters
The function has the following parameters:
Returns
0 if successful, or -1 if an error occurs.
Description
The slapi_send_ldap_result()function is responsible for sending LDAPv3 referrals (search result references) back to the client. You can replace the function that sends LDAPv3 referrals to the client with your own function. To do this:
- Write a function with the prototype specified by send_ldap_result_fn_ptr_t.
- In your plug-in initialization function, register your function by setting the SLAPI_PLUGIN_PRE_REFERRAL_FN parameter in the parameter block to the name of your function if you are using the pre-operation plug-in. If you are using the post-operation plug-in, register your function by setting the SLAPI_PLUGIN_POST_REFERRAL_FN parameter in the parameter block to the name of your function.
See slapi_send_ldap_result() for information on the default function that sends LDAPv3 referrals to clients.
See Also
send_ldap_result_fn_ptr_t
send_ldap_result_fn_ptr_t specifies the prototype for a callback function that you can write to send LDAP result codes back to the client. You can register your function so that it is called whenever the slapi_send_ldap_result() function is called.
Syntax
#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 );Parameters
The function has the following parameters:
Description
The slapi_send_ldap_result() function is responsible for sending LDAP result codes back to the client. You can replace the function that sends LDAP result codes to the client with your own function. To do this:
- Write a function with the prototype specified by send_ldap_result_fn_ptr_t.
- In your plug-in initialization function, register your function for sending results to the client by setting the SLAPI_PLUGIN_PRE_RESULT_FN or SLAPI_PLUGIN_POST_RESULT_FN parameter, depending on the type of plug-in and if it is a pre-operation or post-operation, respectively, in the parameter block to the name of your function.
See slapi_send_ldap_result() for information on the default function that sends LDAP result codes to clients.
See Also
send_ldap_search_entry_fn_ptr_t
send_ldap_result_fn_ptr_t specifies the prototype for a callback function that you can write to send search results (entries found by a search) back to the client. You can register your function so that it is called whenever the slapi_send_ldap_search_entry() function is called.
Syntax
#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 );Description
The slapi_send_ldap_search_entry() function is responsible for sending entries found by a search back to the client. You can replace the function that sends entries to the client with your own function. To do this:
- Write a function with the prototype specified by send_ldap_search_entry_fn_ptr_t.
- In your plug-in initialization function, register your function by setting the SLAPI_PLUGIN_PRE_ENTRY_FN parameter in the parameter block to the name of your function if you are using the pre-operation plug-in. If you are using the post-operation plug-in, register your function by setting the SLAPI_PLUGIN_POST_ENTRY_FN parameter in the parameter block to the name of your function.
See slapi_send_ldap_search_entry() for information on the default function that sends entries to clients.
See Also
slapi_send_ldap_search_entry()
Slapi_Attr
Represents an attribute in an entry.
Syntax
#include "slapi-plugin.h" typedef struct slapi_attr Slapi_Attr;Description
Slapi_Attr is the data type for an opaque structure that represents an attribute in a directory entry. In certain cases, your server plug-in may need to work with an entry's attributes.
The following table summarizes the front-end API functions that you can call to work with attributes.
See Also
Slapi_Backend
Represents a backend operation in the server plug-in-in.
Syntax
#include "slapi-plugin.h" typedef struct backend Slapi_Backend;Description
Slapi_Backend is the data type for an opaque structure that represents a backend operation.
The following table summarizes the front-end API functions that you can call to work with the backend operations.
slapi_backend_state_change_fnptr
slapi_backend_state_change_fnptr specifies the prototype for a callback function, which allows a plug-in to register for callback when a backend state changes.
Syntax
#include "slapi-plugin.h" typedef void (*slapi_backend_state_change_fnptr)(void *handle, char *be_name, int old_be_state, int new_be_state);Parameters
The function has the following parameters:
handle Pointer or reference to the address of the specified function. be_name Name of the backend. old_be_state Old backend state. new_be_state New backend state.
Description
The slapi_register_backend_state_change() function enables a plug-in to register for callback when the state of a backend changes. You may need to keep track of backend state changes when writing custom plug-ins.
See Also
slapi_register_backend_state_change() slapi_unregister_backend_state_change()Slapi_ComponentID
Represents a the component ID in a directory entry.
Syntax
#include "slapi-plugin.h" typedef struct slapi_componentid Slapi_ComponentId;Description
Slapi_ComponentId is the data type for an opaque structure that represents a the component ID in a directory entry.
slapi_compute_callback_t
Represents a callback for evaluating computed attributes.
Syntax
#include "slapi-plugin.h" typedef int (*slapi_compute_callback_t) (computed_attr_context *c, char* type, Slapi_Entry *e, slapi_compute_output_t outputfn);Parameters
The function has the following parameters:
Returns
- -1 if the function is not responsible for generating the computed attribute.
- 0 if the function successfully generates the computed attribute.
- An LDAP error code if an error occurred.
Description
slapi_compute_callback_t specifies the prototype for a callback function that is called by the server when generating a computed attribute. If you want to use computed attributes, you should write a function of this type.
See Also
slapi_compute_output_t
Represents a prototype for an output function for contributed attributes.
Syntax
#include "slapi-plugin.h" typedef int (*slapi_compute_output_t) (computed_attr_context *c, Slapi_Attr *a, Slapi_Entry *e);Parameters
The function has the following parameters:
Returns
- 0 if the function successfully BER-encodes the computed attribute and adds it to the BER element to be sent to the client.
- An LDAP error code if an error occurred.
Description
slapi_compute_output_t specifies the prototype for a callback function that BER-encodes a computed attribute and appends it to the BER element to be sent to the client.
You do not need to define a function of this type. The server will pass a function of this type your slapi_compute_callback_t function. In your slapi_compute_callback_t function, you need to call this slapi_compute_output_t function.
static int my_compute_callback(computed_attr_context *c, char* type, Slapi_Entry *e, slapi_compute_output_t outputfn) { ... int rc; Slapi_Attr my_computed_attr; ... /* Call the output function after created the computed attribute and setting its values. */ rc = (*outputfn) (c, &my_computed_attr, e); ... }In the example above, the slapi_compute_output_t function outputfn is passed in as an argument to my_compute_callback function. After generating the computed attribute, you need to call outputfn, passing it the context, the newly created attribute, and the entry. outputfn BER-encodes the attribute and appends it to the BER element to be sent to the client.
You do not need to define outputfn yourself. You just need to call the function passed in as the last statement from the callback.
See Also
Slapi_Connection
Syntax
#include "slapi-plugin.h" typedef struct conn Slapi_Connection;Description
Slapi_Connection is the data type for an opaque structure that represents a connection.
Slapi_CondVar
Represents a condition variable in a directory entry.
Syntax
#include "slapi-plugin.h" typedef struct slapi_condvar Slapi_CondVar;Description
Slapi_CondVar is the data type for an opaque structure that represents a synchronization lock in the server plug-in.
The following table summarizes the front-end API functions that you can call to modify synchronization locks in the server plug-in.
To ... ... Call this function Destroy a condition variable. Create a new condition variable. Send notification about a condition variable. Wait for a condition variable.
Slapi_DN
Represents a distinguished name in a directory entry.
Syntax
#include "slapi-plugin.h" typedef struct slapi_dn Slapi_DN;Description
Slapi_DN is the data type for an opaque structure that represents a distinguished name in the server plug-in.
The following table summarizes the front-end API functions that you can call to work with distinguished names.
See Also
Slapi_Entry
Represents an entry in the directory.
Syntax
#include "slapi-plugin.h" typedef struct slapi_entry Slapi_Entry;Description
Slapi_Entry is the data type for an opaque structure that represents an entry in the directory. In certain cases, your server plug-in may need to work with an entry in the directory.
The following table summarizes the front-end API functions that you can call to work with entries.
See Also
Slapi_Filter
Syntax
#include "slapi-plugin.h" typedef struct slapi_filter Slapi_Filter;Description
Slapi_Filter is the data type for an opaque structure that represents an search filter. (For more information on search filters, see "Working with Search Filters," on page 74.)
The following table summarizes the front-end API functions that you can call to work with filters.
Slapi_MatchingRuleEntry
Syntax
#include "slapi-plugin.h" typedef struct slapi_matchingRuleEntry Slapi_MatchingRuleEntry;Description
Slapi_MatchingRuleEntry is the data type for an opaque structure that represents a matching rule.
The following table summarizes the front-end API functions that you can call to work with matching rules.
Slapi_Mod
Represents a single LDAP modification to a directory entry.
Syntax
#include "slapi-plugin.h" typedef struct slapi_mod Slapi_Mod;Description
Slapi_Mod is the data type for an opaque structure that represents LDAPMod modifications to an attribute in a directory entry.
The following table summarizes the front-end API functions that you can call to manipulate directory entries.
See Also
LDAPMod and Slapi_Mods
Slapi_Mods
Represents two or more LDAP modifications to a directory entry
Syntax
#include "slapi-plugin.h" typedef struct slapi_mods Slapi_Mods;Description
Slapi_Mods is the data type for an opaque structure that represents LDAPMod manipulations that can be made to a directory entry.
The following table summarizes the front-end API functions that you can call to manipulate directory entries.
See Also
Slapi_Mutex
Represents a mutually exclusive lock in the server plug-in.
Syntax
#include "slapi-plugin.h" typedef struct slapi_mutex Slapi_Mutex;Description
Slapi_Mutex is the data type for an opaque structure that represents a mutual exclusive lock (mutex) in the server plug-in.
The following table summarizes the front-end API functions that you can call to work with mutually exclusive locks.
Slapi_Operation
Represents an operation pending from an LDAP client.
Syntax
#include "slapi-plugin.h" typedef struct op Slapi_Operation;Description
Slapi_Operation is the data type for an opaque structure that represents an operation pending from an LDAP client.
The following table summarizes the front-end API functions that you can call to work with mutually exclusive locks.
To ... ... Call this function Determine if the client has abandoned the current operation. Get the type of a Slapi_Operation.
Slapi_PBlock
Contains name-value pairs, known as parameter blocks, that you can get or set for each LDAP operation.
Syntax
#include "slapi-plugin.h" typedef struct slapi_pblock Slapi_PBlock;Description
Slapi_PBlock contains name-value pairs that you can use to retrieve information from the server and set information to be used by the server.
For most types of plug-in functions, the server passes in a Slapi_PBlock structure that typically includes data relevant to the operation being processed. You can get the value of a parameter by calling the slapi_pblock_get() function.
For example, when the plug-in function for an LDAP bind operation is called, the server puts the DN and credentials in the SLAPI_BIND_TARGET and SLAPI_BIND_CREDENTIALS parameters of the Slapi_PBlock structure. You can call slapi_pblock_get() to get the DN and credentials of the client requesting authentication.
For plug-in initialization functions, you can use the Slapi_PBlock structure to pass information to the server, such as the description of your plug-in and the names of your plug-in functions. You can set the value of a parameter by calling the slapi_pblock_set() function.
For example, in order to register a pre-operation bind plug-in function, you need to call slapi_pblock_set() to set the version number, description, and name of the plug-in function as the SLAPI_PLUGIN_VERSION, SLAPI_PLUGIN_DESCRIPTION, and SLAPI_PLUGIN_PRE_BIND_FN parameters.
The available parameters that you can use depends on the type of plug-in function you are writing.
The following table summarizes the front-end API functions that you can call to work with block parameters.
Slapi_PluginDesc
Represents information about a server plug-in.
Syntax
typedef struct slapi_plugindesc { char *spd_id; char *spd_vendor; char *spd_version; char *spd_description; } Slapi_PluginDesc;Parameters
The function has the following parameters:
Description
Slapi_PluginDesc represents information about a server plug-in. In your initialization function, you specify information about your plug-in in this structure and call slapi_pblock_set() to put the structure in the SLAPI_PLUGIN_DESCRIPTION parameter.
See Also
For more information on using Slapi_PluginDesc to specify plug-in information, see "Specifying Information about the Plug-in," on page 43.
Slapi_RDN
Represents a relative distinguished name in a directory entry.
Syntax
#include "slapi-plugin.h" typedef struct slapi_rdn Slapi_RDN;Description
Slapi_RDN is the data type for an opaque structure that represents a relative distinguished name in the server plug-in.
The following table summarizes the front-end API functions that you can call to work with relative distinguished names.
Slapi_UniqueID
Represents the unique identifier of a directory entry.
Syntax
#include "slapi-plugin.h" typedef struct _guid_t Slapi_UniqueID;Description
Slapi_UniqueID is the data type for an opaque structure that represents the unique identifier of a directory entry. All directory entries contain a unique identifier. Unlike the distinguished name (DN), the unique identifier of an entry never changes, providing a good way to refer unambiguously to an entry in a distributed/replicated environment.
Slapi_Value
Represents the value of the attribute in a directory entry.
Syntax
#include "slapi-plugin.h" typedef struct slapi_value Slapi_Value;Description
Slapi_Value is the data type for an opaque structure that represents the value of an attribute in a directory entry.
The following table summarizes the front-end API functions that you can call to work with directory entry values.
See Also
Slapi_ValueSet
Represents a set of Slapi_Value (or a list of Slapi_Value).
Syntax
#include "slapi-plugin.h" typedef struct slapi_value_set Slapi_ValueSet;Description
Slapi_ValueSet is the data type for an opaque structure that represents set of Slapi_Value (or a list of Slapi_Value).
The following table summarizes the front-end API functions that you can call to work with sets of Slapi_Value.
See Also
Previous |
Contents |
Index |
Next |