advapi32: Implement LsaLookupSids.
authorAric Stewart <aric@codeweavers.com>
Thu, 24 Sep 2009 13:38:35 +0000 (08:38 -0500)
committerAlexandre Julliard <julliard@winehq.org>
Thu, 24 Sep 2009 14:04:24 +0000 (16:04 +0200)
dlls/advapi32/lsa.c

index 796fa45bd71e30810d286af374f1255697df55d6..a0a332eed962cec1daa481039f730dd257d60db8 100644 (file)
@@ -408,9 +408,50 @@ NTSTATUS WINAPI LsaLookupSids(
     OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
     OUT PLSA_TRANSLATED_NAME *Names )
 {
-    FIXME("(%p,%u,%p,%p,%p) stub\n", PolicyHandle, Count, Sids,
+    ULONG i, mapped, size;
+    ULONG name_size, domain_size;
+    SID_NAME_USE use;
+
+    TRACE("(%p,%u,%p,%p,%p) stub\n", PolicyHandle, Count, Sids,
           ReferencedDomains, Names);
 
+    size = sizeof(LSA_TRANSLATED_NAME) * Count;
+    if (!(*Names = HeapAlloc( GetProcessHeap(), 0, size) )) return STATUS_NO_MEMORY;
+    if (!(*ReferencedDomains = HeapAlloc( GetProcessHeap(), 0, sizeof(LSA_REFERENCED_DOMAIN_LIST)) ))
+    {
+        HeapFree( GetProcessHeap(), 0, *Names);
+        return STATUS_NO_MEMORY;
+    }
+    (*ReferencedDomains)->Entries = 0;
+    (*ReferencedDomains)->Domains = NULL;
+
+    mapped = 0;
+    for (i = 0; i < Count; i++)
+    {
+        name_size = domain_size = 0;
+        (*Names)[i].Use = SidTypeUnknown;
+        (*Names)[i].DomainIndex = -1;
+        (*Names)[i].Name.Length = 0;
+        (*Names)[i].Name.MaximumLength = 0;
+        (*Names)[i].Name.Buffer = NULL;
+        if (LookupAccountSidW(NULL, Sids[i], NULL, &name_size, NULL, &domain_size, &use))
+        {
+            if (domain_size)
+                FIXME("domains not handled\n");
+            mapped++;
+
+            domain_size = 0;
+            (*Names)[i].Use = use;
+            (*Names)[i].Name.Length = name_size * sizeof(WCHAR);
+            (*Names)[i].Name.MaximumLength = name_size * sizeof(WCHAR);
+            (*Names)[i].Name.Buffer = HeapAlloc(GetProcessHeap(),0,name_size * sizeof(WCHAR));
+            LookupAccountSidW(NULL, Sids[i], (*Names)[i].Name.Buffer, &name_size, NULL, &domain_size, &use);
+        }
+    }
+    TRACE("mapped %u out of %u\n",mapped,Count);
+
+    if (mapped == Count) return STATUS_SUCCESS;
+    if (mapped) return STATUS_SOME_NOT_MAPPED;
     return STATUS_NONE_MAPPED;
 }