我正在尝试做看起来简单但显然不是的事情-使用NTLM进行身份验证。
文档(http://www.rubydoc.info/gems/httpclient/2.1.5.2/HTTPClient)中的示例看起来很简单,但当我尝试它时,我总是得到一个401。
我用IIS创建了一个需要NTLM的简单网站。我在IE和chrome中测试了这个作品。
然后我
require 'httpclient'
require 'pp'
require 'kconv' #seemed to be needed due to a bug..
require 'rubyntlm' # probably not needed directly?
domain = 'http://qvcluster1/'
url = 'http://qvcluster1/default.htm'
user = 'testuser'
password = 'testpassword'
client = HTTPClient.new
client.set_auth(nil ,user,password)
r = client.get("http://qvcluster1/default.htm")
pp r据我所知,它没有更多的东西,但它正在失败
这是我从最后一行得到的结果的结尾:
@reason_phrase="Unauthorized",
@request_absolute_uri=nil,
@request_method="GET",
@request_query=nil,
@request_uri=#<URI::HTTP http://qvcluster1/default.htm>,
@status_code=401>,如有任何建议,欢迎光临!
顺便说一句,我刚刚在curl上测试了一下,它工作得很好:
"C:\Program Files\cURL\bin\curl.exe" --ntlm -u testuser:testpassword http://qvcluster1/default.htm发布于 2017-01-26 11:16:39
错误警报-事实证明,web服务器与域控制器的通信存在问题,因此导致身份验证混乱。我将其删除并重新添加到域中,现在一切都好了!
https://stackoverflow.com/questions/41842480
复制相似问题