Author: ekohl Date: Thu Oct 4 18:22:55 2012 New Revision: 57480
URL: http://svn.reactos.org/svn/reactos?rev=57480&view=rev Log: [LSASRV] LsapLookupNames: If a name was found, add its domain SID to the domains list and set the domain index accordingly.
Modified: trunk/reactos/dll/win32/lsasrv/sids.c
Modified: trunk/reactos/dll/win32/lsasrv/sids.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/sids.c?rev... ============================================================================== --- trunk/reactos/dll/win32/lsasrv/sids.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/lsasrv/sids.c [iso-8859-1] Thu Oct 4 18:22:55 2012 @@ -830,6 +830,54 @@ }
+static NTSTATUS +LsapAddDomainToDomainsList(PLSAPR_REFERENCED_DOMAIN_LIST ReferencedDomains, + PUNICODE_STRING Name, + PSID Sid, + PULONG Index) +{ + ULONG i; + + i = 0; + while (i < ReferencedDomains->Entries && + ReferencedDomains->Domains[i].Sid != NULL) + { + if (RtlEqualSid(Sid, ReferencedDomains->Domains[i].Sid)) + { + *Index = i; + return STATUS_SUCCESS; + } + + i++; + } + + ReferencedDomains->Domains[i].Sid = MIDL_user_allocate(RtlLengthSid(Sid)); + if (ReferencedDomains->Domains[i].Sid == NULL) + return STATUS_INSUFFICIENT_RESOURCES; + + RtlCopySid(RtlLengthSid(Sid), ReferencedDomains->Domains[i].Sid, Sid); + + ReferencedDomains->Domains[i].Name.Length = Name->Length; + ReferencedDomains->Domains[i].Name.MaximumLength = Name->MaximumLength; + ReferencedDomains->Domains[i].Name.Buffer = MIDL_user_allocate(Name->MaximumLength); + if (ReferencedDomains->Domains[i].Sid == NULL) + { + MIDL_user_free(ReferencedDomains->Domains[i].Sid); + ReferencedDomains->Domains[i].Sid = NULL; + return STATUS_INSUFFICIENT_RESOURCES; + } + + RtlCopyMemory(ReferencedDomains->Domains[i].Name.Buffer, + Name->Buffer, + Name->MaximumLength); + + ReferencedDomains->Entries++; + *Index = i; + + return STATUS_SUCCESS; +} + + NTSTATUS LsapLookupNames(DWORD Count, PRPC_UNICODE_STRING Names, @@ -845,6 +893,7 @@ PRPC_UNICODE_STRING DomainNames = NULL; PRPC_UNICODE_STRING AccountNames = NULL; ULONG SidsBufferLength; + ULONG DomainIndex; // ULONG DomainSidLength; // ULONG AccountSidLength; // PSID DomainSid; @@ -853,7 +902,7 @@ ULONG Mapped = 0; NTSTATUS Status = STATUS_SUCCESS;
- PWELL_KNOWN_SID ptr; + PWELL_KNOWN_SID ptr, ptr2;
//TRACE("()\n");
@@ -878,7 +927,6 @@ goto done; }
- DomainsBuffer->Entries = 0; //Count; DomainsBuffer->Domains = MIDL_user_allocate(Count * sizeof(LSA_TRUST_INFORMATION)); if (DomainsBuffer->Domains == NULL) { @@ -886,6 +934,8 @@ Status = STATUS_INSUFFICIENT_RESOURCES; goto done; } + DomainsBuffer->Entries = 0; + DomainsBuffer->MaxEntries = Count;
for (i = 0; i < Count; i++) { @@ -911,7 +961,7 @@
//TRACE("Domain name: %wZ\n", &DomainNames[i]); //TRACE("Account name: %wZ\n", &AccountNames[i]); - + ptr2 = NULL; ptr = LsapLookupWellKnownName((PUNICODE_STRING)&AccountNames[i]); if (ptr != NULL) { @@ -922,24 +972,33 @@ SidsBuffer[i].DomainIndex = -1; SidsBuffer[i].Flags = 0;
-#if 0 - if (DomainNames[i].Buffer != NULL) + if (DomainNames[i].Length != 0) { - ptr2= LsapLookupWellKnownName((PUNICODE_STRING)&DomainNames[i].Buffer); + ptr2= LsapLookupWellKnownName((PUNICODE_STRING)&DomainNames[i]); if (ptr2 != NULL) { - + Status = LsapAddDomainToDomainsList(DomainsBuffer, + &ptr2->Name, + ptr2->Sid, + &DomainIndex); + if (NT_SUCCESS(Status)) + SidsBuffer[i].DomainIndex = DomainIndex; } } - else if (ptr->Domain.Length != 0) + + if (ptr2 == NULL && ptr->Domain.Length != 0) { - + ptr2= LsapLookupWellKnownName(&ptr->Domain); + if (ptr2 != NULL) + { + Status = LsapAddDomainToDomainsList(DomainsBuffer, + &ptr2->Name, + ptr2->Sid, + &DomainIndex); + if (NT_SUCCESS(Status)) + SidsBuffer[i].DomainIndex = DomainIndex; + } } - else - { - - } -#endif
Mapped++; continue;