LDAPMod is defined as follows:
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 The fields in this structure are described below:
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
mod_op
mod->mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES
mod_type
mod_values
mod_bvalues
The following section of code sets up an LDAPMod structure to change the email address of a user's entry to "bab@ace.com":
Slapi_PBlock *rcpb; LDAPMod attribute1; LDAPMod *list_of_attrs[2]; char *mail_values[] = { "bab@ace.com", NULL }; char *dn; ... /* Identify the entry that you want changed */ dn = "cn=Barbara Jensen, ou=Product Development, o=Ace Industry, c=US"; /* Specify that you want to replace the value of an attribute */ attribute1.mod_op = LDAP_MOD_REPLACE; /* Specify that you want to change the value of the mail attribute */ attribute1.mod_type = "mail"; /* Specify the new value of the mail attribute */ attribute1.mod_values = mail_values; /* Add the change to the list of attributes that you want changed */ list_of_attrs[0] = &attribute_change; list_of_attrs[1] = NULL; /* Update the entry with the change */ rcpb = slapi_modify_internal( dn, list_of_attrs, NULL, 1 ); ...
Slapi_PBlock *rcpb;
LDAPMod attribute1;
LDAPMod *list_of_attrs[2];
char *mail_values[] = { "bab@ace.com", NULL };
char *dn;
...
/* Identify the entry that you want changed */
dn = "cn=Barbara Jensen, ou=Product Development, o=Ace Industry, c=US";
/* Specify that you want to replace the value of an attribute */
attribute1.mod_op = LDAP_MOD_REPLACE;
/* Specify that you want to change the value of the mail attribute */
attribute1.mod_type = "mail";
/* Specify the new value of the mail attribute */
attribute1.mod_values = mail_values;
/* Add the change to the list of attributes that you want changed */
list_of_attrs[0] = &attribute_change;
list_of_attrs[1] = NULL;
/* Update the entry with the change */
rcpb = slapi_modify_internal( dn, list_of_attrs, NULL, 1 );