Complete Contents
Getting Started
Chapter 1 Understanding Server Plug-Ins
Chapter 2 Writing and Compiling Plug-Ins
Chapter 3 Calling the Front-End API Functions
Chapter 4 Quick Start
Chapter 5 Writing Database Plug-Ins
Chapter 6 Writing Pre/Post-Operation Plug-Ins
Chapter 7 Defining Functions for LDAP Operations
Chapter 8 Defining Functions for Database Operations
Chapter 9 Defining Functions for Authentication
Chapter 10 Writing Entry Store/Fetch Plug-Ins
Chapter 11 Writing Extended Operation Plug-Ins
Chapter 12 Writing Matching Rule Plug-Ins
Chapter 13 Data Type and Structure Reference
Chapter 14 Function Reference
Chapter 15 Parameter Reference
Glossary
Previous Next Contents Bookshelf Datatypes List



 LDAPMod
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() and slapi_modify_internal() 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.

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:
mod_op

The operation to be performed on the attribute and the type of data specified as the attribute values. This field can have one of the following values:
In addition, if you are specifying binary values (as opposed to strings), you should OR (|) LDAP_MOD_BVALUES with the operation type. For example:
mod->mod_op = LDAP_MOD_ADD | LDAP_MOD_BVALUES

mod_type

The attribute type that you want to add, delete, or replace.
mod_values

Pointer to a NULL-terminated array of string values for the attribute.
mod_bvalues

Pointer to a NULL-terminated array of berval structures for the attribute.

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

...

 

© Copyright 1998 Netscape Communications Corporation