Modifying a person entry
To modify a person entity,
you must create a list of modification
items and then call modifyAttributes
on the context.
Before you begin
Depending on how your system administrator customized your system, you might not have access to this task. To obtain access to this task or to have someone complete it for you, contact your system administrator.
Ensure that you have initialized the context.
About this task
To modify the attribute values for a person (including adding new attributes, or deleting existing ones), complete these steps:
Procedure
- Define the DN of the person you want to modify.
- Create a list of
ModificationItems
containing the required changes. - Call
modifyAttributes
on the context.
Results
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()]));
What to do next
You can do these tasks:
- Add person entry
- Remove a person entry