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);
}