34 static LSA_HANDLE PhLookupPolicyHandle = NULL;
37 _Out_ PLSA_HANDLE PolicyHandle,
38 _In_ ACCESS_MASK DesiredAccess,
62 LSA_HANDLE lookupPolicyHandle;
63 LSA_HANDLE newLookupPolicyHandle;
65 lookupPolicyHandle = PhLookupPolicyHandle;
69 if (!lookupPolicyHandle)
72 &newLookupPolicyHandle,
82 &PhLookupPolicyHandle,
83 newLookupPolicyHandle,
87 if (!lookupPolicyHandle)
90 lookupPolicyHandle = newLookupPolicyHandle;
97 LsaClose(newLookupPolicyHandle);
102 return lookupPolicyHandle;
115 _In_ PLUID PrivilegeValue,
169 LsaFreeMemory(displayName);
183 _Out_ PLUID PrivilegeValue
216 _Out_opt_ PSID_NAME_USE NameUse
220 LSA_HANDLE policyHandle;
221 PLSA_REFERENCED_DOMAIN_LIST referencedDomains;
222 PLSA_TRANSLATED_NAME names;
226 referencedDomains = NULL;
237 if (names[0].Use != SidTypeInvalid && names[0].Use != SidTypeUnknown)
246 if (names[0].DomainIndex >= 0)
248 PLSA_TRUST_INFORMATION trustInfo;
250 trustInfo = &referencedDomains->Domains[names[0].DomainIndex];
261 *NameUse = names[0].Use;
266 status = STATUS_NONE_MAPPED;
271 if (referencedDomains)
272 LsaFreeMemory(referencedDomains);
274 LsaFreeMemory(names);
297 _Out_opt_ PSID_NAME_USE NameUse
301 LSA_HANDLE policyHandle;
303 PLSA_REFERENCED_DOMAIN_LIST referencedDomains;
304 PLSA_TRANSLATED_SID2 sids;
310 referencedDomains = NULL;
322 if (sids[0].Use != SidTypeInvalid && sids[0].Use != SidTypeUnknown)
330 sid = PhAllocate(sidLength);
331 memcpy(sid, sids[0].Sid, sidLength);
338 if (sids[0].DomainIndex >= 0)
340 PLSA_TRUST_INFORMATION trustInfo;
342 trustInfo = &referencedDomains->Domains[sids[0].DomainIndex];
353 *NameUse = sids[0].Use;
358 status = STATUS_NONE_MAPPED;
363 if (referencedDomains)
364 LsaFreeMemory(referencedDomains);
389 _In_ BOOLEAN IncludeDomain,
390 _Out_opt_ PSID_NAME_USE NameUse
395 LSA_HANDLE policyHandle;
396 PLSA_REFERENCED_DOMAIN_LIST referencedDomains;
397 PLSA_TRANSLATED_NAME names;
401 referencedDomains = NULL;
412 if (names[0].Use != SidTypeInvalid && names[0].Use != SidTypeUnknown)
414 PWSTR domainNameBuffer;
415 ULONG domainNameLength;
417 if (IncludeDomain && names[0].DomainIndex >= 0)
419 PLSA_TRUST_INFORMATION trustInfo;
421 trustInfo = &referencedDomains->Domains[names[0].DomainIndex];
422 domainNameBuffer = trustInfo->Name.Buffer;
423 domainNameLength = trustInfo->Name.Length;
427 domainNameBuffer = NULL;
428 domainNameLength = 0;
431 if (domainNameBuffer && domainNameLength != 0)
433 fullName =
PhCreateStringEx(NULL, domainNameLength +
sizeof(WCHAR) + names[0].Name.Length);
434 memcpy(&fullName->
Buffer[0], domainNameBuffer, domainNameLength);
435 fullName->
Buffer[domainNameLength /
sizeof(WCHAR)] =
'\\';
436 memcpy(&fullName->
Buffer[domainNameLength /
sizeof(WCHAR) + 1], names[0].Name.Buffer, names[0].Name.Length);
445 *NameUse = names[0].Use;
458 if (referencedDomains)
459 LsaFreeMemory(referencedDomains);
461 LsaFreeMemory(names);
493 string->Length = us.
Length;
494 string->Buffer[us.
Length /
sizeof(WCHAR)] = 0;