【问题标题】:Windows Server 2012 Digest MD5 Authentication setup for Active Directory适用于 Active Directory 的 Windows Server 2012 Digest MD5 身份验证设置
【发布时间】: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


    【解决方案1】:

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

    如果它对您来说并不重要,有一个解决方法 - 使用 sAMAccountNameuserPrincipalName 格式的值作为 Context.SECURITY_PRINCIPAL

    因为您当前使用的distinguishedName 格式似乎造成了麻烦。

    以下是适合您的方法:

    env.put(Context.SECURITY_PRINCIPAL,"DemoUser")
    

    描述类似问题的参考文献很少:

    "Active Directory does not support distinguished name."

    "The distinguished name (DN) does not work for authentication; the userPrincipalName attribute must be used instead."

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-24
      • 1970-01-01
      • 1970-01-01
      • 2016-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多