51 [MemberNotNull(
"_binaryForm")]
52 [MemberNotNull(
"_subAuthorities")]
55 if (subAuthorities.
Length > 15)
59 if (identifierAuthority < IdentifierAuthority.NullAuthority || identifierAuthority > (
IdentifierAuthority)281474976710655
L)
68 for (
int i = 0; i < 6; i++)
74 for (
byte b = 0; b < 4; b++)
81 [MemberNotNull(
"_binaryForm")]
82 [MemberNotNull(
"_subAuthorities")]
85 if (binaryForm ==
null)
101 int num = binaryForm[
offset + 1];
106 int num2 = 8 + 4 * num;
107 if (binaryForm.Length -
offset < num2)
113 for (
int i = 0; i < num; i++)
115 span[i] = binaryForm[
offset + 8 + 4 * i] + (binaryForm[
offset + 8 + 4 * i + 1] << 8) + (binaryForm[
offset + 8 + 4 * i + 2] << 16) + (binaryForm[
offset + 8 + 4 * i + 3] << 24);
122 if (sddlForm ==
null)
144 if (binaryForm ==
null)
152 : this(
Win32.ConvertIntPtrSidToByteArraySid(binaryForm), 0)
158 int windowsAccountDomainSid;
179 if (domainSid ==
null)
184 switch (windowsAccountDomainSid)
195 if (resultSid != domainSid)
285 switch (windowsAccountDomainSid)
302 public override bool Equals([NotNullWhen(
true)]
object? o)
333 identifierAuthority.TryFormat(span.
Slice(num), out var charsWritten);
336 for (
int i = 0; i < subAuthorities.Length; i++)
340 uint num2 = (uint)subAuthorities[i];
341 num2.TryFormat(span.
Slice(num), out charsWritten);
371 return windowsAccountDomainSid
switch
396 if (targetType ==
null)
407 identityReferenceCollection.
Add(
this);
409 return identityReferenceCollection2[0];
416 if ((
object)left == right)
420 if ((
object)left ==
null || (
object)right ==
null)
429 return !(left == right);
487 if (sourceSids ==
null)
491 if (sourceSids.
Count == 0)
515 uint num2 = global::Interop.Advapi32.LsaLookupSids(safeLsaPolicyHandle, sourceSids.Count,
array, out referencedDomains, out names);
529 uint error = global::Interop.Advapi32.LsaNtStatusToWinError(num2);
535 names.Initialize((uint)sourceSids.Count, (uint)
Marshal.
SizeOf<global::Interop.LSA_TRANSLATED_NAME>());
538 if (num2 == 0 || num2 == 263)
540 global::Interop.LSA_REFERENCED_DOMAIN_LIST lSA_REFERENCED_DOMAIN_LIST = referencedDomains.Read<global::Interop.LSA_REFERENCED_DOMAIN_LIST>(0uL);
541 string[] array3 =
new string[lSA_REFERENCED_DOMAIN_LIST.Entries];
542 for (
int i = 0; i < lSA_REFERENCED_DOMAIN_LIST.Entries; i++)
544 global::Interop.LSA_TRUST_INFORMATION lSA_TRUST_INFORMATION =
Marshal.
PtrToStructure<global::Interop.LSA_TRUST_INFORMATION>(
new IntPtr((
long)lSA_REFERENCED_DOMAIN_LIST.Domains + i *
Marshal.
SizeOf<global::Interop.LSA_TRUST_INFORMATION>()));
545 array3[i] =
Marshal.
PtrToStringUni(lSA_TRUST_INFORMATION.Name.Buffer, lSA_TRUST_INFORMATION.Name.Length / 2);
547 global::Interop.LSA_TRANSLATED_NAME[] array4 =
new global::Interop.LSA_TRANSLATED_NAME[sourceSids.Count];
548 names.ReadArray(0uL, array4, 0, array4.Length);
549 for (
int j = 0; j < sourceSids.Count; j++)
551 global::Interop.LSA_TRANSLATED_NAME lSA_TRANSLATED_NAME = array4[j];
560 string accountName =
Marshal.
PtrToStringUni(lSA_TRANSLATED_NAME.Name.Buffer, lSA_TRANSLATED_NAME.Name.Length / 2);
561 string domainName = array3[lSA_TRANSLATED_NAME.DomainIndex];
562 identityReferenceCollection.
Add(
new NTAccount(domainName, accountName));
567 identityReferenceCollection.
Add(sourceSids[j]);
574 for (
int k = 0; k < sourceSids.Count; k++)
576 identityReferenceCollection.
Add(sourceSids[k]);
579 return identityReferenceCollection;
583 for (
int l = 0; l < sourceSids.
Count; l++)
585 if (array2[l].IsAllocated)
590 safeLsaPolicyHandle?.
Dispose();
600 if (forceSuccess && someFailed)
605 if (
item.GetType() != targetType)
607 identityReferenceCollection2.Add(
item);
612 return identityReferenceCollection;
617 if (sourceSids ==
null)
static unsafe? string PtrToStringUni(IntPtr ptr)
static ? object PtrToStructure(IntPtr ptr, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors|DynamicallyAccessedMemberTypes.NonPublicConstructors)] Type structureType)
static int SizeOf(object structure)
static string IdentityReference_IdentityNotMapped
static string Argument_InvalidValue
static string IdentityReference_IdentifierAuthorityTooLarge
static string Format(string resourceFormat, object p1)
static string IdentityReference_InvalidNumberOfSubauthorities
static string IdentityReference_CannotCreateLogonIdsSid
static string Argument_ImproperType
static string IdentityReference_MustBeIdentityReference
static string ArgumentOutOfRange_ArrayTooSmall
static string IdentityReference_DomainSidRequired
static string IdentityReference_NotAWindowsDomain
static string Arg_EmptyCollection
static string ArgumentOutOfRange_NeedNonNegNum
static string IdentityReference_InvalidSidRevision
void Add(IdentityReference identity)
SecurityIdentifier GetAccountDomainSid()
void CreateFromBinaryForm(byte[] binaryForm, int offset)
bool IsEqualDomainSid(SecurityIdentifier sid)
SecurityIdentifier(WellKnownSidType sidType, SecurityIdentifier? domainSid)
static IdentityReferenceCollection Translate(IdentityReferenceCollection sourceSids, Type targetType, out bool someFailed)
override string ToString()
bool IsWellKnown(WellKnownSidType type)
static readonly int MaxBinaryLength
bool _accountDomainSidInitialized
void CreateFromParts(IdentifierAuthority identifierAuthority, ReadOnlySpan< int > subAuthorities)
IdentifierAuthority IdentifierAuthority
override bool Equals([NotNullWhen(true)] object? o)
static readonly int MinBinaryLength
static bool IsValidTargetTypeStatic(Type targetType)
SecurityIdentifier(IntPtr binaryForm)
static IdentityReferenceCollection Translate(IdentityReferenceCollection sourceSids, Type targetType, bool forceSuccess)
int GetSubAuthority(int index)
static IdentityReferenceCollection TranslateToNTAccounts(IdentityReferenceCollection sourceSids, out bool someFailed)
SecurityIdentifier _accountDomainSid
void GetBinaryForm(byte[] binaryForm, int offset)
SecurityIdentifier(IdentifierAuthority identifierAuthority, ReadOnlySpan< int > subAuthorities)
override int GetHashCode()
override IdentityReference Translate(Type targetType)
bool Equals(SecurityIdentifier sid)
static bool operator==(SecurityIdentifier? left, SecurityIdentifier? right)
SecurityIdentifier(byte[] binaryForm, int offset)
override bool IsValidTargetType(Type targetType)
IdentifierAuthority _identifierAuthority
SecurityIdentifier(string sddlForm)
static bool operator!=(SecurityIdentifier? left, SecurityIdentifier? right)
int CompareTo(SecurityIdentifier? sid)
SecurityIdentifier? AccountDomainSid
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 bool IsEqualDomainSid(SecurityIdentifier sid1, SecurityIdentifier sid2)
static SafeLsaPolicyHandle LsaOpenPolicy(string systemName, PolicyRights rights)
unsafe IntPtr AddrOfPinnedObject()
static GCHandle Alloc(object? value)
Span< T > Slice(int start)