Compartir a través de


Modifying a Directory Entry (Windows CE 5.0)

Send Feedback

You can use the LDAP API to add and delete directory entries and to compare and modify values within existing entries. Any of these operations can be done either synchronously or asynchronously. LDAP version 3.0 supports extensions to the add, delete, and modify operations that allow you to perform these operations using controls.

To make a change to a directory, you need to first create an LDAPMod structure and then assign the appropriate values to each member of the structure. For multiple changes, or to add an entry, you need to create a separate LDAPMod structure for each attribute or change. When you call the modification function, you will pass these structures as an array.

The following code example shows how to create LDAPMod structures for a new entry with four initial attributes and then constructs an array of these structures to pass to ldap_add (the asynchronous add function).

#include <winldap.h>
LDAPMod Name;
ULONG CallValue;

//Specify a distinguished name for the entry:
char *entry_dn = "cn = Kate Wheeler, ou = IST, ou = PNS, o = USSA, c = US"

//Note that you can specify multiple values for the cn attribute
char *cn_values[] = { "Kathleen Wheeler" "Kate Wheeler", NULL };

//attributes are Name, USSNum, and Team
Name.mod_op = LDAP_MOD_ADD;
Name.mod_type = "cn";
Name.mod_values = cn_values;. 
LDAPMod USSNum;
char *cis_values[] = { "PN8WKS121284", NULL };
USSNum.mod_op = LDAP_MOD_ADD;
USSNum.mod_type = "cis";
USSNum.mod_values = cis_values;. 
LDAPMod Team;
char *ou_values[] = { "IST", NULL };
Team.mod_op = LDAP_MOD_ADD;
Team.mod_type = "ou";
Team.mod_values = ou_values;
LDAPMod Division;
char *ou_values[] = { "PNS", NULL };
Division.mod_op = LDAP_MOD_ADD;
Division.mod_type = "ou";
Division.mod_values = ou_values;

//now build the array of attributes. 
LDAPMod *NewEntry[5];
NewEntry[0] = &Name;
NewEntry[1] = &USSNum;
NewEntry[2] = &Team;
NewEntry[3] = &Division;
NewEntry[4] = NULL;

//add the entry
CallValue = ldap_add( ld, entry_dn, NewEntry);

//can pass CallValue to ldap_result to check on the 
//status of the asynchronous operation. 

See Also

Using the LDAP API

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.