oleaut32: Rewrite ITypeInfo_GetDocumentation proxy/stub to return only the informatio...
[wine.git] / dlls / advapi32 / lsa.c
blob863ddb248e3c2a75f0468330dff940be8e2c92f5
1 /*
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
24 #include <stdarg.h>
26 #include "ntstatus.h"
27 #define WIN32_NO_STATUS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31 #include "winternl.h"
32 #include "ntsecapi.h"
33 #include "advapi32_misc.h"
35 #include "wine/debug.h"
36 #include "wine/unicode.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
40 #define ADVAPI_ForceLocalComputer(ServerName, FailureCode) \
41 if (!ADVAPI_IsLocalComputer(ServerName)) \
42 { \
43 FIXME("Action Implemented for local computer only. " \
44 "Requested for server %s\n", debugstr_w(ServerName)); \
45 return FailureCode; \
48 static void dumpLsaAttributes(const LSA_OBJECT_ATTRIBUTES *oa)
50 if (oa)
52 TRACE("\n\tlength=%u, rootdir=%p, objectname=%s\n\tattr=0x%08x, sid=%s qos=%p\n",
53 oa->Length, oa->RootDirectory,
54 oa->ObjectName?debugstr_w(oa->ObjectName->Buffer):"null",
55 oa->Attributes, debugstr_sid(oa->SecurityDescriptor),
56 oa->SecurityQualityOfService);
60 static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
62 HKEY key;
63 LONG ret;
64 BYTE* ptr = NULL;
65 UNICODE_STRING* ustr;
67 static const WCHAR wVNETSUP[] = {
68 'S','y','s','t','e','m','\\',
69 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
70 'S','e','r','v','i','c','e','s','\\',
71 'V','x','D','\\','V','N','E','T','S','U','P','\0'};
73 ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wVNETSUP, 0, KEY_READ, &key);
74 if (ret == ERROR_SUCCESS)
76 DWORD size = 0;
77 static const WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 };
79 ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size);
80 if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
82 ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sz + size);
83 if (!ptr) return NULL;
84 ustr = (UNICODE_STRING*)(ptr + ofs);
85 ustr->MaximumLength = size;
86 ustr->Buffer = (WCHAR*)(ptr + sz);
87 ret = RegQueryValueExW(key, wg, NULL, NULL, (LPBYTE)ustr->Buffer, &size);
88 if (ret != ERROR_SUCCESS)
90 HeapFree(GetProcessHeap(), 0, ptr);
91 ptr = NULL;
93 else ustr->Length = size - sizeof(WCHAR);
95 RegCloseKey(key);
97 if (!ptr)
99 static const WCHAR wDomain[] = {'D','O','M','A','I','N','\0'};
100 ptr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
101 sz + sizeof(wDomain));
102 if (!ptr) return NULL;
103 ustr = (UNICODE_STRING*)(ptr + ofs);
104 ustr->MaximumLength = sizeof(wDomain);
105 ustr->Buffer = (WCHAR*)(ptr + sz);
106 ustr->Length = sizeof(wDomain) - sizeof(WCHAR);
107 memcpy(ustr->Buffer, wDomain, sizeof(wDomain));
109 return ptr;
112 /******************************************************************************
113 * LsaAddAccountRights [ADVAPI32.@]
116 NTSTATUS WINAPI LsaAddAccountRights(
117 LSA_HANDLE policy,
118 PSID sid,
119 PLSA_UNICODE_STRING rights,
120 ULONG count)
122 FIXME("(%p,%p,%p,0x%08x) stub\n", policy, sid, rights, count);
123 return STATUS_OBJECT_NAME_NOT_FOUND;
126 /******************************************************************************
127 * LsaClose [ADVAPI32.@]
129 * Closes a handle to a Policy or TrustedDomain.
131 * PARAMS
132 * ObjectHandle [I] Handle to a Policy or TrustedDomain.
134 * RETURNS
135 * Success: STATUS_SUCCESS.
136 * Failure: NTSTATUS code.
138 NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle)
140 FIXME("(%p) stub\n", ObjectHandle);
141 return STATUS_SUCCESS;
144 /******************************************************************************
145 * LsaCreateTrustedDomainEx [ADVAPI32.@]
148 NTSTATUS WINAPI LsaCreateTrustedDomainEx(
149 LSA_HANDLE policy,
150 PTRUSTED_DOMAIN_INFORMATION_EX domain_info,
151 PTRUSTED_DOMAIN_AUTH_INFORMATION auth_info,
152 ACCESS_MASK access,
153 PLSA_HANDLE domain)
155 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", policy, domain_info, auth_info,
156 access, domain);
157 return STATUS_SUCCESS;
160 /******************************************************************************
161 * LsaDeleteTrustedDomain [ADVAPI32.@]
164 NTSTATUS WINAPI LsaDeleteTrustedDomain(LSA_HANDLE policy, PSID sid)
166 FIXME("(%p,%p) stub\n", policy, sid);
167 return STATUS_SUCCESS;
170 /******************************************************************************
171 * LsaEnumerateAccountRights [ADVAPI32.@]
174 NTSTATUS WINAPI LsaEnumerateAccountRights(
175 LSA_HANDLE policy,
176 PSID sid,
177 PLSA_UNICODE_STRING *rights,
178 PULONG count)
180 FIXME("(%p,%p,%p,%p) stub\n", policy, sid, rights, count);
181 *rights = 0;
182 *count = 0;
183 return STATUS_OBJECT_NAME_NOT_FOUND;
186 /******************************************************************************
187 * LsaEnumerateAccountsWithUserRight [ADVAPI32.@]
190 NTSTATUS WINAPI LsaEnumerateAccountsWithUserRight(
191 LSA_HANDLE policy,
192 PLSA_UNICODE_STRING rights,
193 PVOID *buffer,
194 PULONG count)
196 FIXME("(%p,%p,%p,%p) stub\n", policy, rights, buffer, count);
197 return STATUS_NO_MORE_ENTRIES;
200 /******************************************************************************
201 * LsaEnumerateTrustedDomains [ADVAPI32.@]
203 * Returns the names and SIDs of trusted domains.
205 * PARAMS
206 * PolicyHandle [I] Handle to a Policy object.
207 * EnumerationContext [I] Pointer to an enumeration handle.
208 * Buffer [O] Contains the names and SIDs of trusted domains.
209 * PreferredMaximumLength[I] Preferred maximum size in bytes of Buffer.
210 * CountReturned [O] Number of elements in Buffer.
212 * RETURNS
213 * Success: STATUS_SUCCESS,
214 * STATUS_MORE_ENTRIES,
215 * STATUS_NO_MORE_ENTRIES
216 * Failure: NTSTATUS code.
218 * NOTES
219 * LsaEnumerateTrustedDomains can be called multiple times to enumerate
220 * all trusted domains.
222 NTSTATUS WINAPI LsaEnumerateTrustedDomains(
223 IN LSA_HANDLE PolicyHandle,
224 IN PLSA_ENUMERATION_HANDLE EnumerationContext,
225 OUT PVOID* Buffer,
226 IN ULONG PreferredMaximumLength,
227 OUT PULONG CountReturned)
229 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", PolicyHandle, EnumerationContext,
230 Buffer, PreferredMaximumLength, CountReturned);
232 if (CountReturned) *CountReturned = 0;
233 return STATUS_SUCCESS;
236 /******************************************************************************
237 * LsaEnumerateTrustedDomainsEx [ADVAPI32.@]
240 NTSTATUS WINAPI LsaEnumerateTrustedDomainsEx(
241 LSA_HANDLE policy,
242 PLSA_ENUMERATION_HANDLE context,
243 PVOID *buffer,
244 ULONG length,
245 PULONG count)
247 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", policy, context, buffer, length, count);
249 if (count) *count = 0;
250 return STATUS_SUCCESS;
253 /******************************************************************************
254 * LsaFreeMemory [ADVAPI32.@]
256 * Frees memory allocated by a LSA function.
258 * PARAMS
259 * Buffer [I] Memory buffer to free.
261 * RETURNS
262 * Success: STATUS_SUCCESS.
263 * Failure: NTSTATUS code.
265 NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
267 TRACE("(%p)\n", Buffer);
269 HeapFree(GetProcessHeap(), 0, Buffer);
270 return STATUS_SUCCESS;
273 /******************************************************************************
274 * LsaLookupNames [ADVAPI32.@]
276 * Returns the SIDs of an array of user, group, or local group names.
278 * PARAMS
279 * PolicyHandle [I] Handle to a Policy object.
280 * Count [I] Number of names in Names.
281 * Names [I] Array of names to lookup.
282 * ReferencedDomains [O] Array of domains where the names were found.
283 * Sids [O] Array of SIDs corresponding to Names.
285 * RETURNS
286 * Success: STATUS_SUCCESS,
287 * STATUS_SOME_NOT_MAPPED
288 * Failure: STATUS_NONE_MAPPED or NTSTATUS code.
290 NTSTATUS WINAPI LsaLookupNames(
291 IN LSA_HANDLE PolicyHandle,
292 IN ULONG Count,
293 IN PLSA_UNICODE_STRING Names,
294 OUT PLSA_REFERENCED_DOMAIN_LIST* ReferencedDomains,
295 OUT PLSA_TRANSLATED_SID* Sids)
297 FIXME("(%p,0x%08x,%p,%p,%p) stub\n", PolicyHandle, Count, Names,
298 ReferencedDomains, Sids);
300 return STATUS_NONE_MAPPED;
303 static BOOL lookup_name( LSA_UNICODE_STRING *name, SID *sid, DWORD *sid_size, WCHAR *domain,
304 DWORD *domain_size, SID_NAME_USE *use, BOOL *handled )
306 BOOL ret;
308 ret = lookup_local_wellknown_name( name, sid, sid_size, domain, domain_size, use, handled );
309 if (!*handled)
310 ret = lookup_local_user_name( name, sid, sid_size, domain, domain_size, use, handled );
312 return ret;
315 static INT build_domain(PLSA_REFERENCED_DOMAIN_LIST currentList, PLSA_UNICODE_STRING domain)
317 ULONG count;
318 ULONG sid_size = 0,domain_size = 0;
319 BOOL handled = FALSE;
320 SID_NAME_USE use;
322 for (count = 0; count < currentList->Entries; count ++)
324 if ((currentList->Domains[count].Name.Length == domain->Length) &&
325 (strncmpiW(currentList->Domains[count].Name.Buffer,domain->Buffer,(domain->Length / sizeof(WCHAR))) == 0))
327 HeapFree(GetProcessHeap(),0,domain->Buffer);
328 return count;
332 if (currentList->Entries > 0)
333 currentList->Domains = HeapReAlloc(GetProcessHeap(),0,currentList->Domains, (currentList->Entries + 1) * sizeof(LSA_TRUST_INFORMATION));
334 else
335 currentList->Domains = HeapAlloc(GetProcessHeap(),0,sizeof(LSA_TRUST_INFORMATION));
337 currentList->Domains[currentList->Entries].Name = *domain;
339 lookup_name( domain, NULL, &sid_size, NULL, &domain_size, &use, &handled );
340 domain_size = 0;
341 currentList->Domains[currentList->Entries].Sid = HeapAlloc(GetProcessHeap(),0,sid_size);
342 lookup_name( domain, currentList->Domains[currentList->Entries].Sid, &sid_size, NULL, &domain_size, &use, &handled );
344 currentList->Entries++;
345 return currentList->Entries-1;
348 /******************************************************************************
349 * LsaLookupNames2 [ADVAPI32.@]
352 NTSTATUS WINAPI LsaLookupNames2( LSA_HANDLE policy, ULONG flags, ULONG count,
353 PLSA_UNICODE_STRING names, PLSA_REFERENCED_DOMAIN_LIST *domains,
354 PLSA_TRANSLATED_SID2 *sids )
356 ULONG i, sid_size_total = 0, domain_size_max = 0, size;
357 ULONG sid_size, domain_size, mapped;
358 BOOL handled = FALSE;
359 SID_NAME_USE use;
360 SID *sid;
362 TRACE("(%p,0x%08x,0x%08x,%p,%p,%p)\n", policy, flags, count, names, domains, sids);
364 mapped = 0;
365 for (i = 0; i < count; i++)
367 handled = FALSE;
368 sid_size = domain_size = 0;
369 lookup_name( &names[i], NULL, &sid_size, NULL, &domain_size, &use, &handled );
370 if (handled)
372 sid_size_total += sid_size;
373 if (domain_size)
375 if (domain_size > domain_size_max)
376 domain_size_max = domain_size;
378 mapped++;
381 TRACE("mapped %u out of %u\n", mapped, count);
383 size = sizeof(LSA_TRANSLATED_SID2) * count + sid_size_total;
384 if (!(*sids = HeapAlloc( GetProcessHeap(), 0, size) )) return STATUS_NO_MEMORY;
386 sid = (SID *)(*sids + count);
388 if (!(*domains = HeapAlloc( GetProcessHeap(), 0, sizeof(LSA_REFERENCED_DOMAIN_LIST) )))
390 HeapFree( GetProcessHeap(), 0, *sids );
391 return STATUS_NO_MEMORY;
393 (*domains)->Entries = 0;
394 (*domains)->Domains = NULL;
396 for (i = 0; i < count; i++)
398 LSA_UNICODE_STRING domain;
400 domain.Length = domain_size_max*sizeof(WCHAR);
401 domain.MaximumLength = domain_size_max*sizeof(WCHAR);
402 domain.Buffer = HeapAlloc(GetProcessHeap(),0,domain.Length);
404 (*sids)[i].Use = SidTypeUnknown;
405 (*sids)[i].DomainIndex = -1;
406 (*sids)[i].Flags = 0;
408 handled = FALSE;
409 sid_size = sid_size_total;
410 domain_size = domain_size_max;
411 lookup_name( &names[i], sid, &sid_size, domain.Buffer, &domain_size, &use, &handled );
412 if (handled)
414 (*sids)[i].Sid = sid;
415 (*sids)[i].Use = use;
417 sid += sid_size;
418 sid_size_total -= sid_size;
419 if (domain_size)
421 domain.Length = domain_size * sizeof(WCHAR);
422 (*sids)[i].DomainIndex = build_domain(*domains, &domain);
424 else
425 HeapFree(GetProcessHeap(),0,domain.Buffer);
427 else
428 HeapFree(GetProcessHeap(),0,domain.Buffer);
431 if (mapped == count) return STATUS_SUCCESS;
432 if (mapped > 0 && mapped < count) return STATUS_SOME_NOT_MAPPED;
433 return STATUS_NONE_MAPPED;
436 /******************************************************************************
437 * LsaLookupSids [ADVAPI32.@]
439 * Looks up the names that correspond to an array of SIDs.
441 * PARAMS
442 * PolicyHandle [I] Handle to a Policy object.
443 * Count [I] Number of SIDs in the Sids array.
444 * Sids [I] Array of SIDs to lookup.
445 * ReferencedDomains [O] Array of domains where the sids were found.
446 * Names [O] Array of names corresponding to Sids.
448 * RETURNS
449 * Success: STATUS_SUCCESS,
450 * STATUS_SOME_NOT_MAPPED
451 * Failure: STATUS_NONE_MAPPED or NTSTATUS code.
453 NTSTATUS WINAPI LsaLookupSids(
454 IN LSA_HANDLE PolicyHandle,
455 IN ULONG Count,
456 IN PSID *Sids,
457 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
458 OUT PLSA_TRANSLATED_NAME *Names )
460 ULONG i, mapped, size;
461 ULONG name_size, domain_size;
462 SID_NAME_USE use;
464 TRACE("(%p,%u,%p,%p,%p) stub\n", PolicyHandle, Count, Sids,
465 ReferencedDomains, Names);
467 size = sizeof(LSA_TRANSLATED_NAME) * Count;
468 if (!(*Names = HeapAlloc( GetProcessHeap(), 0, size) )) return STATUS_NO_MEMORY;
469 if (!(*ReferencedDomains = HeapAlloc( GetProcessHeap(), 0, sizeof(LSA_REFERENCED_DOMAIN_LIST)) ))
471 HeapFree( GetProcessHeap(), 0, *Names);
472 return STATUS_NO_MEMORY;
474 (*ReferencedDomains)->Entries = 0;
475 (*ReferencedDomains)->Domains = NULL;
477 mapped = 0;
478 for (i = 0; i < Count; i++)
480 name_size = domain_size = 0;
481 (*Names)[i].Use = SidTypeUnknown;
482 (*Names)[i].DomainIndex = -1;
483 (*Names)[i].Name.Length = 0;
484 (*Names)[i].Name.MaximumLength = 0;
485 (*Names)[i].Name.Buffer = NULL;
487 if (!LookupAccountSidW(NULL, Sids[i], NULL, &name_size, NULL, &domain_size, &use) &&
488 GetLastError() == ERROR_INSUFFICIENT_BUFFER)
490 LSA_UNICODE_STRING domain;
492 mapped++;
494 if (domain_size)
496 domain.Length = (domain_size - 1) * sizeof(WCHAR);
497 domain.MaximumLength = domain_size*sizeof(WCHAR);
498 domain.Buffer = HeapAlloc(GetProcessHeap(),0,domain.MaximumLength);
500 else
502 domain.Length = 0;
503 domain.MaximumLength = 0;
504 domain.Buffer = NULL;
507 (*Names)[i].Name.Length = (name_size - 1) * sizeof(WCHAR);
508 (*Names)[i].Name.MaximumLength = name_size * sizeof(WCHAR);
509 (*Names)[i].Name.Buffer = HeapAlloc(GetProcessHeap(), 0, name_size * sizeof(WCHAR));
510 LookupAccountSidW(NULL, Sids[i], (*Names)[i].Name.Buffer, &name_size, domain.Buffer, &domain_size, &use);
511 (*Names)[i].Use = use;
513 if (domain_size)
514 (*Names)[i].DomainIndex = build_domain(*ReferencedDomains, &domain);
517 TRACE("mapped %u out of %u\n",mapped,Count);
519 if (mapped == Count) return STATUS_SUCCESS;
520 if (mapped) return STATUS_SOME_NOT_MAPPED;
521 return STATUS_NONE_MAPPED;
524 /******************************************************************************
525 * LsaNtStatusToWinError [ADVAPI32.@]
527 * Converts an LSA NTSTATUS code to a Windows error code.
529 * PARAMS
530 * Status [I] NTSTATUS code.
532 * RETURNS
533 * Success: Corresponding Windows error code.
534 * Failure: ERROR_MR_MID_NOT_FOUND.
536 ULONG WINAPI LsaNtStatusToWinError(NTSTATUS Status)
538 return RtlNtStatusToDosError(Status);
541 /******************************************************************************
542 * LsaOpenPolicy [ADVAPI32.@]
544 * Opens a handle to the Policy object on a local or remote system.
546 * PARAMS
547 * SystemName [I] Name of the target system.
548 * ObjectAttributes [I] Connection attributes.
549 * DesiredAccess [I] Requested access rights.
550 * PolicyHandle [I/O] Handle to the Policy object.
552 * RETURNS
553 * Success: STATUS_SUCCESS.
554 * Failure: NTSTATUS code.
556 * NOTES
557 * Set SystemName to NULL to open the local Policy object.
559 NTSTATUS WINAPI LsaOpenPolicy(
560 IN PLSA_UNICODE_STRING SystemName,
561 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
562 IN ACCESS_MASK DesiredAccess,
563 IN OUT PLSA_HANDLE PolicyHandle)
565 FIXME("(%s,%p,0x%08x,%p) stub\n",
566 SystemName?debugstr_w(SystemName->Buffer):"(null)",
567 ObjectAttributes, DesiredAccess, PolicyHandle);
569 ADVAPI_ForceLocalComputer(SystemName ? SystemName->Buffer : NULL,
570 STATUS_ACCESS_VIOLATION);
571 dumpLsaAttributes(ObjectAttributes);
573 if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe;
574 return STATUS_SUCCESS;
577 /******************************************************************************
578 * LsaOpenTrustedDomainByName [ADVAPI32.@]
581 NTSTATUS WINAPI LsaOpenTrustedDomainByName(
582 LSA_HANDLE policy,
583 PLSA_UNICODE_STRING name,
584 ACCESS_MASK access,
585 PLSA_HANDLE handle)
587 FIXME("(%p,%p,0x%08x,%p) stub\n", policy, name, access, handle);
588 return STATUS_OBJECT_NAME_NOT_FOUND;
591 /******************************************************************************
592 * LsaQueryInformationPolicy [ADVAPI32.@]
594 * Returns information about a Policy object.
596 * PARAMS
597 * PolicyHandle [I] Handle to a Policy object.
598 * InformationClass [I] Type of information to retrieve.
599 * Buffer [O] Pointer to the requested information.
601 * RETURNS
602 * Success: STATUS_SUCCESS.
603 * Failure: NTSTATUS code.
605 NTSTATUS WINAPI LsaQueryInformationPolicy(
606 IN LSA_HANDLE PolicyHandle,
607 IN POLICY_INFORMATION_CLASS InformationClass,
608 OUT PVOID *Buffer)
610 TRACE("(%p,0x%08x,%p)\n", PolicyHandle, InformationClass, Buffer);
612 if(!Buffer) return STATUS_INVALID_PARAMETER;
613 switch (InformationClass)
615 case PolicyAuditEventsInformation: /* 2 */
617 PPOLICY_AUDIT_EVENTS_INFO p = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
618 sizeof(POLICY_AUDIT_EVENTS_INFO));
619 p->AuditingMode = FALSE; /* no auditing */
620 *Buffer = p;
622 break;
623 case PolicyPrimaryDomainInformation: /* 3 */
625 /* Only the domain name is valid for the local computer.
626 * All other fields are zero.
628 PPOLICY_PRIMARY_DOMAIN_INFO pinfo;
630 pinfo = ADVAPI_GetDomainName(sizeof(*pinfo), offsetof(POLICY_PRIMARY_DOMAIN_INFO, Name));
632 TRACE("setting domain to %s\n", debugstr_w(pinfo->Name.Buffer));
634 *Buffer = pinfo;
636 break;
637 case PolicyAccountDomainInformation: /* 5 */
639 struct di
641 POLICY_ACCOUNT_DOMAIN_INFO info;
642 SID sid;
643 DWORD padding[3];
644 WCHAR domain[MAX_COMPUTERNAME_LENGTH + 1];
647 DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
648 struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*xdi));
650 xdi->info.DomainName.MaximumLength = dwSize * sizeof(WCHAR);
651 xdi->info.DomainName.Buffer = xdi->domain;
652 if (GetComputerNameW(xdi->info.DomainName.Buffer, &dwSize))
653 xdi->info.DomainName.Length = dwSize * sizeof(WCHAR);
655 TRACE("setting name to %s\n", debugstr_w(xdi->info.DomainName.Buffer));
657 xdi->info.DomainSid = &xdi->sid;
659 /* read the computer SID from the registry */
660 if (!ADVAPI_GetComputerSid(&xdi->sid))
662 HeapFree(GetProcessHeap(), 0, xdi);
664 WARN("Computer SID not found\n");
666 return STATUS_UNSUCCESSFUL;
669 TRACE("setting SID to %s\n", debugstr_sid(&xdi->sid));
671 *Buffer = xdi;
673 break;
674 case PolicyDnsDomainInformation: /* 12 (0xc) */
676 /* Only the domain name is valid for the local computer.
677 * All other fields are zero.
679 PPOLICY_DNS_DOMAIN_INFO pinfo;
681 pinfo = ADVAPI_GetDomainName(sizeof(*pinfo), offsetof(POLICY_DNS_DOMAIN_INFO, Name));
683 TRACE("setting domain to %s\n", debugstr_w(pinfo->Name.Buffer));
685 *Buffer = pinfo;
687 break;
688 case PolicyAuditLogInformation:
689 case PolicyPdAccountInformation:
690 case PolicyLsaServerRoleInformation:
691 case PolicyReplicaSourceInformation:
692 case PolicyDefaultQuotaInformation:
693 case PolicyModificationInformation:
694 case PolicyAuditFullSetInformation:
695 case PolicyAuditFullQueryInformation:
697 FIXME("category %d not implemented\n", InformationClass);
698 return STATUS_UNSUCCESSFUL;
701 return STATUS_SUCCESS;
704 /******************************************************************************
705 * LsaQueryTrustedDomainInfo [ADVAPI32.@]
708 NTSTATUS WINAPI LsaQueryTrustedDomainInfo(
709 LSA_HANDLE policy,
710 PSID sid,
711 TRUSTED_INFORMATION_CLASS class,
712 PVOID *buffer)
714 FIXME("(%p,%p,%d,%p) stub\n", policy, sid, class, buffer);
715 return STATUS_OBJECT_NAME_NOT_FOUND;
718 /******************************************************************************
719 * LsaQueryTrustedDomainInfoByName [ADVAPI32.@]
722 NTSTATUS WINAPI LsaQueryTrustedDomainInfoByName(
723 LSA_HANDLE policy,
724 PLSA_UNICODE_STRING name,
725 TRUSTED_INFORMATION_CLASS class,
726 PVOID *buffer)
728 FIXME("(%p,%p,%d,%p) stub\n", policy, name, class, buffer);
729 return STATUS_OBJECT_NAME_NOT_FOUND;
732 /******************************************************************************
733 * LsaRegisterPolicyChangeNotification [ADVAPI32.@]
736 NTSTATUS WINAPI LsaRegisterPolicyChangeNotification(
737 POLICY_NOTIFICATION_INFORMATION_CLASS class,
738 HANDLE event)
740 FIXME("(%d,%p) stub\n", class, event);
741 return STATUS_UNSUCCESSFUL;
744 /******************************************************************************
745 * LsaRemoveAccountRights [ADVAPI32.@]
748 NTSTATUS WINAPI LsaRemoveAccountRights(
749 LSA_HANDLE policy,
750 PSID sid,
751 BOOLEAN all,
752 PLSA_UNICODE_STRING rights,
753 ULONG count)
755 FIXME("(%p,%p,%d,%p,0x%08x) stub\n", policy, sid, all, rights, count);
756 return STATUS_SUCCESS;
759 /******************************************************************************
760 * LsaRetrievePrivateData [ADVAPI32.@]
762 * Retrieves data stored by LsaStorePrivateData.
764 * PARAMS
765 * PolicyHandle [I] Handle to a Policy object.
766 * KeyName [I] Name of the key where the data is stored.
767 * PrivateData [O] Pointer to the private data.
769 * RETURNS
770 * Success: STATUS_SUCCESS.
771 * Failure: STATUS_OBJECT_NAME_NOT_FOUND or NTSTATUS code.
773 NTSTATUS WINAPI LsaRetrievePrivateData(
774 IN LSA_HANDLE PolicyHandle,
775 IN PLSA_UNICODE_STRING KeyName,
776 OUT PLSA_UNICODE_STRING* PrivateData)
778 FIXME("(%p,%p,%p) stub\n", PolicyHandle, KeyName, PrivateData);
779 return STATUS_OBJECT_NAME_NOT_FOUND;
782 /******************************************************************************
783 * LsaSetInformationPolicy [ADVAPI32.@]
785 * Modifies information in a Policy object.
787 * PARAMS
788 * PolicyHandle [I] Handle to a Policy object.
789 * InformationClass [I] Type of information to set.
790 * Buffer [I] Pointer to the information to set.
792 * RETURNS
793 * Success: STATUS_SUCCESS.
794 * Failure: NTSTATUS code.
796 NTSTATUS WINAPI LsaSetInformationPolicy(
797 IN LSA_HANDLE PolicyHandle,
798 IN POLICY_INFORMATION_CLASS InformationClass,
799 IN PVOID Buffer)
801 FIXME("(%p,0x%08x,%p) stub\n", PolicyHandle, InformationClass, Buffer);
803 return STATUS_UNSUCCESSFUL;
806 /******************************************************************************
807 * LsaSetSecret [ADVAPI32.@]
809 * Set old and new values on a secret handle
811 * PARAMS
812 * SecretHandle [I] Handle to a secret object.
813 * EncryptedCurrentValue [I] Pointer to encrypted new value, can be NULL
814 * EncryptedOldValue [I] Pointer to encrypted old value, can be NULL
816 * RETURNS
817 * Success: STATUS_SUCCESS
818 * Failure: NTSTATUS code.
820 NTSTATUS WINAPI LsaSetSecret(
821 IN LSA_HANDLE SecretHandle,
822 IN PLSA_UNICODE_STRING EncryptedCurrentValue,
823 IN PLSA_UNICODE_STRING EncryptedOldValue)
825 FIXME("(%p,%p,%p) stub\n", SecretHandle, EncryptedCurrentValue,
826 EncryptedOldValue);
827 return STATUS_SUCCESS;
830 /******************************************************************************
831 * LsaSetTrustedDomainInfoByName [ADVAPI32.@]
834 NTSTATUS WINAPI LsaSetTrustedDomainInfoByName(
835 LSA_HANDLE policy,
836 PLSA_UNICODE_STRING name,
837 TRUSTED_INFORMATION_CLASS class,
838 PVOID buffer)
840 FIXME("(%p,%p,%d,%p) stub\n", policy, name, class, buffer);
841 return STATUS_SUCCESS;
844 /******************************************************************************
845 * LsaSetTrustedDomainInformation [ADVAPI32.@]
848 NTSTATUS WINAPI LsaSetTrustedDomainInformation(
849 LSA_HANDLE policy,
850 PSID sid,
851 TRUSTED_INFORMATION_CLASS class,
852 PVOID buffer)
854 FIXME("(%p,%p,%d,%p) stub\n", policy, sid, class, buffer);
855 return STATUS_SUCCESS;
858 /******************************************************************************
859 * LsaStorePrivateData [ADVAPI32.@]
861 * Stores or deletes a Policy object's data under the specified reg key.
863 * PARAMS
864 * PolicyHandle [I] Handle to a Policy object.
865 * KeyName [I] Name of the key where the data will be stored.
866 * PrivateData [O] Pointer to the private data.
868 * RETURNS
869 * Success: STATUS_SUCCESS.
870 * Failure: STATUS_OBJECT_NAME_NOT_FOUND or NTSTATUS code.
872 NTSTATUS WINAPI LsaStorePrivateData(
873 IN LSA_HANDLE PolicyHandle,
874 IN PLSA_UNICODE_STRING KeyName,
875 IN PLSA_UNICODE_STRING PrivateData)
877 FIXME("(%p,%p,%p) stub\n", PolicyHandle, KeyName, PrivateData);
878 return STATUS_OBJECT_NAME_NOT_FOUND;
881 /******************************************************************************
882 * LsaUnregisterPolicyChangeNotification [ADVAPI32.@]
885 NTSTATUS WINAPI LsaUnregisterPolicyChangeNotification(
886 POLICY_NOTIFICATION_INFORMATION_CLASS class,
887 HANDLE event)
889 FIXME("(%d,%p) stub\n", class, event);
890 return STATUS_SUCCESS;