使用Windows.Web.Http.HttpClient NTLM身份验证 [英] NTLM authentication using Windows.Web.Http.HttpClient

查看:1409
本文介绍了使用Windows.Web.Http.HttpClient NTLM身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作在Windows 10 UWP应用程序,需要与使用NTLM身份验证的IIS服务器。我设置的用户名和密码在HttpBaseProtocolFilter:

filter.ServerCredential =新PasswordCredential(URI,用户名,密码);

当我查看小提琴手的要求,它是使用基本认证。有什么我可以做的就是它使用NTLM,服务器所需要?


请求报头:

 的Content-Length:1459
内容类型:文本/ xml的;字符集= UTF-8
主持人:服务器
连接:保持活动
缓存控制:无缓存
饼干:客户端Id = XXXXXXXXX
授权:基本XXXXXXXXX

响应头:

  HTTP / 1.1 401匿名请求不允许
服务器:Microsoft-IIS / 8.5
请求ID:XXXXX
WWW验证:NTLM
WWW身份验证:协商
的X已启动方式:ASP.NET
的X FEServer:XXXXXXX
日期:星期四,2015年12月3日16点12分58秒GMT
内容长度:0
代理服务器的支持:基于会话的验证


解决方案

简短的回答:NTLM身份验证不使用用户名/密码工作。需要重试连接的第二次,因为HttpClient的是pre-发送时服务器需要NTLM基本身份验证

龙答:我的应用程序托管的联系人在同一服务器上的两个服务。第一个允许基本认证,但第二只允许NTLM。首先,我连接到​​基本身份验证服务,然后我连接到NTLM之一。我将承担HttpClient的将自动拥有执行重试使用NTLM时,它得到了 WWW验证:NTLM 头,但现在看来,事实并非如此。但是,如果我手动重试连接,那么第二次的HttpClient将执行NTLM身份验证。

I am working on a Windows 10 UWP app that needs to talk to a IIS server using NTLM authentication. I am setting the username and password in the HttpBaseProtocolFilter:

filter.ServerCredential = new PasswordCredential(uri, UserName, Password);

When i view the request in fiddler, it is using Basic Auth. Is there anything I can do to get it to use NTLM, which the server is requiring?


Request Headers:

Content-Length: 1459
Content-Type: text/xml; charset=utf-8
Host: server
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: ClientId=XXXXXXXXX
Authorization: Basic XXXXXXXXX

Response Headers:

HTTP/1.1 401 Anonymous Request Disallowed
Server: Microsoft-IIS/8.5
request-id: xxxxx
WWW-Authenticate: NTLM
WWW-Authenticate: Negotiate
X-Powered-By: ASP.NET
X-FEServer: XXXXXXX
Date: Thu, 03 Dec 2015 16:12:58 GMT
Content-Length: 0
Proxy-Support: Session-Based-Authentication

解决方案

Short answer: NTLM auth does work with username / password. Need to retry the connection a second time, because HttpClient is pre-sending BASIC auth when server wants NTLM

Long answer: My app contacts two services hosted on the same server. The first allows Basic auth but the second only allows NTLM. First I connected to the Basic auth service and then I connect to the NTLM one. I would assume the HttpClient would have automatically performed a retry with NTLM when it got the WWW-Authenticate: NTLM header, but it appears that it doesn't. However, if I manually retry the connection, then the second time the HttpClient will perform NTLM auth.

这篇关于使用Windows.Web.Http.HttpClient NTLM身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆