【发布时间】:2015-11-19 09:25:29
【问题描述】:
请问如何在我的 Windows Server 2012 活动目录上为 Digest MD5 设置身份验证,以允许客户端对服务器进行身份验证。这是我用来建立从客户端到服务器的连接的代码。
Hashtable env = new Hashtable()
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory")
env.put(Context.SECURITY_AUTHENTICATION,"DIGEST-MD5 CRAM-MD5")
env.put(Context.SECURITY_PROTOCOL,"ssl")
env.put(Context.PROVIDER_URL,"ldap://test.com:636/") //The Window Server Address
env.put(Context.SECURITY_PRINCIPAL,"CN=DemoUser,OU=test,DC=test,DC=com")
env.put(Context.SECURITY_CREDENTIALS,"thepasswordishere")
try {
def ctx = new InitialDirContext(env)
if (ctx) {
println "Authentication Success"
}
}catch(AuthenticationException elc){
println elc.printStackTrace()
println "Authentication Fail"
}catch(Exception e){
println e.printStackTrace()
}
ctx.close()
【问题讨论】:
标签: active-directory ldap windows-server-2012 digest-authentication sasl