File tree 2 files changed +19
-5
lines changed
src/Servers/IIS/AspNetCoreModuleV2
OutOfProcessRequestHandler
2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -516,7 +516,13 @@ http_get_authentication_information(
516
516
)
517
517
{
518
518
*pstrAuthType = SysAllocString (pInProcessHandler->QueryHttpContext ()->GetUser ()->GetAuthenticationType ());
519
- *pvToken = pInProcessHandler->QueryHttpContext ()->GetUser ()->GetImpersonationToken ();
519
+ // prefer GetPrimaryToken over GetImpersonationToken as that's what we've been using since before .NET 10
520
+ // we'll fallback to GetImpersonationToken if GetPrimaryToken is not available
521
+ *pvToken = pInProcessHandler->QueryHttpContext ()->GetUser ()->GetPrimaryToken ();
522
+ if (*pvToken == nullptr )
523
+ {
524
+ *pvToken = pInProcessHandler->QueryHttpContext ()->GetUser ()->GetImpersonationToken ();
525
+ }
520
526
521
527
return S_OK;
522
528
}
Original file line number Diff line number Diff line change @@ -819,12 +819,20 @@ FORWARDING_HANDLER::GetHeaders(
819
819
(_wcsicmp (m_pW3Context->GetUser ()->GetAuthenticationType (), L" negotiate" ) == 0 ||
820
820
_wcsicmp (m_pW3Context->GetUser ()->GetAuthenticationType (), L" ntlm" ) == 0 ))
821
821
{
822
- HANDLE impersonationToken = m_pW3Context->GetUser ()->GetImpersonationToken ();
823
- if (impersonationToken != nullptr &&
824
- impersonationToken != INVALID_HANDLE_VALUE)
822
+ // prefer GetPrimaryToken over GetImpersonationToken as that's what we've been using since before .NET 10
823
+ // we'll fallback to GetImpersonationToken if GetPrimaryToken is not available
824
+ HANDLE authToken = m_pW3Context->GetUser ()->GetPrimaryToken ();
825
+ if (authToken == nullptr ||
826
+ authToken == INVALID_HANDLE_VALUE)
827
+ {
828
+ authToken = m_pW3Context->GetUser ()->GetImpersonationToken ();
829
+ }
830
+
831
+ if (authToken != nullptr &&
832
+ authToken != INVALID_HANDLE_VALUE)
825
833
{
826
834
HANDLE hTargetTokenHandle = nullptr ;
827
- RETURN_IF_FAILED (pServerProcess->SetWindowsAuthToken (impersonationToken ,
835
+ RETURN_IF_FAILED (pServerProcess->SetWindowsAuthToken (authToken ,
828
836
&hTargetTokenHandle));
829
837
830
838
//
You can’t perform that action at this time.
0 commit comments