Jeff
Jeff

Reputation: 982

User Impersonation (Windows Identity) not working in .NET for Windows Authentication

I have an ASP.NET (Blazor Server) app (.NET 8) which calls an API. We are using Windows Authentication on both the website and API. This works in multiple (6) different environments. We have a client in that has a VERY locked down Windows Server environment.

When executing the following code:

return await WindowsIdentity.RunImpersonatedAsync(windowsIdentity.AccessToken, async () =>
{
    var response = await HttpRequst<T, T1>(HttpMethod.Post, url, obj);
    return response;
});

We are getting object reference issues when using the browser developer console. Using Event viewer, we were able to see the floowing error: enter image description here

I have not been able to find much about this via Google, does anyone have any ideas?

FYI, while this works on multiple other Windows 10/11/Server environments, this is the 2nd server they have given us which is having the same issue; they are unwilling to make any changes to their production server policy so I'm hoping to resolve this through a code solution or off to Okta it is.

Also, there is no proxy, and the same code works when the impersonation piece is commented out.

Thanks!

Upvotes: 0

Views: 326

Answers (0)

Related Questions