2012-08-13 303 views
1

目前,我正在使用用户名和密码作为ldap的连接凭证(以便在本AD上进行搜索)。使用NTLM连接到LDAP(Active Directory)

我的代码如下所示:

env = new Hashtable(); 
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); 
env.put(Context.PROVIDER_URL, ...); 
env.put(Context.SECURITY_AUTHENTICATION, "simple"); 
env.put(Context.SECURITY_PRINCIPAL, ...); 
env.put(Context.SECURITY_CREDENTIALS, ...); 
env.put("com.sun.jndi.ldap.connect.timeout", ...); 

try { 
    ctx = new InitialLdapContext(env, null); 
} 
catch (NamingException e) { 
    System.out.println("error") 
} 

我想改变这个代码,因此它不会使用用户+密码作为对LDAP的凭据。我希望它使用NTLM进行身份验证。

我该怎么办?你能提供一个例子吗?

+0

你试过jcifs吗? – 2012-08-13 13:26:24

回答

0

没有机会,JGSS不支持NTLM作为SASL机制。使用Kerberos(GSS-API)和SASL。

+0

你能解释一下吗? – Matan 2012-08-13 10:12:17

+0

在这里阅读我的答案:http://stackoverflow.com/a/7786225/696632 – 2012-08-13 10:27:12

+0

试过它没有运气。你可以请回答我的问题:http://stackoverflow.com/questions/12025998/javax-naming-authenticationexception?谢谢! – Matan 2012-08-19 11:54:07