I am Trying to Change The Group Distinguished name using Java Naming Package but every Time i get the same error message
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, url);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, user);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put(Context.REFERRAL, "follow");
DirContext ctx = new InitialDirContext(env);
ModificationItem[] roleMods = new ModificationItem[]
{
new ModificationItem(DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("distinguishedName",DN2))
};
ctx.modifyAttributes(DN1,roleMods);
And Every time i get this error :
Exception in thread "main" javax.naming.directory.InvalidAttributeValueException: [LDAP: error code 19 - 000020B1: AtrErr: DSID-030F04A3, #1: 0: 000020B1: DSID-030F04A3, problem 1005 (CONSTRAINT_ATT_TYPE), data 0, Att 31 (distinguishedName)
Is it at all posibble to change DN if yes how should i do it ?
In general, renaming in LDAP is not a modification as the change applies to the DN (distinguished name). You more often find examples when you look for rename or the modify DN / modify RDN operation.
Here is an example how to do renames using the JNDI LDAP provider.
I hope this helps.