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

◆ IsInRole() [2/4]

virtual bool System.Security.Principal.WindowsPrincipal.IsInRole ( SecurityIdentifier sid)
inlinevirtual

Definition at line 88 of file WindowsPrincipal.cs.

89 {
90 if (sid == null)
91 {
92 throw new ArgumentNullException("sid");
93 }
95 {
96 return false;
97 }
99 if (_identity.ImpersonationLevel == TokenImpersonationLevel.None && !global::Interop.Advapi32.DuplicateTokenEx(_identity.AccessToken, 8u, IntPtr.Zero, 2u, 2u, ref phNewToken))
100 {
101 throw new SecurityException(new Win32Exception().Message);
102 }
103 bool IsMember = false;
104 if (!global::Interop.Advapi32.CheckTokenMembership((_identity.ImpersonationLevel != 0) ? _identity.AccessToken : phNewToken, sid.BinaryForm, ref IsMember))
105 {
106 throw new SecurityException(new Win32Exception().Message);
107 }
108 phNewToken.Dispose();
109 return IsMember;
110 }

References System.Security.Principal.WindowsPrincipal._identity, System.Security.Principal.WindowsIdentity.AccessToken, System.Security.Principal.WindowsIdentity.ImpersonationLevel, Microsoft.Win32.SafeHandles.SafeAccessTokenHandle.InvalidHandle, Microsoft.Win32.SafeHandles.SafeAccessTokenHandle.IsInvalid, and System.IntPtr.Zero.