7internal static class Win32
11 global::Interop.OBJECT_ATTRIBUTES Attributes =
default(global::Interop.OBJECT_ATTRIBUTES);
13 uint num = global::Interop.Advapi32.LsaOpenPolicy(systemName, ref Attributes, (
int)rights, out PolicyHandle);
25 uint error = global::Interop.Advapi32.LsaNtStatusToWinError(num);
39 if (b2 < 0 || b2 > 15)
44 byte[]
array =
new byte[num];
55 if (global::Interop.Advapi32.ConvertStringSidToSid(stringSid, out ByteArray) == 0)
69 return lastWin32Error;
75 resultSid =
new byte[resultSidLength];
76 if (global::Interop.Advapi32.CreateWellKnownSid((
int)sidType, domainSid?.
BinaryForm, resultSid, ref resultSidLength) != 0)
86 if (sid1 ==
null || sid2 ==
null)
94 if (global::Interop.Advapi32.IsEqualDomainSid(
array, array2, out var result) != 0)
104 global::Interop.LSA_REFERENCED_DOMAIN_LIST lSA_REFERENCED_DOMAIN_LIST = referencedDomains.Read<global::Interop.LSA_REFERENCED_DOMAIN_LIST>(0uL);
109 if (lSA_REFERENCED_DOMAIN_LIST.Domains !=
IntPtr.
Zero)
111 global::Interop.LSA_TRUST_INFORMATION* ptr = (global::Interop.LSA_TRUST_INFORMATION*)(
void*)lSA_REFERENCED_DOMAIN_LIST.Domains;
112 ptr += lSA_REFERENCED_DOMAIN_LIST.Entries;
113 long numBytes = (
byte*)ptr -
pointer;
114 referencedDomains.
Initialize((ulong)numBytes);
131 byte[] array2 =
new byte[resultSidLength];
132 if (global::Interop.Advapi32.GetWindowsAccountDomainSid(
array, array2, ref resultSidLength) != 0)
145 if (global::Interop.Advapi32.IsWellKnownSid(
array, (
int)
type) == 0)
static void FreeHGlobal(IntPtr hglobal)
static byte ReadByte(object ptr, int ofs)
static int GetLastWin32Error()
static void Copy(int[] source, int startIndex, IntPtr destination, int length)
static int SizeOf(object structure)
void Initialize(ulong numBytes)
unsafe void AcquirePointer(ref byte *pointer)
static string Format(string resourceFormat, object p1)
static string IdentityReference_InvalidNumberOfSubauthorities
static string IdentityReference_InvalidSidRevision
static readonly int MaxBinaryLength
void GetBinaryForm(byte[] binaryForm, int offset)
static unsafe void InitializeReferencedDomainsPointer(SafeLsaMemoryHandle referencedDomains)
static int CreateWellKnownSid(WellKnownSidType sidType, SecurityIdentifier domainSid, out byte[] resultSid)
static int CreateSidFromString(string stringSid, out byte[] resultSid)
static int GetWindowsAccountDomainSid(SecurityIdentifier sid, out SecurityIdentifier resultSid)
static bool IsWellKnownSid(SecurityIdentifier sid, WellKnownSidType type)
static byte[] ConvertIntPtrSidToByteArraySid(IntPtr binaryForm)
static bool IsEqualDomainSid(SecurityIdentifier sid1, SecurityIdentifier sid2)
static SafeLsaPolicyHandle LsaOpenPolicy(string systemName, PolicyRights rights)
static readonly IntPtr Zero