ArrayList<ModificationItem> modifications = new ArrayList<ModificationItem>();
// update displayName & description
if (!user.getFullName().equals(existingUser.getFullName()))
{
ModificationItem mod =
new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(ldapAttrMapping.userDisplayNameAttr,
user.getFullName()));
modifications.add(mod);
mod =
new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(ldapAttrMapping.ldapDescriptionAttr,
user.getFullName()));
modifications.add(mod);
}
// update account name
if (!user.getUserName().equals(existingUser.getUserName()))
{
ModificationItem mod =
new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(ldapAttrMapping.userUsernameAttr,
user.getUserName()));
modifications.add(mod);
}
// update last name
if (!user.getLastName().equals(existingUser.getLastName()))
{
ModificationItem mod =
new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(ldapAttrMapping.userLastNameAttr,
user.getLastName()));
modifications.add(mod);
}
// update first name
if (!user.getFirstName().equals(existingUser.getFirstName()))
{
ModificationItem mod =
new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(ldapAttrMapping.userFirstNameAttr,
user.getFirstName()));
modifications.add(mod);
}
// update email
if (!user.getEmail().equals(existingUser.getEmail()))
{
ModificationItem mod =
new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute(ldapAttrMapping.userMailAttr, user
.getEmail()));
modifications.add(mod);
}
ModificationItem[] mods = new ModificationItem[modifications.size()];
return modifications.toArray(mods);