我有一段代码,在绑定(bind)操作后在事件目录服务器上执行搜索。我使用 LDAP 协议(protocol)进行绑定(bind),我的代码如下所示:
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "none");
env.put("com.sun.jndi.ldap.read.timeout", "9000");
env.put("com.sun.jndi.ldap.connect.timeout", "9000");
env.put(Context.PROVIDER_URL, "ldap://" + "nec.jp");
DirContext ctx = new InitialDirContext(env);
NamingEnumeration<SearchResult> answer = ctx.search(
searchBase, searchFilter, searchCtls);
if (answer.hasMore())
{
env.put(Context.SECURITY_PRINCIPAL, principalNameres);
env.put(Context.SECURITY_CREDENTIALS, userPasswd);
env.put(Context.SECURITY_AUTHENTICATION, "simple");
final DirContext ctxForSerachedResult = new InitialDirContext(
env);
ctxForSerachedResult.close();
}
我的问题是配置 AD 服务器以使用匿名登录用户执行搜索。
根据目前的理解,可以通过执行以下显示的步骤来启用匿名:
a.通过更改 DsHeuristics 属性值启用匿名 LDAP 操作。
b.提供读取目录的权限。
引用链接:
- http://social.technet.microsoft.com/Forums/en/winserverDS/thread/524a77fb-e819-497e-ae8a-c0fc43f1bba8
- http://support.microsoft.com/kb/326690
我尝试使用 LDP.exe 匿名登录绑定(bind)来批准 Active Directory 设置成功,如下图所示:
但是搜索操作仍然无法按预期工作。
请指出我哪里出错了。
最佳答案
关于active-directory - 使用匿名绑定(bind)进行事件目录搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14208540/