[ADVAPI32/LSASRV]
authorEric Kohl <eric.kohl@reactos.org>
Sun, 11 Jul 2010 09:33:44 +0000 (09:33 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sun, 11 Jul 2010 09:33:44 +0000 (09:33 +0000)
- Export LsaLookupPrivilegeName.
- Move mockup code from advapi32 to lsasrv (LsaLookupSids --> LsarLookupSids).
- Make LsaLookupSids call the server function LsarLookupSids.

svn path=/trunk/; revision=47996

reactos/dll/win32/advapi32/advapi32.spec
reactos/dll/win32/advapi32/sec/lsa.c
reactos/dll/win32/lsasrv/lsarpc.c

index a3ade3a..fe952b9 100644 (file)
 @ stdcall LsaLookupNames(long long ptr ptr ptr)
 @ stdcall LsaLookupNames2(ptr long long ptr ptr ptr)
 @ stub LsaLookupPrivilegeDisplayName
-@ stub LsaLookupPrivilegeName
+@ stdcall LsaLookupPrivilegeName(ptr ptr ptr)
 @ stdcall LsaLookupPrivilegeValue(ptr ptr ptr)
 @ stdcall LsaLookupSids(ptr long ptr ptr ptr)
 @ stdcall LsaNtStatusToWinError(long)
index 10bb1e6..4a89b0f 100644 (file)
@@ -429,7 +429,7 @@ LsaLookupPrivilegeName(IN LSA_HANDLE PolicyHandle,
     PRPC_UNICODE_STRING NameBuffer = NULL;
     NTSTATUS Status;
 
-    TRACE("(%p,%p,%p) stub\n", PolicyHandle, Value, Name);
+    TRACE("(%p,%p,%p)\n", PolicyHandle, Value, Name);
 
     RpcTryExcept
     {
@@ -463,7 +463,7 @@ LsaLookupPrivilegeValue(IN LSA_HANDLE PolicyHandle,
     LUID Luid;
     NTSTATUS Status;
 
-    TRACE("(%p,%p,%p) stub\n", PolicyHandle, Name, Value);
+    TRACE("(%p,%p,%p)\n", PolicyHandle, Name, Value);
 
     RpcTryExcept
     {
@@ -483,7 +483,7 @@ LsaLookupPrivilegeValue(IN LSA_HANDLE PolicyHandle,
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 NTSTATUS
 WINAPI
@@ -494,36 +494,49 @@ LsaLookupSids(
     PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
     PLSA_TRANSLATED_NAME *Names)
 {
-    static const UNICODE_STRING UserName = RTL_CONSTANT_STRING(L"Administrator");
-    PLSA_REFERENCED_DOMAIN_LIST LocalDomains;
-    PLSA_TRANSLATED_NAME LocalNames;
+    LSAPR_SID_ENUM_BUFFER SidEnumBuffer;
+    LSAPR_TRANSLATED_NAMES TranslatedNames;
+    ULONG MappedCount = 0;
+    NTSTATUS  Status;
 
-    TRACE("(%p,%u,%p,%p,%p) stub\n", PolicyHandle, Count, Sids,
+    TRACE("(%p,%u,%p,%p,%p)\n", PolicyHandle, Count, Sids,
           ReferencedDomains, Names);
 
-    WARN("LsaLookupSids(): stub. Always returning 'Administrator'\n");
-    if (Count != 1)
-        return STATUS_NONE_MAPPED;
-    LocalDomains = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(LSA_TRANSLATED_SID));
-    if (!LocalDomains)
-        return SCESTATUS_NOT_ENOUGH_RESOURCE;
-    LocalNames = RtlAllocateHeap(RtlGetProcessHeap(), 0,  sizeof(LSA_TRANSLATED_NAME) + UserName.MaximumLength);
-    if (!LocalNames)
+    if (Count == 0)
+        return STATUS_INVALID_PARAMETER;
+
+    SidEnumBuffer.Entries = Count;
+    SidEnumBuffer.SidInfo = (PLSAPR_SID_INFORMATION)Sids;
+
+    RpcTryExcept
     {
-        LsaFreeMemory(LocalDomains);
-        return SCESTATUS_NOT_ENOUGH_RESOURCE;
+        *ReferencedDomains = NULL;
+        *Names = NULL;
+
+        TranslatedNames.Entries = 0;
+        TranslatedNames.Names = NULL;
+
+        Status = LsarLookupSids((LSAPR_HANDLE)PolicyHandle,
+                                &SidEnumBuffer,
+                                (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
+                                &TranslatedNames,
+                                LsapLookupWksta,
+                                &MappedCount);
+
+        *Names = (PLSA_TRANSLATED_NAME)TranslatedNames.Names;
     }
-    LocalDomains[0].Entries = 0;
-    LocalDomains[0].Domains = NULL;
-    LocalNames[0].Use = SidTypeWellKnownGroup;
-    LocalNames[0].Name.Buffer = (LPWSTR)((ULONG_PTR)(LocalNames) + sizeof(LSA_TRANSLATED_NAME));
-    LocalNames[0].Name.Length = UserName.Length;
-    LocalNames[0].Name.MaximumLength = UserName.MaximumLength;
-    RtlCopyMemory(LocalNames[0].Name.Buffer, UserName.Buffer, UserName.MaximumLength);
-
-    *ReferencedDomains = LocalDomains;
-    *Names = LocalNames;
-    return STATUS_SUCCESS;
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        if (TranslatedNames.Names != NULL)
+        {
+            MIDL_user_free(TranslatedNames.Names);
+        }
+
+        Status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return Status;
 }
 
 /******************************************************************************
index 57f802b..c20a8cd 100644 (file)
@@ -347,8 +347,44 @@ NTSTATUS LsarLookupSids(
     LSAP_LOOKUP_LEVEL LookupLevel,
     DWORD *MappedCount)
 {
-    UNIMPLEMENTED;
-    return STATUS_NOT_IMPLEMENTED;
+    static const UNICODE_STRING UserName = RTL_CONSTANT_STRING(L"Administrator");
+    PLSAPR_TRANSLATED_NAME OutputNames = NULL;
+    ULONG OutputNamesLength;
+    ULONG i;
+
+    TRACE("LsarLookupSids(%p, %p, %p, %p, %d, %p)\n",
+          PolicyHandle, SidEnumBuffer, ReferencedDomains, TranslatedNames,
+          LookupLevel, MappedCount);
+
+    TranslatedNames->Entries = SidEnumBuffer->Entries;
+    TranslatedNames->Names = NULL;
+    *ReferencedDomains = NULL;
+
+    OutputNamesLength = SidEnumBuffer->Entries * sizeof(LSA_TRANSLATED_NAME);
+    OutputNames = MIDL_user_allocate(OutputNamesLength);
+    if (OutputNames == NULL)
+    {
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+
+    RtlZeroMemory(OutputNames, OutputNamesLength);
+
+    for (i = 0; i < SidEnumBuffer->Entries; i++)
+    {
+        OutputNames[i].Use = SidTypeWellKnownGroup;
+        OutputNames[i].DomainIndex = 0;
+        OutputNames[i].Name.Buffer = MIDL_user_allocate(UserName.MaximumLength);
+        OutputNames[i].Name.Length = UserName.Length;
+        OutputNames[i].Name.MaximumLength = UserName.MaximumLength;
+        RtlCopyMemory(OutputNames[i].Name.Buffer, UserName.Buffer, UserName.MaximumLength);
+    }
+
+    *MappedCount = SidEnumBuffer->Entries;
+
+    TranslatedNames->Entries =  SidEnumBuffer->Entries;
+    TranslatedNames->Names = OutputNames;
+
+    return STATUS_SUCCESS;
 }