{
//TODO: maybe perform a schema check if this attribute is not required on the LDAP level
IdentityObjectAttributeMetaData amd = mdMap.get(name);
if (amd != null && amd.isRequired())
{
throw new IdentityException("Cannot remove required attribute: " + name);
}
}
Attributes attrs = new BasicAttributes(true);
Attribute attr = new BasicAttribute(attributeName);
attrs.put(attr);
try
{
ldapContext.modifyAttributes(dn, DirContext.REMOVE_ATTRIBUTE, attrs);
}
catch (NamingException e)
{
throw new IdentityException("Cannot remove attribute", e);
}
}
}
finally
{
try
{
ldapContext.close();
}
catch (NamingException e)
{
throw new IdentityException("Failed to close LDAP connection", e);
}
}
}