// Field displayName is not mandatory. We need to handle situation when user deleted displayName, which had been set
// previously.
// We need to ask if current User has displayName set previously and if yes, it needs to be removed.
private void removeDisplayNameIfNeeded(AttributesManager am, User user) {
try {
Attribute attr = am.getAttribute(user.getUserName(), USER_DISPLAY_NAME);
if (attr != null) {
am.removeAttributes(user.getUserName(), new String[] { USER_DISPLAY_NAME });
}
} catch (Exception e) {
handleException("Cannot remove displayName attribute of user: " + user.getUserName() + "; ", e);