0

I am trying to call an api with which has implemented NTLM authentication in the deployed iis server. This is giving proper response when tried from postman or in the browser, but this doesn't work when tried from code as mentioned below, code is in c# and i am using . netcore7 I know it is a three step process. The http client which I call is always giving me 401 in response.

Here is the sample code

var uri = new uri(https: //     xyz.xyz.org/api/controller 

    using HttpclientHandler handler = new() {
        Credentials = new NetworkCredential(username, password, domain),
            usecookies = true,
            CookiesContainer = new CookiesContainer(),
            PreAuthenticate = true
    }; using Httpclient client = new(handler) {
        var response = await client.GetAsync(uri);
    }

When I check response, i have 401 and the challenge www-Authenticate of the second step and no Type3 message is passed.

How can we do this? Please help

I tried multiple ways to send the server response in the next request headers, but not able to generate proper Authorization header

  • I haven't done a test, and I just want to double confirm some details here. First, NTLM doesn't support cross domain request, so you need to make sure the host API is in the same domain of your running code. By the way, maybe you also need to add the windows account to have permission to that IIS website. – Tiny Wang May 16 '23 at 07:45

0 Answers0