2 * Implementation of the Local Security Authority API
4 * Copyright 1999 Juergen Schmied
5 * Copyright 2002 Andriy Palamarchuk
6 * Copyright 2004 Mike McCormack
7 * Copyright 2005 Hans Leidekker
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #define WIN32_NO_STATUS
32 #include "advapi32_misc.h"
34 #include "wine/debug.h"
35 #include "wine/unicode.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
39 #define ADVAPI_ForceLocalComputer(ServerName, FailureCode) \
40 if (!ADVAPI_IsLocalComputer(ServerName)) \
42 FIXME("Action Implemented for local computer only. " \
43 "Requested for server %s\n", debugstr_w(ServerName)); \
47 static void dumpLsaAttributes(const LSA_OBJECT_ATTRIBUTES *oa)
51 TRACE("\n\tlength=%u, rootdir=%p, objectname=%s\n\tattr=0x%08x, sid=%s qos=%p\n",
52 oa->Length, oa->RootDirectory,
53 oa->ObjectName?debugstr_w(oa->ObjectName->Buffer):"null",
54 oa->Attributes, debugstr_sid(oa->SecurityDescriptor),
55 oa->SecurityQualityOfService);
59 static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
66 static const WCHAR wVNETSUP[] = {
67 'S','y','s','t','e','m','\\',
68 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
69 'S','e','r','v','i','c','e','s','\\',
70 'V','x','D','\\','V','N','E','T','S','U','P','\0'};
72 ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wVNETSUP, 0, KEY_READ, &key);
73 if (ret == ERROR_SUCCESS)
76 static const WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 };
78 ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size);
79 if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
81 ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sz + size);
82 if (!ptr) return NULL;
83 ustr = (UNICODE_STRING*)(ptr + ofs);
84 ustr->MaximumLength = size;
85 ustr->Buffer = (WCHAR*)(ptr + sz);
86 ret = RegQueryValueExW(key, wg, NULL, NULL, (LPBYTE)ustr->Buffer, &size);
87 if (ret != ERROR_SUCCESS)
89 HeapFree(GetProcessHeap(), 0, ptr);
92 else ustr->Length = size - sizeof(WCHAR);
98 static const WCHAR wDomain[] = {'D','O','M','A','I','N','\0'};
99 ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
100 sz + sizeof(wDomain));
101 if (!ptr) return NULL;
102 ustr = (UNICODE_STRING*)(ptr + ofs);
103 ustr->MaximumLength = sizeof(wDomain);
104 ustr->Buffer = (WCHAR*)(ptr + sz);
105 ustr->Length = sizeof(wDomain) - sizeof(WCHAR);
106 memcpy(ustr->Buffer, wDomain, sizeof(wDomain));
111 /******************************************************************************
112 * LsaAddAccountRights [ADVAPI32.@]
115 NTSTATUS WINAPI LsaAddAccountRights(
118 PLSA_UNICODE_STRING rights,
121 FIXME("(%p,%p,%p,0x%08x) stub\n", policy, sid, rights, count);
122 return STATUS_OBJECT_NAME_NOT_FOUND;
125 /******************************************************************************
126 * LsaClose [ADVAPI32.@]
128 * Closes a handle to a Policy or TrustedDomain.
131 * ObjectHandle [I] Handle to a Policy or TrustedDomain.
134 * Success: STATUS_SUCCESS.
135 * Failure: NTSTATUS code.
137 NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle)
139 FIXME("(%p) stub\n", ObjectHandle);
140 return STATUS_SUCCESS;
143 /******************************************************************************
144 * LsaCreateTrustedDomainEx [ADVAPI32.@]
147 NTSTATUS WINAPI LsaCreateTrustedDomainEx(
149 PTRUSTED_DOMAIN_INFORMATION_EX domain_info,
150 PTRUSTED_DOMAIN_AUTH_INFORMATION auth_info,
154 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", policy, domain_info, auth_info,
156 return STATUS_SUCCESS;
159 /******************************************************************************
160 * LsaDeleteTrustedDomain [ADVAPI32.@]
163 NTSTATUS WINAPI LsaDeleteTrustedDomain(LSA_HANDLE policy, PSID sid)
165 FIXME("(%p,%p) stub\n", policy, sid);
166 return STATUS_SUCCESS;
169 /******************************************************************************
170 * LsaEnumerateAccountRights [ADVAPI32.@]
173 NTSTATUS WINAPI LsaEnumerateAccountRights(
176 PLSA_UNICODE_STRING *rights,
179 FIXME("(%p,%p,%p,%p) stub\n", policy, sid, rights, count);
182 return STATUS_OBJECT_NAME_NOT_FOUND;
185 /******************************************************************************
186 * LsaEnumerateAccountsWithUserRight [ADVAPI32.@]
189 NTSTATUS WINAPI LsaEnumerateAccountsWithUserRight(
191 PLSA_UNICODE_STRING rights,
195 FIXME("(%p,%p,%p,%p) stub\n", policy, rights, buffer, count);
196 return STATUS_NO_MORE_ENTRIES;
199 /******************************************************************************
200 * LsaEnumerateTrustedDomains [ADVAPI32.@]
202 * Returns the names and SIDs of trusted domains.
205 * PolicyHandle [I] Handle to a Policy object.
206 * EnumerationContext [I] Pointer to an enumeration handle.
207 * Buffer [O] Contains the names and SIDs of trusted domains.
208 * PreferredMaximumLength[I] Preferred maximum size in bytes of Buffer.
209 * CountReturned [O] Number of elements in Buffer.
212 * Success: STATUS_SUCCESS,
213 * STATUS_MORE_ENTRIES,
214 * STATUS_NO_MORE_ENTRIES
215 * Failure: NTSTATUS code.
218 * LsaEnumerateTrustedDomains can be called multiple times to enumerate
219 * all trusted domains.
221 NTSTATUS WINAPI LsaEnumerateTrustedDomains(
222 IN LSA_HANDLE PolicyHandle,
223 IN PLSA_ENUMERATION_HANDLE EnumerationContext,
225 IN ULONG PreferredMaximumLength,
226 OUT PULONG CountReturned)
228 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", PolicyHandle, EnumerationContext,
229 Buffer, PreferredMaximumLength, CountReturned);
231 if (CountReturned) *CountReturned = 0;
232 return STATUS_SUCCESS;
235 /******************************************************************************
236 * LsaEnumerateTrustedDomainsEx [ADVAPI32.@]
239 NTSTATUS WINAPI LsaEnumerateTrustedDomainsEx(
241 PLSA_ENUMERATION_HANDLE context,
246 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", policy, context, buffer, length, count);
248 if (count) *count = 0;
249 return STATUS_SUCCESS;
252 /******************************************************************************
253 * LsaFreeMemory [ADVAPI32.@]
255 * Frees memory allocated by a LSA function.
258 * Buffer [I] Memory buffer to free.
261 * Success: STATUS_SUCCESS.
262 * Failure: NTSTATUS code.
264 NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
266 TRACE("(%p)\n", Buffer);
268 HeapFree(GetProcessHeap(), 0, Buffer);
269 return STATUS_SUCCESS;
272 /******************************************************************************
273 * LsaLookupNames [ADVAPI32.@]
275 * Returns the SIDs of an array of user, group, or local group names.
278 * PolicyHandle [I] Handle to a Policy object.
279 * Count [I] Number of names in Names.
280 * Names [I] Array of names to lookup.
281 * ReferencedDomains [O] Array of domains where the names were found.
282 * Sids [O] Array of SIDs corresponding to Names.
285 * Success: STATUS_SUCCESS,
286 * STATUS_SOME_NOT_MAPPED
287 * Failure: STATUS_NONE_MAPPED or NTSTATUS code.
289 NTSTATUS WINAPI LsaLookupNames(
290 IN LSA_HANDLE PolicyHandle,
292 IN PLSA_UNICODE_STRING Names,
293 OUT PLSA_REFERENCED_DOMAIN_LIST* ReferencedDomains,
294 OUT PLSA_TRANSLATED_SID* Sids)
296 FIXME("(%p,0x%08x,%p,%p,%p) stub\n", PolicyHandle, Count, Names,
297 ReferencedDomains, Sids);
299 return STATUS_NONE_MAPPED;
302 static BOOL lookup_name( LSA_UNICODE_STRING *name, SID *sid, DWORD *sid_size, WCHAR *domain,
303 DWORD *domain_size, SID_NAME_USE *use, BOOL *handled )
307 ret = lookup_local_wellknown_name( name, sid, sid_size, domain, domain_size, use, handled );
309 ret = lookup_local_user_name( name, sid, sid_size, domain, domain_size, use, handled );
314 /* Adds domain info to referenced domain list.
315 Domain list is stored as plain buffer, layout is:
317 LSA_REFERENCED_DOMAIN_LIST,
318 LSA_TRUST_INFORMATION array,
321 domain name data (WCHAR buffer),
326 list [I] referenced list pointer
327 domain [I] domain name string
328 data [IO] pointer to domain data array
330 static LONG lsa_reflist_add_domain(LSA_REFERENCED_DOMAIN_LIST *list, LSA_UNICODE_STRING *domain, char **data)
332 ULONG sid_size = 0,domain_size = 0;
333 BOOL handled = FALSE;
337 for (i = 0; i < list->Entries; i++)
339 /* try to reuse index */
340 if ((list->Domains[i].Name.Length == domain->Length) &&
341 (!strncmpiW(list->Domains[i].Name.Buffer, domain->Buffer, (domain->Length / sizeof(WCHAR)))))
347 /* no matching domain found, store name */
348 list->Domains[list->Entries].Name.Length = domain->Length;
349 list->Domains[list->Entries].Name.MaximumLength = domain->MaximumLength;
350 list->Domains[list->Entries].Name.Buffer = (WCHAR*)*data;
351 memcpy(list->Domains[list->Entries].Name.Buffer, domain->Buffer, domain->MaximumLength);
352 *data += domain->MaximumLength;
354 /* get and store SID data */
355 list->Domains[list->Entries].Sid = *data;
356 lookup_name(domain, NULL, &sid_size, NULL, &domain_size, &use, &handled);
358 lookup_name(domain, list->Domains[list->Entries].Sid, &sid_size, NULL, &domain_size, &use, &handled);
361 return list->Entries++;
364 /******************************************************************************
365 * LsaLookupNames2 [ADVAPI32.@]
368 NTSTATUS WINAPI LsaLookupNames2( LSA_HANDLE policy, ULONG flags, ULONG count,
369 PLSA_UNICODE_STRING names, PLSA_REFERENCED_DOMAIN_LIST *domains,
370 PLSA_TRANSLATED_SID2 *sids )
372 ULONG i, sid_size_total = 0, domain_size_max = 0, size, domainname_size_total = 0;
373 ULONG sid_size, domain_size, mapped;
374 BOOL handled = FALSE;
379 TRACE("(%p,0x%08x,0x%08x,%p,%p,%p)\n", policy, flags, count, names, domains, sids);
382 for (i = 0; i < count; i++)
385 sid_size = domain_size = 0;
386 lookup_name( &names[i], NULL, &sid_size, NULL, &domain_size, &use, &handled );
389 sid_size_total += sid_size;
390 domainname_size_total += domain_size;
393 if (domain_size > domain_size_max)
394 domain_size_max = domain_size;
399 TRACE("mapped %u out of %u\n", mapped, count);
401 size = sizeof(LSA_TRANSLATED_SID2) * count + sid_size_total;
402 if (!(*sids = heap_alloc(size))) return STATUS_NO_MEMORY;
404 sid = (SID *)(*sids + count);
406 /* use maximum domain count */
407 if (!(*domains = heap_alloc(sizeof(LSA_REFERENCED_DOMAIN_LIST) + sizeof(LSA_TRUST_INFORMATION)*count +
408 sid_size_total + domainname_size_total)))
411 return STATUS_NO_MEMORY;
413 (*domains)->Entries = 0;
414 (*domains)->Domains = (LSA_TRUST_INFORMATION*)((char*)*domains + sizeof(LSA_REFERENCED_DOMAIN_LIST));
415 domain_data = (char*)(*domains)->Domains + sizeof(LSA_TRUST_INFORMATION)*count;
417 for (i = 0; i < count; i++)
419 LSA_UNICODE_STRING domain;
421 domain.Length = domain_size_max*sizeof(WCHAR);
422 domain.MaximumLength = domain_size_max*sizeof(WCHAR);
423 domain.Buffer = heap_alloc(domain.Length);
425 (*sids)[i].Use = SidTypeUnknown;
426 (*sids)[i].DomainIndex = -1;
427 (*sids)[i].Flags = 0;
430 sid_size = sid_size_total;
431 domain_size = domain_size_max;
432 lookup_name( &names[i], sid, &sid_size, domain.Buffer, &domain_size, &use, &handled );
435 (*sids)[i].Sid = sid;
436 (*sids)[i].Use = use;
438 sid = (SID *)((char *)sid + sid_size);
439 sid_size_total -= sid_size;
442 domain.Length = domain_size * sizeof(WCHAR);
443 (*sids)[i].DomainIndex = lsa_reflist_add_domain(*domains, &domain, &domain_data);
447 heap_free(domain.Buffer);
450 if (mapped == count) return STATUS_SUCCESS;
451 if (mapped > 0 && mapped < count) return STATUS_SOME_NOT_MAPPED;
452 return STATUS_NONE_MAPPED;
455 /******************************************************************************
456 * LsaLookupSids [ADVAPI32.@]
458 * Looks up the names that correspond to an array of SIDs.
461 * PolicyHandle [I] Handle to a Policy object.
462 * Count [I] Number of SIDs in the Sids array.
463 * Sids [I] Array of SIDs to lookup.
464 * ReferencedDomains [O] Array of domains where the sids were found.
465 * Names [O] Array of names corresponding to Sids.
468 * Success: STATUS_SUCCESS,
469 * STATUS_SOME_NOT_MAPPED
470 * Failure: STATUS_NONE_MAPPED or NTSTATUS code.
472 NTSTATUS WINAPI LsaLookupSids(
473 LSA_HANDLE PolicyHandle,
476 LSA_REFERENCED_DOMAIN_LIST **ReferencedDomains,
477 LSA_TRANSLATED_NAME **Names)
479 ULONG i, mapped, name_fullsize, domain_fullsize;
480 ULONG name_size, domain_size;
481 LSA_UNICODE_STRING domain;
486 TRACE("(%p, %u, %p, %p, %p)\n", PolicyHandle, Count, Sids, ReferencedDomains, Names);
488 /* this length does not include actual string length yet */
489 name_fullsize = sizeof(LSA_TRANSLATED_NAME) * Count;
490 if (!(*Names = heap_alloc(name_fullsize))) return STATUS_NO_MEMORY;
491 /* maximum count of stored domain infos is Count, allocate it like that cause really needed
492 count could only be computed after sid data is retrieved */
493 domain_fullsize = sizeof(LSA_REFERENCED_DOMAIN_LIST) + sizeof(LSA_TRUST_INFORMATION)*Count;
494 if (!(*ReferencedDomains = heap_alloc(domain_fullsize)))
497 return STATUS_NO_MEMORY;
499 (*ReferencedDomains)->Entries = 0;
500 (*ReferencedDomains)->Domains = (LSA_TRUST_INFORMATION*)((char*)*ReferencedDomains + sizeof(LSA_REFERENCED_DOMAIN_LIST));
502 /* Get full names data length and full length needed to store domain name and SID */
503 for (i = 0; i < Count; i++)
505 (*Names)[i].Use = SidTypeUnknown;
506 (*Names)[i].DomainIndex = -1;
507 (*Names)[i].Name.Buffer = NULL;
509 memset(&(*ReferencedDomains)->Domains[i], 0, sizeof(LSA_TRUST_INFORMATION));
511 name_size = domain_size = 0;
512 if (!LookupAccountSidW(NULL, Sids[i], NULL, &name_size, NULL, &domain_size, &use) &&
513 GetLastError() == ERROR_INSUFFICIENT_BUFFER)
517 (*Names)[i].Name.Length = (name_size - 1) * sizeof(WCHAR);
518 (*Names)[i].Name.MaximumLength = name_size * sizeof(WCHAR);
519 name_fullsize += (*Names)[i].Name.MaximumLength;
523 (*Names)[i].Name.Length = 0;
524 (*Names)[i].Name.MaximumLength = 0;
527 /* This potentially allocates more than needed, cause different names will reuse same domain index.
528 Also it's not possible to store domain name length right here for the same reason. */
532 BOOL handled = FALSE;
535 domain_fullsize += domain_size * sizeof(WCHAR);
537 /* get domain SID size too */
538 name = heap_alloc(domain_size * sizeof(WCHAR));
540 LookupAccountSidW(NULL, Sids[i], NULL, &name_size, name, &domain_size, &use);
542 domain.Buffer = name;
543 domain.Length = domain_size * sizeof(WCHAR);
544 domain.MaximumLength = domain_size * sizeof(WCHAR);
546 lookup_name(&domain, NULL, &sid_size, NULL, &domain_size, &use, &handled);
547 domain_fullsize += sid_size;
554 /* now we have full length needed for both */
555 *Names = heap_realloc(*Names, name_fullsize);
556 name_buffer = (WCHAR*)((char*)*Names + sizeof(LSA_TRANSLATED_NAME)*Count);
558 *ReferencedDomains = heap_realloc(*ReferencedDomains, domain_fullsize);
559 /* fix pointer after reallocation */
560 (*ReferencedDomains)->Domains = (LSA_TRUST_INFORMATION*)((char*)*ReferencedDomains + sizeof(LSA_REFERENCED_DOMAIN_LIST));
561 domain_data = (char*)(*ReferencedDomains)->Domains + sizeof(LSA_TRUST_INFORMATION)*Count;
564 for (i = 0; i < Count; i++)
566 name_size = domain_size = 0;
568 if (!LookupAccountSidW(NULL, Sids[i], NULL, &name_size, NULL, &domain_size, &use) &&
569 GetLastError() == ERROR_INSUFFICIENT_BUFFER)
575 domain.Length = (domain_size - 1) * sizeof(WCHAR);
576 domain.MaximumLength = domain_size * sizeof(WCHAR);
577 domain.Buffer = heap_alloc(domain.MaximumLength);
580 (*Names)[i].Name.Buffer = name_buffer;
581 LookupAccountSidW(NULL, Sids[i], (*Names)[i].Name.Buffer, &name_size, domain.Buffer, &domain_size, &use);
582 (*Names)[i].Use = use;
586 (*Names)[i].DomainIndex = lsa_reflist_add_domain(*ReferencedDomains, &domain, &domain_data);
587 heap_free(domain.Buffer);
591 name_buffer += name_size;
593 TRACE("mapped %u out of %u\n", mapped, Count);
595 if (mapped == Count) return STATUS_SUCCESS;
596 if (mapped) return STATUS_SOME_NOT_MAPPED;
597 return STATUS_NONE_MAPPED;
600 /******************************************************************************
601 * LsaNtStatusToWinError [ADVAPI32.@]
603 * Converts an LSA NTSTATUS code to a Windows error code.
606 * Status [I] NTSTATUS code.
609 * Success: Corresponding Windows error code.
610 * Failure: ERROR_MR_MID_NOT_FOUND.
612 ULONG WINAPI LsaNtStatusToWinError(NTSTATUS Status)
614 return RtlNtStatusToDosError(Status);
617 /******************************************************************************
618 * LsaOpenPolicy [ADVAPI32.@]
620 * Opens a handle to the Policy object on a local or remote system.
623 * SystemName [I] Name of the target system.
624 * ObjectAttributes [I] Connection attributes.
625 * DesiredAccess [I] Requested access rights.
626 * PolicyHandle [I/O] Handle to the Policy object.
629 * Success: STATUS_SUCCESS.
630 * Failure: NTSTATUS code.
633 * Set SystemName to NULL to open the local Policy object.
635 NTSTATUS WINAPI LsaOpenPolicy(
636 IN PLSA_UNICODE_STRING SystemName,
637 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
638 IN ACCESS_MASK DesiredAccess,
639 IN OUT PLSA_HANDLE PolicyHandle)
641 FIXME("(%s,%p,0x%08x,%p) stub\n",
642 SystemName?debugstr_w(SystemName->Buffer):"(null)",
643 ObjectAttributes, DesiredAccess, PolicyHandle);
645 ADVAPI_ForceLocalComputer(SystemName ? SystemName->Buffer : NULL,
646 STATUS_ACCESS_VIOLATION);
647 dumpLsaAttributes(ObjectAttributes);
649 if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe;
650 return STATUS_SUCCESS;
653 /******************************************************************************
654 * LsaOpenTrustedDomainByName [ADVAPI32.@]
657 NTSTATUS WINAPI LsaOpenTrustedDomainByName(
659 PLSA_UNICODE_STRING name,
663 FIXME("(%p,%p,0x%08x,%p) stub\n", policy, name, access, handle);
664 return STATUS_OBJECT_NAME_NOT_FOUND;
667 /******************************************************************************
668 * LsaQueryInformationPolicy [ADVAPI32.@]
670 * Returns information about a Policy object.
673 * PolicyHandle [I] Handle to a Policy object.
674 * InformationClass [I] Type of information to retrieve.
675 * Buffer [O] Pointer to the requested information.
678 * Success: STATUS_SUCCESS.
679 * Failure: NTSTATUS code.
681 NTSTATUS WINAPI LsaQueryInformationPolicy(
682 IN LSA_HANDLE PolicyHandle,
683 IN POLICY_INFORMATION_CLASS InformationClass,
686 TRACE("(%p,0x%08x,%p)\n", PolicyHandle, InformationClass, Buffer);
688 if(!Buffer) return STATUS_INVALID_PARAMETER;
689 switch (InformationClass)
691 case PolicyAuditEventsInformation: /* 2 */
693 PPOLICY_AUDIT_EVENTS_INFO p = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
694 sizeof(POLICY_AUDIT_EVENTS_INFO));
695 p->AuditingMode = FALSE; /* no auditing */
699 case PolicyPrimaryDomainInformation: /* 3 */
701 /* Only the domain name is valid for the local computer.
702 * All other fields are zero.
704 PPOLICY_PRIMARY_DOMAIN_INFO pinfo;
706 pinfo = ADVAPI_GetDomainName(sizeof(*pinfo), offsetof(POLICY_PRIMARY_DOMAIN_INFO, Name));
708 TRACE("setting domain to %s\n", debugstr_w(pinfo->Name.Buffer));
713 case PolicyAccountDomainInformation: /* 5 */
717 POLICY_ACCOUNT_DOMAIN_INFO info;
720 WCHAR domain[MAX_COMPUTERNAME_LENGTH + 1];
723 DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
724 struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*xdi));
726 xdi->info.DomainName.MaximumLength = dwSize * sizeof(WCHAR);
727 xdi->info.DomainName.Buffer = xdi->domain;
728 if (GetComputerNameW(xdi->info.DomainName.Buffer, &dwSize))
729 xdi->info.DomainName.Length = dwSize * sizeof(WCHAR);
731 TRACE("setting name to %s\n", debugstr_w(xdi->info.DomainName.Buffer));
733 xdi->info.DomainSid = &xdi->sid;
735 if (!ADVAPI_GetComputerSid(&xdi->sid))
737 HeapFree(GetProcessHeap(), 0, xdi);
739 WARN("Computer SID not found\n");
741 return STATUS_UNSUCCESSFUL;
744 TRACE("setting SID to %s\n", debugstr_sid(&xdi->sid));
749 case PolicyDnsDomainInformation: /* 12 (0xc) */
751 /* Only the domain name is valid for the local computer.
752 * All other fields are zero.
754 PPOLICY_DNS_DOMAIN_INFO pinfo;
756 pinfo = ADVAPI_GetDomainName(sizeof(*pinfo), offsetof(POLICY_DNS_DOMAIN_INFO, Name));
758 TRACE("setting domain to %s\n", debugstr_w(pinfo->Name.Buffer));
763 case PolicyAuditLogInformation:
764 case PolicyPdAccountInformation:
765 case PolicyLsaServerRoleInformation:
766 case PolicyReplicaSourceInformation:
767 case PolicyDefaultQuotaInformation:
768 case PolicyModificationInformation:
769 case PolicyAuditFullSetInformation:
770 case PolicyAuditFullQueryInformation:
772 FIXME("category %d not implemented\n", InformationClass);
773 return STATUS_UNSUCCESSFUL;
776 return STATUS_SUCCESS;
779 /******************************************************************************
780 * LsaQueryTrustedDomainInfo [ADVAPI32.@]
783 NTSTATUS WINAPI LsaQueryTrustedDomainInfo(
786 TRUSTED_INFORMATION_CLASS class,
789 FIXME("(%p,%p,%d,%p) stub\n", policy, sid, class, buffer);
790 return STATUS_OBJECT_NAME_NOT_FOUND;
793 /******************************************************************************
794 * LsaQueryTrustedDomainInfoByName [ADVAPI32.@]
797 NTSTATUS WINAPI LsaQueryTrustedDomainInfoByName(
799 PLSA_UNICODE_STRING name,
800 TRUSTED_INFORMATION_CLASS class,
803 FIXME("(%p,%p,%d,%p) stub\n", policy, name, class, buffer);
804 return STATUS_OBJECT_NAME_NOT_FOUND;
807 /******************************************************************************
808 * LsaRegisterPolicyChangeNotification [ADVAPI32.@]
811 NTSTATUS WINAPI LsaRegisterPolicyChangeNotification(
812 POLICY_NOTIFICATION_INFORMATION_CLASS class,
815 FIXME("(%d,%p) stub\n", class, event);
816 return STATUS_UNSUCCESSFUL;
819 /******************************************************************************
820 * LsaRemoveAccountRights [ADVAPI32.@]
823 NTSTATUS WINAPI LsaRemoveAccountRights(
827 PLSA_UNICODE_STRING rights,
830 FIXME("(%p,%p,%d,%p,0x%08x) stub\n", policy, sid, all, rights, count);
831 return STATUS_SUCCESS;
834 /******************************************************************************
835 * LsaRetrievePrivateData [ADVAPI32.@]
837 * Retrieves data stored by LsaStorePrivateData.
840 * PolicyHandle [I] Handle to a Policy object.
841 * KeyName [I] Name of the key where the data is stored.
842 * PrivateData [O] Pointer to the private data.
845 * Success: STATUS_SUCCESS.
846 * Failure: STATUS_OBJECT_NAME_NOT_FOUND or NTSTATUS code.
848 NTSTATUS WINAPI LsaRetrievePrivateData(
849 IN LSA_HANDLE PolicyHandle,
850 IN PLSA_UNICODE_STRING KeyName,
851 OUT PLSA_UNICODE_STRING* PrivateData)
853 FIXME("(%p,%p,%p) stub\n", PolicyHandle, KeyName, PrivateData);
854 return STATUS_OBJECT_NAME_NOT_FOUND;
857 /******************************************************************************
858 * LsaSetInformationPolicy [ADVAPI32.@]
860 * Modifies information in a Policy object.
863 * PolicyHandle [I] Handle to a Policy object.
864 * InformationClass [I] Type of information to set.
865 * Buffer [I] Pointer to the information to set.
868 * Success: STATUS_SUCCESS.
869 * Failure: NTSTATUS code.
871 NTSTATUS WINAPI LsaSetInformationPolicy(
872 IN LSA_HANDLE PolicyHandle,
873 IN POLICY_INFORMATION_CLASS InformationClass,
876 FIXME("(%p,0x%08x,%p) stub\n", PolicyHandle, InformationClass, Buffer);
878 return STATUS_UNSUCCESSFUL;
881 /******************************************************************************
882 * LsaSetSecret [ADVAPI32.@]
884 * Set old and new values on a secret handle
887 * SecretHandle [I] Handle to a secret object.
888 * EncryptedCurrentValue [I] Pointer to encrypted new value, can be NULL
889 * EncryptedOldValue [I] Pointer to encrypted old value, can be NULL
892 * Success: STATUS_SUCCESS
893 * Failure: NTSTATUS code.
895 NTSTATUS WINAPI LsaSetSecret(
896 IN LSA_HANDLE SecretHandle,
897 IN PLSA_UNICODE_STRING EncryptedCurrentValue,
898 IN PLSA_UNICODE_STRING EncryptedOldValue)
900 FIXME("(%p,%p,%p) stub\n", SecretHandle, EncryptedCurrentValue,
902 return STATUS_SUCCESS;
905 /******************************************************************************
906 * LsaSetTrustedDomainInfoByName [ADVAPI32.@]
909 NTSTATUS WINAPI LsaSetTrustedDomainInfoByName(
911 PLSA_UNICODE_STRING name,
912 TRUSTED_INFORMATION_CLASS class,
915 FIXME("(%p,%p,%d,%p) stub\n", policy, name, class, buffer);
916 return STATUS_SUCCESS;
919 /******************************************************************************
920 * LsaSetTrustedDomainInformation [ADVAPI32.@]
923 NTSTATUS WINAPI LsaSetTrustedDomainInformation(
926 TRUSTED_INFORMATION_CLASS class,
929 FIXME("(%p,%p,%d,%p) stub\n", policy, sid, class, buffer);
930 return STATUS_SUCCESS;
933 /******************************************************************************
934 * LsaStorePrivateData [ADVAPI32.@]
936 * Stores or deletes a Policy object's data under the specified reg key.
939 * PolicyHandle [I] Handle to a Policy object.
940 * KeyName [I] Name of the key where the data will be stored.
941 * PrivateData [O] Pointer to the private data.
944 * Success: STATUS_SUCCESS.
945 * Failure: STATUS_OBJECT_NAME_NOT_FOUND or NTSTATUS code.
947 NTSTATUS WINAPI LsaStorePrivateData(
948 IN LSA_HANDLE PolicyHandle,
949 IN PLSA_UNICODE_STRING KeyName,
950 IN PLSA_UNICODE_STRING PrivateData)
952 FIXME("(%p,%p,%p) stub\n", PolicyHandle, KeyName, PrivateData);
953 return STATUS_OBJECT_NAME_NOT_FOUND;
956 /******************************************************************************
957 * LsaUnregisterPolicyChangeNotification [ADVAPI32.@]
960 NTSTATUS WINAPI LsaUnregisterPolicyChangeNotification(
961 POLICY_NOTIFICATION_INFORMATION_CLASS class,
964 FIXME("(%d,%p) stub\n", class, event);
965 return STATUS_SUCCESS;