我怎样才能知道我的 Activity 目录的所有属性?
我看到了类似“ou=People”的示例,但我不知道如何访问我公司中特定的名称“People”。我没有 LDAP 的访问权限(或者我不知道如何访问),所以我不知道我应该输入什么。
DirContext ctx = null;
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://"+serverAddress+":389");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, DOMAIN+username);
env.put(Context.SECURITY_CREDENTIALS, password);
try {
ctx = new InitialDirContext(env);
Attributes matchAttrs = new BasicAttributes(true); // ignore attribute name case
matchAttrs.put(new BasicAttribute("mail", "XXXXXX@XXXX.com"));
Attributes attrs = ctx.getAttributes("");
// Search for objects that have those matching attributes
NamingEnumeration<SearchResult> answer = ctx.search("ou=Users", matchAttrs);
while (answer.hasMore()) {
SearchResult sr = (SearchResult)answer.next();
System.out.println(">>>" + sr.getName());
}
我遇到错误:无法绑定(bind)到 LDAP [LDAP:错误代码 1 - 000020D6:SvcErr:DSID-03100754,问题 5012 (DIR_ERROR),数据 0 剩余名称 'ou=Users'
我如何知道公司在ou=....
之后使用哪个名称
非常感谢!
最佳答案
您可以使用 LDAP 浏览器来浏览 LDAP。 (我一般用softerra Ldap管理员) 您需要连接的所有信息都在代码的第一行内(地址、端口等...)
关于java - LDAP+ Java : How can I know my active directory's names,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15075125/