HttpWebRequest的401 NTLM Authenticiation [英] HttpWebRequest 401 with NTLM Authenticiation
问题描述
我有一个认证为HttpWebRequest的一个网络服务器的困难。我收到的反应是一个简单的401,我确信我正确设置凭据在C#的一面,和IIS是否正确设置为允许NTLM身份验证。我不知道这是否重要,但他的电脑是不是在同一个域中的Web服务器。
I am having difficulties authenticating a HttpWebRequest to a webserver. The response I am receiving is simply a 401. I've made sure I set the credentials correctly on the C# side, and IIS is correctly set to allow NTLM authentication. I don't know if this matters, but he computer is not on the same domain as the the web server.
我确信用户名/密码是正确的,但在那里上配置用户需要的任何其他授权设置?
I am sure the user/pass is correct but are there any other authorization settings needed to configure on the user?
如果我启用基本身份验证,并禁用Windows身份验证,要求完美的作品(当然是正确的C#code的变化)。
If I enable Basic authentication, and disable Windows Authentication, the request works perfectly (with the correct C# code changes of course).
我是什么失踪?
webRequest.UseDefaultCredentials = false;
webRequest.PreAuthenticate = true;
var c = new NetworkCredential("User", "password", "domain");
CredentialCache credentialCache = new CredentialCache();
credentialCache.Add(new Uri(Url), "NTLM", c);
webRequest.Credentials = credentialCache;
继承人在IIS中的我的设置快照。
Heres a snapshot of my settings in IIS.
失败请求跟踪:
推荐答案
与同事的帮助下,我们能够判断出了问题在Windows中处理身份验证的方式。貌似在本地安全设置是错误的。更改本地策略>安全选项>网络访问:共享和本地帐户从游客的安全模式只 - 本地用户以来宾为经典身份验证解决了这一问题。
With the help of a colleague, we were able to determine something was wrong in the way Windows was dealing with the authentication. Looks like a setting in the Local Security was wrong. Changing Local Policies > Security Options > Network access: Sharing and security model for local accounts from Guest only - local users authenticate as Guest to Classic fixed the problem.
这篇关于HttpWebRequest的401 NTLM Authenticiation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!