LdapIdentity identity = (LdapIdentity) getIdentityByName(ldapAccount, identityName, null); if (identity == null) throw AccountServiceException.NO_SUCH_IDENTITY(identityName);
if (identityName.equalsIgnoreCase(DEFAULT_IDENTITY_NAME)) {   Set<String> validAttrs = AttributeManager.getInstance().getAttrsInClass(AttributeClass.identity); for (String key : identityAttrs.keySet()) { if (!validAttrs.contains(key)) throw ServiceException.INVALID_REQUEST("unable to modify attr: "+key, null); } modifyAttrs(ldapAccount, identityAttrs); } else {
    public void modifyIdentity(Account account, String identityName, Map<String, Object> identityAttrs) throws ServiceException {        LdapAccount ldapAccount = (LdapAccount) (account instanceof LdapAccount ? account : getAccountById(account.getId()));        if (ldapAccount == null)             throw AccountServiceException.NO_SUCH_ACCOUNT(account.getName());        LdapIdentity identity = (LdapIdentity) getIdentityByName(ldapAccount, identityName, null);        if (identity == null)                throw AccountServiceException.NO_SUCH_IDENTITY(identityName);                   String name = (String) identityAttrs.get(A_zimbraPrefIdentityName);        boolean newName = (name != null && !name.equals(identityName));        if (newName) identityAttrs.remove(A_zimbraPrefIdentityName);                modifyAttrs(identity, identityAttrs, true);        if (newName) renameIdentity(ldapAccount, identity, name);    }