This discussion is archived
0 Replies Latest reply: Jun 14, 2012 4:44 AM by 937672 RSS

InvalidNameException

937672 Newbie
Currently Being Moderated
Hi everyone,

I'm always getting an error when getting a name from my active directory server.

The error is the following:

javax.naming.InvalidNameException: Invalid name: "CN=»OGMA Serviço LAN/WAN",cn=Recipients,cn=Users,,dc=intra

After googling a bit, I found the following information

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4307193
http://docs.oracle.com/javase/jndi/tutorial/beyond/names/syntax.html

As you can see, I tried both with the parser approach and the composite name approach, but the error continues!

What am I missing?

I know the problem comes from the quotes and the forward slash, but the solutions that were presented didn't work for me.

Here's my code that does those operations:
     DirContext ctx = new InitialDirContext( (Hashtable<String,String>) env);

               NamingEnumeration contentsEnum = ctx.list(usersContainer);

               String[] attName = {"cn"};


               while ( contentsEnum.hasNext() )
               {


                    NameClassPair ncp = (NameClassPair) contentsEnum.next();

                    NameParser ldapParser = ctx.getNameParser("");

                    String name = ncp.getName() + "," + usersContainer;
                    Name n = ldapParser.parse(name);

                    ctx.lookup(n);
}
Regards,
Nuno.

Edited by: Nuno Miguel Santos on 14/Jun/2012 4:43

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points