Is Windows Authentication Impersonation dead in ASP.NET Core?

Viewed 1298

Found this bit while trying to find out why none of the impersonation stuff works.

https://docs.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-3.1&tabs=visual-studio#impersonation

ASP.NET Core doesn't implement impersonation.

and

RunImpersonated doesn't support asynchronous operations and shouldn't be used for complex scenarios. For example, wrapping entire requests or middleware chains isn't supported or recommended.

That sounds like a no-go to me. Is it no longer practical to query the database as the end user?

1 Answers

Starting with .NET 5 there will be a WindowsIdentity.RunImpersonatedAsync.

For now, you have to stick with this (remarks from the 3.1 docs):

This method may be used reliably with the async/await pattern, unlike Impersonate. In an async method, this method may be used with an async delegate argument so that the resulting task may be awaited.

The .NET Platform Extensions for System.Security.Principal.WindowsIdentity for 5.0 are currently in preview2.
You can find the release date here: Upcoming Ship Dates

Related