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

◆ CheckNtTokenForSid()

bool System.Security.Principal.WindowsIdentity.CheckNtTokenForSid ( SecurityIdentifier sid)
inlineprivate

Definition at line 532 of file WindowsIdentity.cs.

533 {
535 {
536 return false;
537 }
539 TokenImpersonationLevel impersonationLevel = ImpersonationLevel;
540 bool IsMember = false;
541 try
542 {
543 if (impersonationLevel == TokenImpersonationLevel.None && !global::Interop.Advapi32.DuplicateTokenEx(_safeTokenHandle, 8u, IntPtr.Zero, 2u, 2u, ref phNewToken))
544 {
545 throw new SecurityException(new Win32Exception().Message);
546 }
547 if (!global::Interop.Advapi32.CheckTokenMembership((impersonationLevel != 0) ? _safeTokenHandle : phNewToken, sid.BinaryForm, ref IsMember))
548 {
549 throw new SecurityException(new Win32Exception().Message);
550 }
551 return IsMember;
552 }
553 finally
554 {
556 {
557 phNewToken.Dispose();
558 }
559 }
560 }

References System.Security.Principal.WindowsIdentity._safeTokenHandle, System.Runtime.Serialization.Dictionary, System.Security.Principal.WindowsIdentity.ImpersonationLevel, Microsoft.Win32.SafeHandles.SafeAccessTokenHandle.InvalidHandle, Microsoft.Win32.SafeHandles.SafeAccessTokenHandle.IsInvalid, and System.IntPtr.Zero.