Modify a person entry

To modify a person entity, we must create a list of modification items and then call modifyAttributes on the context.

Ensure that we have initialized the context.

To modify the attribute values for a person (including adding new attributes, or deleting existing ones), complete these steps.

  1. Define the DN of the person to modify.

  2. Create a list of ModificationItems containing the required changes.
  3. Call modifyAttributes on the context.

After defining the DN of the person, a call to modifyAttributes is made with the JNDI context.


Example

Vector mods = new Vector(); 
// Add a new attribute (or additional value ifit already exists) 
mods.add(new ModificationItem(DirContext.ADD_ATTRIBUTE, new BasicAttribute("roomnumber", "102"))); 
// Modify an existing Attribute
mods.add(new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("title","Consultant"))); 
// Modify an existing Attribute to a multi-valued value Attribute
newOuAt = new BasicAttribute("ou"); 
newOuAt.add("Research Department"); 
newOuAt.add("DevelopmentDivision"); 
mods.add(new ModificationItem(DirContext.REPLACE_ATTRIBUTE, newOuAt));
// Delete one existing attribute 
mods.add(new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("initials", null)));  
String dn = "uid=" + uid; 
damlContext.modifyAttributes(dn,(ModificationItem[])mods.toArray(new ModificationItem[mods.size()]));

We can do these tasks:

Parent topic: Event notifications of HR data