Chapter 21. Functions for Dealing with Controls

This chapter contains reference information on routines for dealing with controls.

Table 21.1. Routines for Dealing with Controls

Function Description
slapi_add_control_ext() Adds the specified control to the end of an array of controls.
slapi_add_controls() Appends all of an array of controls to an existing array of controls.
slapi_build_control() Creates an LDAPControl structure based on a BerElement, an OID, and a criticality flag.
slapi_build_control_from_berval() Creates an LDAPControl structure based on a struct berval, an OID, and a criticality flag.
slapi_control_present() Determines whether the specified object identification (OID) identifies a control that is present in a list of controls.
slapi_dup_control() Makes an allocated copy of an LDAPControl.
slapi_get_supported_controls_copy() Retrieves an allocated array of object identifiers (OIDs) representing the controls supported by the Directory Server.
slapi_register_supported_control() Registers the specified control with the server. This function associates the control with an object identification (OID).

21.1. slapi_add_control_ext()

This function specifies an LDAPControl, and then appends the control to the end of a specified array or creates a new array. For example:
slapi_add_control_ext(&ctrls, newctrl, 1);
An existing array is grown using slapi_ch_realloc(). Otherwise, a new array is created using slapi_ch_malloc().
Syntax

#include "slapi-plugin.h"
void slapi_add_control_ext(LDAPControl ***ctrlsp, LDAPControl *newctrl, int copy)

Parameters

This function takes the following parameters:

ctrlsp Pointer that will receive the specified LDAPControl. If ctrls is NULL, then the array is created using slapi_ch_malloc().
newctrl Pointer to the specified LDAPControl.
copy Sets whether the given control is copied. If the value is true (0), then the control in newctrl is copied. If the value is false (1), then the control in newctrl is used and owned by the array and must be freed using ldap_controls_free.
Returns

This function returns LDAP_SUCCESS (LDAP result code) if successful.

See Also