From 80d19952efe182ea4da81ef18ebe0143fe726dd5 Mon Sep 17 00:00:00 2001 From: Louis Lenders Date: Tue, 23 Jun 2009 18:23:01 +0200 Subject: advapi32: Add some flesh to LsaLookupNames2 (only for the case when there's one name in the names array,based on a patch from Aric Stewart) --- dlls/advapi32/lsa.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 51 insertions(+), 1 deletions(-) diff --git a/dlls/advapi32/lsa.c b/dlls/advapi32/lsa.c index 315cce9..1fafb0a 100644 --- a/dlls/advapi32/lsa.c +++ b/dlls/advapi32/lsa.c @@ -309,8 +309,58 @@ NTSTATUS WINAPI LsaLookupNames2( PLSA_REFERENCED_DOMAIN_LIST *domains, PLSA_TRANSLATED_SID2 *sids) { + DWORD sidsize, domainsize; + SID_NAME_USE use; + NTSTATUS status; + LPWSTR name, domain; + INT i = 0; + FIXME("(%p,0x%08x,0x%08x,%p,%p,%p) stub\n", policy, flags, count, names, domains, sids); - return STATUS_NONE_MAPPED; + + status = STATUS_SUCCESS; + + /* we only handle the case of one name in the names array for now */ + if (count != 1) + { + return STATUS_NONE_MAPPED; + } + + *sids = HeapAlloc(GetProcessHeap(),0,sizeof(LSA_TRANSLATED_SID2) * count); + + sidsize = 0; + domainsize = 0; + + name = HeapAlloc(GetProcessHeap(),0,names[i].Length + sizeof(WCHAR)); + memcpy(name ,names[i].Buffer,names[i].Length); + name[(names[i].Length/sizeof(WCHAR))] = 0; + + LookupAccountNameW(NULL, name, NULL, &sidsize, NULL, &domainsize, &use); + + if (sidsize) + { + (*sids)[i].Sid = HeapAlloc(GetProcessHeap(),0,sidsize); + domain = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR) * (domainsize)); + + LookupAccountNameW(NULL, name, (*sids)[i].Sid, &sidsize, domain, &domainsize, &use); + + if ( use == SidTypeUnknown ) status=STATUS_NONE_MAPPED; + + (*sids)[i].Use = use; + (*sids)[i].DomainIndex = 0; + HeapFree(GetProcessHeap(),0,domain); + } + else + { + (*sids)[i].Use = SidTypeUnknown; + status=STATUS_NONE_MAPPED; + } + + HeapFree(GetProcessHeap(),0,name); + + (*domains) = HeapAlloc(GetProcessHeap(),0,sizeof(LSA_REFERENCED_DOMAIN_LIST)); + (*domains)->Entries = 1; + + return status; } /****************************************************************************** -- 1.6.0.4