File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes JNDI, LDAP,  renaming to different part of namespace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "JNDI, LDAP,  renaming to different part of namespace" Watch "JNDI, LDAP,  renaming to different part of namespace" New topic
Author

JNDI, LDAP, renaming to different part of namespace

Igor Styrman
Greenhorn

Joined: May 15, 2002
Posts: 1
Hi,
Running following code to rename entries:
******************************************************************************
Hashtable hashtableEnvironment = new Hashtable();
hashtableEnvironment.put(
Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory"
);
hashtableEnvironment.put(
Context.PROVIDER_URL, "ldap://ip ort"
);
Hashtable env;
//read parameters from properties file
readParameters();
env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,initialContextFactoryLDAP);
env.put(Context.PROVIDER_URL,providerUrlLDAP);
env.put(Context.SECURITY_PRINCIPAL,securityPrincipalLDAP);
env.put(Context.SECURITY_CREDENTIALS,securityCredentialsLDAP);
env.put("java.naming.ldap.version","3");
DirContext dirContext = new InitialDirContext(env);
String DNa = "o=testiPT, o=testiPT, o=testiRP, o=Juuri, l=Ammattilaiset, c=fi";
String DNb = "ou=testiPT, o=testiPT, o=testiRP, o=Juuri, l=Ammattilaiset, c=fi";
dirContext.rename(DNa, DNb);
dirContext.close();
******************************************************************************
Exception follows:
javax.naming.InvalidNameException: o=testiPT, o=testiPT, o=testiRP, o=Juuri, l=A
mmattilaiset, c=fi: [LDAP: error code 64 - Update Error: Naming Violation]; rema
ining name 'o=testiPT, o=testiPT, o=testiRP, o=Juuri, l=Ammattilaiset, c=fi'
at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.c_rename(Unknown Source)
at com.sun.jndi.toolkit.ctx.ComponentContext.p_rename(Unknown Source)
at com.sun.jndi.toolkit.ctx.PartialCompositeContext.rename(Unknown Sourc
e)
at com.sun.jndi.toolkit.ctx.PartialCompositeContext.rename(Unknown Sourc
e)
at javax.naming.InitialContext.rename(Unknown Source)
at LDAP.main(LDAP.java:64)
******************************************************************************
Renaming just the leaf name works fine, but changeing any node-type (= o --> ou) gives problems. Renaming middle-node also causes exception.
The LDAP server is providing both versions 2 and 3 simultaneusly. The admin tells me its ok and that there should be no problem with the server maybe being restricted to v2... Anyone had similar case? Any ideas would be appreciated.
Actually I can make this type of renaming work by binding the target and its sub-nodes to a new node of the same level, and then deleting the original.. But id be intrested to know if it ought to be possible to do this with the standard API?
Thanks,
Igor
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNDI, LDAP, renaming to different part of namespace