Author: ekohl
Date: Mon Apr 4 22:08:45 2011
New Revision: 51257
URL:
http://svn.reactos.org/svn/reactos?rev=51257&view=rev
Log:
[ADVAPI32/LSASRV]
- Implement LsaLookupNames2 in advapi32.dll.
- Implement LsarLookupNames3 in lsasrv.dll as a mock-up which returns a hard-coded user
account (Administrator).
This fixes several wine tests.
Modified:
trunk/reactos/dll/win32/advapi32/sec/lsa.c
trunk/reactos/dll/win32/lsasrv/lsarpc.c
Modified: trunk/reactos/dll/win32/advapi32/sec/lsa.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/sec/lsa…
==============================================================================
--- trunk/reactos/dll/win32/advapi32/sec/lsa.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/advapi32/sec/lsa.c [iso-8859-1] Mon Apr 4 22:08:45 2011
@@ -430,20 +430,22 @@
OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
OUT PLSA_TRANSLATED_SID *Sids)
{
- LSAPR_TRANSLATED_SIDS TranslatedSids;
+ LSAPR_TRANSLATED_SIDS TranslatedSids = {0, NULL};
ULONG MappedCount = 0;
NTSTATUS Status;
TRACE("(%p,0x%08x,%p,%p,%p)\n", PolicyHandle, Count, Names,
ReferencedDomains, Sids);
+ if (ReferencedDomains == NULL || Sids == NULL)
+ return STATUS_INVALID_PARAMETER;
+
RpcTryExcept
{
*ReferencedDomains = NULL;
*Sids = NULL;
TranslatedSids.Entries = Count;
- TranslatedSids.Sids = *Sids;
Status = LsarLookupNames((LSAPR_HANDLE)PolicyHandle,
Count,
@@ -458,40 +460,67 @@
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
if (TranslatedSids.Sids != NULL)
- {
MIDL_user_free(TranslatedSids.Sids);
- }
-
- Status = I_RpcMapWin32Status(RpcExceptionCode());
- }
- RpcEndExcept;
-
- return Status;
-}
-
-
-/*
- * @unimplemented
- */
-NTSTATUS
-WINAPI
-LsaLookupNames2(
- LSA_HANDLE PolicyHandle,
- ULONG Flags,
- ULONG Count,
- PLSA_UNICODE_STRING Names,
- PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
- PLSA_TRANSLATED_SID2 *Sids)
-{
- FIXME("(%p,0x%08x,0x%08x,%p,%p,%p) stub\n", PolicyHandle, Flags,
- Count, Names, ReferencedDomains, Sids);
- if (Names != NULL && Count > 0)
- {
- *ReferencedDomains = RtlAllocateHeap(RtlGetProcessHeap(), 0,
sizeof(LSA_REFERENCED_DOMAIN_LIST));
- *Sids = RtlAllocateHeap(RtlGetProcessHeap(), 0, Count *
sizeof(LSA_TRANSLATED_SID2));
- return STATUS_SOME_NOT_MAPPED;
- }
- return STATUS_NONE_MAPPED;
+
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ return Status;
+}
+
+
+/*
+ * @implemented
+ */
+NTSTATUS
+WINAPI
+LsaLookupNames2(IN LSA_HANDLE PolicyHandle,
+ IN ULONG Flags,
+ IN ULONG Count,
+ IN PLSA_UNICODE_STRING Names,
+ OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
+ OUT PLSA_TRANSLATED_SID2 *Sids)
+{
+ LSAPR_TRANSLATED_SIDS_EX2 TranslatedSids = {0, NULL};
+ ULONG MappedCount = 0;
+ NTSTATUS Status;
+
+ TRACE("(%p,0x%08x,0x%08x,%p,%p,%p) stub\n", PolicyHandle, Flags,
+ Count, Names, ReferencedDomains, Sids);
+
+ if (ReferencedDomains == NULL || Sids == NULL)
+ return STATUS_INVALID_PARAMETER;
+
+ RpcTryExcept
+ {
+ *ReferencedDomains = NULL;
+ *Sids = NULL;
+
+ TranslatedSids.Entries = Count;
+
+ Status = LsarLookupNames3((LSAPR_HANDLE)PolicyHandle,
+ Count,
+ (PRPC_UNICODE_STRING)Names,
+ (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
+ &TranslatedSids,
+ LsapLookupWksta,
+ &MappedCount,
+ Flags,
+ 2);
+
+ *Sids = (PLSA_TRANSLATED_SID2)TranslatedSids.Sids;
+ }
+ RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+ {
+ if (TranslatedSids.Sids != NULL)
+ MIDL_user_free(TranslatedSids.Sids);
+
+ Status = I_RpcMapWin32Status(RpcExceptionCode());
+ }
+ RpcEndExcept;
+
+ return Status;
}
@@ -762,6 +791,7 @@
return STATUS_NOT_IMPLEMENTED;
}
+
/*
* @unimplemented
*/
Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsarpc.c?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] Mon Apr 4 22:08:45 2011
@@ -554,7 +554,7 @@
for (i = 0; i < Count; i++)
{
OutputSids[i].Use = SidTypeWellKnownGroup;
- OutputSids[i].RelativeId = DOMAIN_ALIAS_RID_ADMINS;
+ OutputSids[i].RelativeId = DOMAIN_USER_RID_ADMIN; //DOMAIN_ALIAS_RID_ADMINS;
OutputSids[i].DomainIndex = i;
}
@@ -1293,8 +1293,126 @@
DWORD LookupOptions,
DWORD ClientRevision)
{
- UNIMPLEMENTED;
- return STATUS_NOT_IMPLEMENTED;
+ SID_IDENTIFIER_AUTHORITY IdentifierAuthority = {SECURITY_NT_AUTHORITY};
+ static const UNICODE_STRING DomainName = RTL_CONSTANT_STRING(L"DOMAIN");
+ PLSAPR_REFERENCED_DOMAIN_LIST DomainsBuffer = NULL;
+ PLSAPR_TRANSLATED_SID_EX2 SidsBuffer = NULL;
+ ULONG SidsBufferLength;
+ ULONG DomainSidLength;
+ ULONG AccountSidLength;
+ PSID DomainSid;
+ PSID AccountSid;
+ ULONG i;
+ NTSTATUS Status;
+
+ TRACE("LsarLookupNames3(%p, %lu, %p, %p, %p, %d, %p, %lu, %lu)\n",
+ PolicyHandle, Count, Names, ReferencedDomains, TranslatedSids,
+ LookupLevel, MappedCount, LookupOptions, ClientRevision);
+
+ if (Count == 0)
+ return STATUS_NONE_MAPPED;
+
+ TranslatedSids->Entries = Count;
+ TranslatedSids->Sids = NULL;
+ *ReferencedDomains = NULL;
+
+ SidsBufferLength = Count * sizeof(LSAPR_TRANSLATED_SID_EX2);
+ SidsBuffer = MIDL_user_allocate(SidsBufferLength);
+ if (SidsBuffer == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ for (i = 0; i < Count; i++)
+ {
+ SidsBuffer[i].Use = SidTypeUser;
+ SidsBuffer[i].Sid = NULL;
+ SidsBuffer[i].DomainIndex = -1;
+ SidsBuffer[i].Flags = 0;
+ }
+
+ DomainsBuffer = MIDL_user_allocate(sizeof(LSAPR_REFERENCED_DOMAIN_LIST));
+ if (DomainsBuffer == NULL)
+ {
+ MIDL_user_free(SidsBuffer);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ DomainsBuffer->Entries = Count;
+ DomainsBuffer->Domains = MIDL_user_allocate(Count *
sizeof(LSA_TRUST_INFORMATION));
+ if (DomainsBuffer->Domains == NULL)
+ {
+ MIDL_user_free(DomainsBuffer);
+ MIDL_user_free(SidsBuffer);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ Status = RtlAllocateAndInitializeSid(&IdentifierAuthority,
+ 2,
+ SECURITY_BUILTIN_DOMAIN_RID,
+ DOMAIN_ALIAS_RID_ADMINS,
+ 0, 0, 0, 0, 0, 0,
+ &DomainSid);
+ if (!NT_SUCCESS(Status))
+ {
+ MIDL_user_free(DomainsBuffer->Domains);
+ MIDL_user_free(DomainsBuffer);
+ MIDL_user_free(SidsBuffer);
+ return Status;
+ }
+
+ DomainSidLength = RtlLengthSid(DomainSid);
+
+ for (i = 0; i < Count; i++)
+ {
+ DomainsBuffer->Domains[i].Sid = MIDL_user_allocate(DomainSidLength);
+ RtlCopyMemory(DomainsBuffer->Domains[i].Sid,
+ DomainSid,
+ DomainSidLength);
+
+ DomainsBuffer->Domains[i].Name.Buffer =
MIDL_user_allocate(DomainName.MaximumLength);
+ DomainsBuffer->Domains[i].Name.Length = DomainName.Length;
+ DomainsBuffer->Domains[i].Name.MaximumLength = DomainName.MaximumLength;
+ RtlCopyMemory(DomainsBuffer->Domains[i].Name.Buffer,
+ DomainName.Buffer,
+ DomainName.MaximumLength);
+ }
+
+ Status = RtlAllocateAndInitializeSid(&IdentifierAuthority,
+ 3,
+ SECURITY_BUILTIN_DOMAIN_RID,
+ DOMAIN_ALIAS_RID_ADMINS,
+ DOMAIN_USER_RID_ADMIN,
+ 0, 0, 0, 0, 0,
+ &AccountSid);
+ if (!NT_SUCCESS(Status))
+ {
+ MIDL_user_free(DomainsBuffer->Domains);
+ MIDL_user_free(DomainsBuffer);
+ MIDL_user_free(SidsBuffer);
+ return Status;
+ }
+
+ AccountSidLength = RtlLengthSid(AccountSid);
+
+ for (i = 0; i < Count; i++)
+ {
+ SidsBuffer[i].Use = SidTypeWellKnownGroup;
+ SidsBuffer[i].Sid = MIDL_user_allocate(AccountSidLength);
+
+ RtlCopyMemory(SidsBuffer[i].Sid,
+ AccountSid,
+ AccountSidLength);
+
+ SidsBuffer[i].DomainIndex = i;
+ SidsBuffer[i].Flags = 0;
+ }
+
+ *ReferencedDomains = DomainsBuffer;
+ *MappedCount = Count;
+
+ TranslatedSids->Entries = Count;
+ TranslatedSids->Sids = SidsBuffer;
+
+ return STATUS_SUCCESS;
}