1

My computer is connected to the company AD. When I try to access certain REST API from Edge I am automatically signed in and I can access the API. I want to mimic this behavior from C#.

var clientHandler = new HttpClientHandler{
    Proxy = GlobalProxySelection.GetEmptyWebProxy(),  // the resource has direct access
    UseDefaultCredentials = true,
    // PreAuthenticate = false,
    AllowAutoRedirect = false,
    // UseCookies = true,
    // CookieContainer = new CookieContainer()
};

var client = new HttpClient(clientHandler);
var result = client.GetAsync(URL).Result;
Console.WriteLine(result.StatusCode);
Console.WriteLine(result.Headers);

However this code doesn't work since it redirects my to ADFS sing-in page. Instead, I'd like it to use NTLM/Kerberos/SSPI/magic. I've been wrapping my head around it for weeks now, but nothing seems to work and I really need someone to put me in the right direction.

Samuele Pilleri
  • 734
  • 1
  • 7
  • 17
  • may be you find solution in this post [https://stackoverflow.com/questions/66906401/c-sharp-httpclient-with-ntlm-auth-not-passing-correct-credentials] – Mihal By Oct 05 '22 at 20:30

0 Answers0