2

I need to simulate Win Auth http header for HttpClient. It could be something like the following , see the Authorization header :

POST http://url HTTP/1.1
Host: http://127.0.0.1/
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0
Accept: /
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://127.0.0.1/
Content-Length: 18
Origin: http://127.0.0.1/
Connection: keep-alive
Authorization: NTLM TlRMTVNTUAADAAAAGAAYAIQAAABuAW4BnAAAAAAAAABYAAAAFgAWAFgAAAA
WABYAbgAAAAAAAAAKAgAABYKIogoAACgAAAAPUOVvBWOMBKcZqtqFzf+fmWQAZwByAHUAZAB6AGkAbgBzA...

Please, give me some examples how to encode domain username & password for that http header, i found only examples for BASIC authentication. But there are windows authentication & NTLM.

Vladyslav Furdak
  • 1,765
  • 2
  • 22
  • 46
  • 1
    https://developer.gnome.org/evolution-exchange/stable/ximian-connector-ntlm.html or http://davenport.sourceforge.net/ntlm.html seem to give some info – steve cook Jan 05 '16 at 15:50
  • @steve Yes, thanks, but there is only specification, i need to get some trusted c# code snippet to encode domain username & password to base64 string from appropriate format. – Vladyslav Furdak Jan 05 '16 at 15:54
  • 1
    You mention HttpClient, but if you can use HttpWebRequest you might find this useful: http://stackoverflow.com/questions/1520703/sending-http-headers-with-http-web-request-for-ntlm-authentication – steve cook Jan 05 '16 at 16:01

1 Answers1

0

Put the domain credentials in the HttpClientHandler.Credentials property and the AuthorizationManager will do the Auth dance for you and fill in the Authorization header as required.

Darrel Miller
  • 139,164
  • 32
  • 194
  • 243