从我的活动目录服务器获取名称时,我总是收到错误消息。错误如下:
javax.naming.InvalidNameException: Invalid name: "CN=»OGMA Serviço LAN/WAN",cn=Recipients,cn=Users,,dc=intra
谷歌搜索了一下,我发现了以下信息
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4307193 http://docs.oracle.com/javase/jndi/tutorial/beyond/names/syntax.html
如您所见,我尝试了解析器方法和复合名称方法,但错误仍然存在!我错过了什么?
这是我执行这些操作的代码:
DirContext ctx = new InitialDirContext( (Hashtable<String,String>) env);
Name n2 = new CompositeName().add(usersContainer);
NamingEnumeration contentsEnum = ctx.list(n2);
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);
变量name
是"CN=»OGMA Serviço LAN/WAN" + cn=Recipients,cn=Users,,dc=intra