Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
We run some ASP.NET Core services using In-process hosting with IIS and we use Windows Authentication.
We also use CoreWCF because we have some legacy clients that we still need to support.
It seems that old clients using .NET Framework cannot authenticate anymore. I found this comment that describes the same issue.
I analyzed the issue and it seems that it is caused by using GetPrimaryToken here. GetPrimaryToken() is also used in Out-of-process hosting.
I don't know if this is really an issue but shouldn't GetImpersonationToken be used instead? GetPrimaryToken() returns 0 when authenticating with TokenImpersonationLevel.Identification. It is not 0 when TokenImpersonationLevel.Impersonation is used.
GetImpersonationToken() seems to return a handle to a token of the user making the HTTP request.
Expected Behavior
Client applications that use .NET Framework must not be changed in order for Windows Authentication to work.
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
No response
Anything else?
- We don't have this problem when we use HTTP.sys web server
- As we have to use IIS, I developed a native IIS module (as a workaround) that sets the IHttpUser and forwards the calls of GetPrimartyToken() to GetImpersonationToken() for WCF calls.