使用Golang进行Windows NTLM身份验证

时间:2017-06-29 20:04:29

标签: go windows-authentication ntlm

需要使用golang客户端(net / http)进行http调用,这需要集成的Windows身份验证(NTLM)(similar issue )它无法工作... - 我不是下面缺少的是我使用的代码..(使用的包 - ntlmssp“github.com/Azure/go-ntlmssp”)

client := &http.Client{
    Transport: ntlmssp.Negotiator{
        RoundTripper: &http.Transport{},
    },
}

req, _ := http.NewRequest("GET", url1, nil)

req.SetBasicAuth("login", "password") 

res, err := client.Do(req)

我得到以下回复的错误..

{401 Unauthorized 401 HTTP/1.1 1 1 map[Content-Type:[text/html] Server:[Microsoft-IIS/8.5] Www-Authenticate:[NTLM Negotiate]

当我针对已启用Windows身份验证的本地网络服务器运行时似乎工作...我注意到IIS版本中的不同 - 不确定它是如何影响NTLM ...

200 OK 200 HTTP/1.1 1 1 map[Content-Type:[text/html] Accept-Ranges:[bytes] Server:[Microsoft-IIS/10.0] Persistent-Auth:[true] L

另外..当我注意到NTLM握手时 - 这就是我所看到的(不太熟悉NTLM握手/它意味着什么......)所以不确定这是否意味着......

当它工作时,授权标签为Negotiate When it works the authorization tags to Negotiate

但是当授权标签失败到NTLM but when it fails the authorization tags to NTLM

0 个答案:

没有答案