Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ RunImpersonatedInternal()

static void System.Security.Principal.WindowsIdentity.RunImpersonatedInternal ( SafeAccessTokenHandle token,
Action action )
inlinestaticprivate

Definition at line 629 of file WindowsIdentity.cs.

630 {
631 token = DuplicateAccessToken(token);
632 bool isImpersonating;
633 int hr;
635 if (currentToken == null || currentToken.IsInvalid)
636 {
637 throw new SecurityException(new Win32Exception(hr).Message);
638 }
639 s_currentImpersonatedToken.Value = (isImpersonating ? currentToken : null);
642 {
643 if (!global::Interop.Advapi32.RevertToSelf())
644 {
645 Environment.FailFast(new Win32Exception().Message);
646 }
648 if (!token.IsInvalid && !global::Interop.Advapi32.ImpersonateLoggedOnUser(token))
649 {
650 throw new SecurityException(System.SR.Argument_ImpersonateUser);
651 }
653 action();
654 }, null);
655 }
static string Argument_ImpersonateUser
Definition SR.cs:18
Definition SR.cs:7
static SafeAccessTokenHandle GetCurrentToken(TokenAccessLevels desiredAccess, bool threadOnly, out bool isImpersonating, out int hr)
static SafeAccessTokenHandle DuplicateAccessToken(IntPtr accessToken)
static ? ExecutionContext Capture()
static void Run(ExecutionContext executionContext, ContextCallback callback, object? state)

References System.action, System.SR.Argument_ImpersonateUser, System.Threading.ExecutionContext.Capture(), System.Runtime.Serialization.Dictionary, System.Security.Principal.WindowsIdentity.DuplicateAccessToken(), System.Environment.FailFast(), System.Security.Principal.WindowsIdentity.GetCurrentToken(), Microsoft.Win32.SafeHandles.SafeAccessTokenHandle.IsInvalid, and System.Threading.ExecutionContext.Run().

Referenced by System.Security.Principal.WindowsIdentity.RunImpersonated(), and System.Security.Principal.WindowsIdentity.RunImpersonated< T >().