Active directory Active Directory的Windows Server 2012摘要MD5身份验证设置

Active directory Active Directory的Windows Server 2012摘要MD5身份验证设置,active-directory,ldap,windows-server-2012,digest-authentication,sasl,Active Directory,Ldap,Windows Server 2012,Digest Authentication,Sasl,请问如何在Windows Server 2012 active directory上设置摘要MD5的身份验证,以允许客户端向服务器进行身份验证。下面是我用来建立从客户端到服务器的连接的代码 Hashtable env = new Hashtable() env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory") env.put(Context.SECURITY_AUTHENTICATION,"DIGEST

请问如何在Windows Server 2012 active directory上设置摘要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()

我在Windows Server 2012R2上遇到了同样的问题

如果这对您来说并不重要,那么有一个解决方法-使用
sAMAccountName
userPrincipalName
格式中的值作为
上下文.安全性\u PRINCIPAL

因为您当前使用的
discrimitedName
格式似乎正在引起问题

以下是适合您的:

env.put(Context.SECURITY_PRINCIPAL,"DemoUser")
描述类似问题的参考文献很少:


我在Windows Server 2012R2上遇到了同样的问题

如果这对您来说并不重要,那么有一个解决方法-使用
sAMAccountName
userPrincipalName
格式中的值作为
上下文.安全性\u PRINCIPAL

因为您当前使用的
discrimitedName
格式似乎正在引起问题

以下是适合您的:

env.put(Context.SECURITY_PRINCIPAL,"DemoUser")
描述类似问题的参考文献很少: