使用 HttpWebRequest 的 NTLM 身份验证适用于 .net 4.0,但不适用于 3.5
我编写了一些代码来使用 HttpWebRequest 执行 NTLM 身份验证。如果我将 winform 应用程序的目标框架设置为 4.0 那么它就可以工作。
但是,如果我将其设置为 3.5,则不会(它返回 401 未经授权的错误)。前两个连接已正确发送和接收,但在收到第二个响应时。客户没有提出第三个请求,只是说未经授权。
我的代码是:
request = (HttpWebRequest)WebRequest.Create(authenticatedOpenAssetRssUrl);
request.Credentials = new NetworkCredential(Environment.UserName, null);
request.UserAgent = Constant.XML_FEED_USER_AGENT;
request.UnsafeAuthenticatedConnectionSharing = true;
这是在 Windows 7 x64 位上运行的。
I have written some code to perform NTLM authentication using HttpWebRequest. If i set the target framework of winform app to 4.0 then it works.
However, if I set it to 3.5 then it doesnt (it returns 401 unauthorized error). The first two connections are sent and received correctly, but on receiving the 2nd response. the client does not make the 3rd request and it simply says unauthorized.
My code is:
request = (HttpWebRequest)WebRequest.Create(authenticatedOpenAssetRssUrl);
request.Credentials = new NetworkCredential(Environment.UserName, null);
request.UserAgent = Constant.XML_FEED_USER_AGENT;
request.UnsafeAuthenticatedConnectionSharing = true;
This is running on windows 7 x64 bit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查
Windows
的安全性、网络安全
:基于 NTLM SSP(包括安全 RPC)客户端的最低会话安全性。取消选中需要 128 位加密
并重新测试。Check the security of
Windows
, theNetwork security
: Minimum session security for NTLM SSP based (including secure RPC) clients. UncheckRequire 128-bit encryption
and retest.我也有同样的问题。
我能够通过更改突出显示的本地组策略来解决这些问题
您需要做的就是右键单击该策略并单击“属性”,然后取消选中“使用 128 位 ssl”
本地组中设置的屏幕截图政策
I to had the same issue.
I was able to solve them by altering the highlighted local group policy
all you need to do is right click on that policy and click properties and you need to uncheck the use 128 bit ssl
Screenshot of the settings in local group policy