2
我想列出或搜索LDAP樹中的根環境。我使用Apache Directory Server和Java:列出LDAP中的根環境
Hashtable<String, String> contextParams = new Hashtable<String, String>();
contextParams.put("java.naming.provider.url", "ldap://localhost:10389");
contextParams.put("java.naming.security.principal", "uid=admin,ou=system");
contextParams.put("java.naming.security.credentials", "secret");
contextParams.put("java.naming.security.authentication", "simple");
contextParams.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
DirContext dirContext = new InitialDirContext(contextParams);
NamingEnumeration<NameClassPair> resultList;
//Works
resultList = dirContext.list("ou=system");
while (resultList.hasMore()) {
NameClassPair result = resultList.next();
System.out.println(result.getName());
}
//Does not work
resultList = dirContext.list("");
while (resultList.hasMore()) {
NameClassPair result = resultList.next();
System.out.println(result.getName());
}
我可以列出ou = system的子節點。但是我無法列出實際根節點的子節點。我想要這個列表就像Apache Directory Studio可以: alt text http://lesc.se/stackoverflow/ldap_root_contexts.png
謝謝!這是完美的! – 2010-04-11 10:57:06