This repository was archived by the owner on Mar 19, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -224,8 +224,14 @@ internal WindowsPrincipal GetUser()
224224 && info ->InfoType == HttpApi . HTTP_REQUEST_INFO_TYPE . HttpRequestInfoTypeAuth
225225 && info ->pInfo ->AuthStatus == HttpApi . HTTP_AUTH_STATUS . HttpAuthStatusSuccess )
226226 {
227- return new WindowsPrincipal ( new WindowsIdentity ( info ->pInfo ->AccessToken ,
228- GetAuthTypeFromRequest ( info ->pInfo ->AuthType ) . ToString ( ) ) ) ;
227+ // Duplicates AccessToken
228+ var identity = new WindowsIdentity ( info ->pInfo ->AccessToken ,
229+ GetAuthTypeFromRequest ( info ->pInfo ->AuthType ) . ToString ( ) ) ;
230+
231+ // Close the original
232+ UnsafeNclNativeMethods . SafeNetHandles . CloseHandle ( info ->pInfo ->AccessToken ) ;
233+
234+ return new WindowsPrincipal ( identity ) ;
229235 }
230236 }
231237
Original file line number Diff line number Diff line change @@ -302,6 +302,7 @@ internal void Dispose()
302302 // TODO: Verbose log
303303 _isDisposed = true ;
304304 _nativeRequestContext . Dispose ( ) ;
305+ ( User ? . Identity as WindowsIdentity ) ? . Dispose ( ) ;
305306 if ( _nativeStream != null )
306307 {
307308 _nativeStream . Dispose ( ) ;
You can’t perform that action at this time.
0 commit comments