d3d8: Get rid of the format switching code in d3d8_device_CopyRects().
[wine.git] / dlls / advapi32 / lsa.c
blob483e90266a126f5dbff8d4653333bf5c88591714
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 "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)) \
41 { \
42 FIXME("Action Implemented for local computer only. " \
43 "Requested for server %s\n", debugstr_w(ServerName)); \
44 return FailureCode; \
47 static void dumpLsaAttributes(const LSA_OBJECT_ATTRIBUTES *oa)
49 if (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)
61 HKEY key;
62 LONG ret;
63 BYTE* ptr = NULL;
64 UNICODE_STRING* ustr;
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)
75 DWORD size = 0;
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 = heap_alloc_zero(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 heap_free(ptr);
90 ptr = NULL;
92 else ustr->Length = size - sizeof(WCHAR);
94 RegCloseKey(key);
96 if (!ptr)
98 static const WCHAR wDomain[] = {'D','O','M','A','I','N','\0'};
99 ptr = heap_alloc_zero(sz + sizeof(wDomain));
100 if (!ptr) return NULL;
101 ustr = (UNICODE_STRING*)(ptr + ofs);
102 ustr->MaximumLength = sizeof(wDomain);
103 ustr->Buffer = (WCHAR*)(ptr + sz);
104 ustr->Length = sizeof(wDomain) - sizeof(WCHAR);
105 memcpy(ustr->Buffer, wDomain, sizeof(wDomain));
107 return ptr;
110 /******************************************************************************
111 * LsaAddAccountRights [ADVAPI32.@]
114 NTSTATUS WINAPI LsaAddAccountRights(
115 LSA_HANDLE policy,
116 PSID sid,
117 PLSA_UNICODE_STRING rights,
118 ULONG count)
120 FIXME("(%p,%p,%p,0x%08x) stub\n", policy, sid, rights, count);
121 return STATUS_OBJECT_NAME_NOT_FOUND;
124 /******************************************************************************
125 * LsaClose [ADVAPI32.@]
127 * Closes a handle to a Policy or TrustedDomain.
129 * PARAMS
130 * ObjectHandle [I] Handle to a Policy or TrustedDomain.
132 * RETURNS
133 * Success: STATUS_SUCCESS.
134 * Failure: NTSTATUS code.
136 NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle)
138 FIXME("(%p) stub\n", ObjectHandle);
139 return STATUS_SUCCESS;
142 /******************************************************************************
143 * LsaCreateTrustedDomainEx [ADVAPI32.@]
146 NTSTATUS WINAPI LsaCreateTrustedDomainEx(
147 LSA_HANDLE policy,
148 PTRUSTED_DOMAIN_INFORMATION_EX domain_info,
149 PTRUSTED_DOMAIN_AUTH_INFORMATION auth_info,
150 ACCESS_MASK access,
151 PLSA_HANDLE domain)
153 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", policy, domain_info, auth_info,
154 access, domain);
155 return STATUS_SUCCESS;
158 /******************************************************************************
159 * LsaDeleteTrustedDomain [ADVAPI32.@]
162 NTSTATUS WINAPI LsaDeleteTrustedDomain(LSA_HANDLE policy, PSID sid)
164 FIXME("(%p,%p) stub\n", policy, sid);
165 return STATUS_SUCCESS;
168 /******************************************************************************
169 * LsaEnumerateAccountRights [ADVAPI32.@]
172 NTSTATUS WINAPI LsaEnumerateAccountRights(
173 LSA_HANDLE policy,
174 PSID sid,
175 PLSA_UNICODE_STRING *rights,
176 PULONG count)
178 FIXME("(%p,%p,%p,%p) stub\n", policy, sid, rights, count);
179 *rights = 0;
180 *count = 0;
181 return STATUS_OBJECT_NAME_NOT_FOUND;
184 /******************************************************************************
185 * LsaEnumerateAccountsWithUserRight [ADVAPI32.@]
188 NTSTATUS WINAPI LsaEnumerateAccountsWithUserRight(
189 LSA_HANDLE policy,
190 PLSA_UNICODE_STRING rights,
191 PVOID *buffer,
192 PULONG count)
194 FIXME("(%p,%p,%p,%p) stub\n", policy, rights, buffer, count);
195 return STATUS_NO_MORE_ENTRIES;
198 /******************************************************************************
199 * LsaEnumerateTrustedDomains [ADVAPI32.@]
201 * Returns the names and SIDs of trusted domains.
203 * PARAMS
204 * PolicyHandle [I] Handle to a Policy object.
205 * EnumerationContext [I] Pointer to an enumeration handle.
206 * Buffer [O] Contains the names and SIDs of trusted domains.
207 * PreferredMaximumLength[I] Preferred maximum size in bytes of Buffer.
208 * CountReturned [O] Number of elements in Buffer.
210 * RETURNS
211 * Success: STATUS_SUCCESS,
212 * STATUS_MORE_ENTRIES,
213 * STATUS_NO_MORE_ENTRIES
214 * Failure: NTSTATUS code.
216 * NOTES
217 * LsaEnumerateTrustedDomains can be called multiple times to enumerate
218 * all trusted domains.
220 NTSTATUS WINAPI LsaEnumerateTrustedDomains(
221 IN LSA_HANDLE PolicyHandle,
222 IN PLSA_ENUMERATION_HANDLE EnumerationContext,
223 OUT PVOID* Buffer,
224 IN ULONG PreferredMaximumLength,
225 OUT PULONG CountReturned)
227 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", PolicyHandle, EnumerationContext,
228 Buffer, PreferredMaximumLength, CountReturned);
230 if (CountReturned) *CountReturned = 0;
231 return STATUS_SUCCESS;
234 /******************************************************************************
235 * LsaEnumerateTrustedDomainsEx [ADVAPI32.@]
238 NTSTATUS WINAPI LsaEnumerateTrustedDomainsEx(
239 LSA_HANDLE policy,
240 PLSA_ENUMERATION_HANDLE context,
241 PVOID *buffer,
242 ULONG length,
243 PULONG count)
245 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", policy, context, buffer, length, count);
247 if (count) *count = 0;
248 return STATUS_SUCCESS;
251 /******************************************************************************
252 * LsaFreeMemory [ADVAPI32.@]
254 * Frees memory allocated by a LSA function.
256 * PARAMS
257 * Buffer [I] Memory buffer to free.
259 * RETURNS
260 * Success: STATUS_SUCCESS.
261 * Failure: NTSTATUS code.
263 NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
265 TRACE("(%p)\n", Buffer);
267 heap_free(Buffer);
268 return STATUS_SUCCESS;
271 /******************************************************************************
272 * LsaLookupNames [ADVAPI32.@]
274 * Returns the SIDs of an array of user, group, or local group names.
276 * PARAMS
277 * PolicyHandle [I] Handle to a Policy object.
278 * Count [I] Number of names in Names.
279 * Names [I] Array of names to lookup.
280 * ReferencedDomains [O] Array of domains where the names were found.
281 * Sids [O] Array of SIDs corresponding to Names.
283 * RETURNS
284 * Success: STATUS_SUCCESS,
285 * STATUS_SOME_NOT_MAPPED
286 * Failure: STATUS_NONE_MAPPED or NTSTATUS code.
288 NTSTATUS WINAPI LsaLookupNames(
289 IN LSA_HANDLE PolicyHandle,
290 IN ULONG Count,
291 IN PLSA_UNICODE_STRING Names,
292 OUT PLSA_REFERENCED_DOMAIN_LIST* ReferencedDomains,
293 OUT PLSA_TRANSLATED_SID* Sids)
295 FIXME("(%p,0x%08x,%p,%p,%p) stub\n", PolicyHandle, Count, Names,
296 ReferencedDomains, Sids);
298 return STATUS_NONE_MAPPED;
301 static BOOL lookup_name( LSA_UNICODE_STRING *name, SID *sid, DWORD *sid_size, WCHAR *domain,
302 DWORD *domain_size, SID_NAME_USE *use, BOOL *handled )
304 BOOL ret;
306 ret = lookup_local_wellknown_name( name, sid, sid_size, domain, domain_size, use, handled );
307 if (!*handled)
308 ret = lookup_local_user_name( name, sid, sid_size, domain, domain_size, use, handled );
310 return ret;
313 /* Adds domain info to referenced domain list.
314 Domain list is stored as plain buffer, layout is:
316 LSA_REFERENCED_DOMAIN_LIST,
317 LSA_TRUST_INFORMATION array,
318 domain data array of
320 domain name data (WCHAR buffer),
321 SID data
324 Parameters:
325 list [I] referenced list pointer
326 domain [I] domain name string
327 data [IO] pointer to domain data array
329 static LONG lsa_reflist_add_domain(LSA_REFERENCED_DOMAIN_LIST *list, LSA_UNICODE_STRING *domain, char **data)
331 ULONG sid_size = 0,domain_size = 0;
332 BOOL handled = FALSE;
333 SID_NAME_USE use;
334 LONG i;
336 for (i = 0; i < list->Entries; i++)
338 /* try to reuse index */
339 if ((list->Domains[i].Name.Length == domain->Length) &&
340 (!strncmpiW(list->Domains[i].Name.Buffer, domain->Buffer, (domain->Length / sizeof(WCHAR)))))
342 return i;
346 /* no matching domain found, store name */
347 list->Domains[list->Entries].Name.Length = domain->Length;
348 list->Domains[list->Entries].Name.MaximumLength = domain->MaximumLength;
349 list->Domains[list->Entries].Name.Buffer = (WCHAR*)*data;
350 memcpy(list->Domains[list->Entries].Name.Buffer, domain->Buffer, domain->MaximumLength);
351 *data += domain->MaximumLength;
353 /* get and store SID data */
354 list->Domains[list->Entries].Sid = *data;
355 lookup_name(domain, NULL, &sid_size, NULL, &domain_size, &use, &handled);
356 domain_size = 0;
357 lookup_name(domain, list->Domains[list->Entries].Sid, &sid_size, NULL, &domain_size, &use, &handled);
358 *data += sid_size;
360 return list->Entries++;
363 /******************************************************************************
364 * LsaLookupNames2 [ADVAPI32.@]
367 NTSTATUS WINAPI LsaLookupNames2( LSA_HANDLE policy, ULONG flags, ULONG count,
368 PLSA_UNICODE_STRING names, PLSA_REFERENCED_DOMAIN_LIST *domains,
369 PLSA_TRANSLATED_SID2 *sids )
371 ULONG i, sid_size_total = 0, domain_size_max = 0, size, domainname_size_total = 0;
372 ULONG sid_size, domain_size, mapped;
373 LSA_UNICODE_STRING domain;
374 BOOL handled = FALSE;
375 char *domain_data;
376 SID_NAME_USE use;
377 SID *sid;
379 TRACE("(%p,0x%08x,0x%08x,%p,%p,%p)\n", policy, flags, count, names, domains, sids);
381 mapped = 0;
382 for (i = 0; i < count; i++)
384 handled = FALSE;
385 sid_size = domain_size = 0;
386 lookup_name( &names[i], NULL, &sid_size, NULL, &domain_size, &use, &handled );
387 if (handled)
389 sid_size_total += sid_size;
390 domainname_size_total += domain_size;
391 if (domain_size)
393 if (domain_size > domain_size_max)
394 domain_size_max = domain_size;
396 mapped++;
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*sizeof(WCHAR))))
410 heap_free(*sids);
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 domain.Buffer = heap_alloc(domain_size_max*sizeof(WCHAR));
418 for (i = 0; i < count; i++)
420 domain.Length = domain_size_max*sizeof(WCHAR);
421 domain.MaximumLength = domain_size_max*sizeof(WCHAR);
423 (*sids)[i].Use = SidTypeUnknown;
424 (*sids)[i].DomainIndex = -1;
425 (*sids)[i].Flags = 0;
427 handled = FALSE;
428 sid_size = sid_size_total;
429 domain_size = domain_size_max;
430 lookup_name( &names[i], sid, &sid_size, domain.Buffer, &domain_size, &use, &handled );
431 if (handled)
433 (*sids)[i].Sid = sid;
434 (*sids)[i].Use = use;
436 sid = (SID *)((char *)sid + sid_size);
437 sid_size_total -= sid_size;
438 if (domain_size)
440 domain.Length = domain_size * sizeof(WCHAR);
441 domain.MaximumLength = (domain_size + 1) * sizeof(WCHAR);
442 (*sids)[i].DomainIndex = lsa_reflist_add_domain(*domains, &domain, &domain_data);
446 heap_free(domain.Buffer);
448 if (mapped == count) return STATUS_SUCCESS;
449 if (mapped > 0 && mapped < count) return STATUS_SOME_NOT_MAPPED;
450 return STATUS_NONE_MAPPED;
453 /******************************************************************************
454 * LsaLookupSids [ADVAPI32.@]
456 * Looks up the names that correspond to an array of SIDs.
458 * PARAMS
459 * PolicyHandle [I] Handle to a Policy object.
460 * Count [I] Number of SIDs in the Sids array.
461 * Sids [I] Array of SIDs to lookup.
462 * ReferencedDomains [O] Array of domains where the sids were found.
463 * Names [O] Array of names corresponding to Sids.
465 * RETURNS
466 * Success: STATUS_SUCCESS,
467 * STATUS_SOME_NOT_MAPPED
468 * Failure: STATUS_NONE_MAPPED or NTSTATUS code.
470 NTSTATUS WINAPI LsaLookupSids(
471 LSA_HANDLE PolicyHandle,
472 ULONG Count,
473 PSID *Sids,
474 LSA_REFERENCED_DOMAIN_LIST **ReferencedDomains,
475 LSA_TRANSLATED_NAME **Names)
477 ULONG i, mapped, name_fullsize, domain_fullsize;
478 ULONG name_size, domain_size;
479 LSA_UNICODE_STRING domain;
480 WCHAR *name_buffer;
481 char *domain_data;
482 SID_NAME_USE use;
484 TRACE("(%p, %u, %p, %p, %p)\n", PolicyHandle, Count, Sids, ReferencedDomains, Names);
486 /* this length does not include actual string length yet */
487 name_fullsize = sizeof(LSA_TRANSLATED_NAME) * Count;
488 if (!(*Names = heap_alloc(name_fullsize))) return STATUS_NO_MEMORY;
489 /* maximum count of stored domain infos is Count, allocate it like that cause really needed
490 count could only be computed after sid data is retrieved */
491 domain_fullsize = sizeof(LSA_REFERENCED_DOMAIN_LIST) + sizeof(LSA_TRUST_INFORMATION)*Count;
492 if (!(*ReferencedDomains = heap_alloc(domain_fullsize)))
494 heap_free(*Names);
495 return STATUS_NO_MEMORY;
497 (*ReferencedDomains)->Entries = 0;
498 (*ReferencedDomains)->Domains = (LSA_TRUST_INFORMATION*)((char*)*ReferencedDomains + sizeof(LSA_REFERENCED_DOMAIN_LIST));
500 /* Get full names data length and full length needed to store domain name and SID */
501 for (i = 0; i < Count; i++)
503 (*Names)[i].Use = SidTypeUnknown;
504 (*Names)[i].DomainIndex = -1;
505 (*Names)[i].Name.Buffer = NULL;
507 memset(&(*ReferencedDomains)->Domains[i], 0, sizeof(LSA_TRUST_INFORMATION));
509 name_size = domain_size = 0;
510 if (!LookupAccountSidW(NULL, Sids[i], NULL, &name_size, NULL, &domain_size, &use) &&
511 GetLastError() == ERROR_INSUFFICIENT_BUFFER)
513 if (name_size)
515 (*Names)[i].Name.Length = (name_size - 1) * sizeof(WCHAR);
516 (*Names)[i].Name.MaximumLength = name_size * sizeof(WCHAR);
517 name_fullsize += (*Names)[i].Name.MaximumLength;
519 else
521 (*Names)[i].Name.Length = 0;
522 (*Names)[i].Name.MaximumLength = 0;
525 /* This potentially allocates more than needed, cause different names will reuse same domain index.
526 Also it's not possible to store domain name length right here for the same reason. */
527 if (domain_size)
529 ULONG sid_size = 0;
530 BOOL handled = FALSE;
531 WCHAR *name;
533 domain_fullsize += domain_size * sizeof(WCHAR);
535 /* get domain SID size too */
536 name = heap_alloc(domain_size * sizeof(WCHAR));
537 *name = 0;
538 LookupAccountSidW(NULL, Sids[i], NULL, &name_size, name, &domain_size, &use);
540 domain.Buffer = name;
541 domain.Length = domain_size * sizeof(WCHAR);
542 domain.MaximumLength = domain_size * sizeof(WCHAR);
544 lookup_name(&domain, NULL, &sid_size, NULL, &domain_size, &use, &handled);
545 domain_fullsize += sid_size;
547 heap_free(name);
552 /* now we have full length needed for both */
553 *Names = heap_realloc(*Names, name_fullsize);
554 name_buffer = (WCHAR*)((char*)*Names + sizeof(LSA_TRANSLATED_NAME)*Count);
556 *ReferencedDomains = heap_realloc(*ReferencedDomains, domain_fullsize);
557 /* fix pointer after reallocation */
558 (*ReferencedDomains)->Domains = (LSA_TRUST_INFORMATION*)((char*)*ReferencedDomains + sizeof(LSA_REFERENCED_DOMAIN_LIST));
559 domain_data = (char*)(*ReferencedDomains)->Domains + sizeof(LSA_TRUST_INFORMATION)*Count;
561 mapped = 0;
562 for (i = 0; i < Count; i++)
564 name_size = domain_size = 0;
566 if (!LookupAccountSidW(NULL, Sids[i], NULL, &name_size, NULL, &domain_size, &use) &&
567 GetLastError() == ERROR_INSUFFICIENT_BUFFER)
569 mapped++;
571 if (domain_size)
573 domain.Length = (domain_size - 1) * sizeof(WCHAR);
574 domain.MaximumLength = domain_size * sizeof(WCHAR);
575 domain.Buffer = heap_alloc(domain.MaximumLength);
578 (*Names)[i].Name.Buffer = name_buffer;
579 LookupAccountSidW(NULL, Sids[i], (*Names)[i].Name.Buffer, &name_size, domain.Buffer, &domain_size, &use);
580 (*Names)[i].Use = use;
582 if (domain_size)
584 (*Names)[i].DomainIndex = lsa_reflist_add_domain(*ReferencedDomains, &domain, &domain_data);
585 heap_free(domain.Buffer);
589 name_buffer += name_size;
591 TRACE("mapped %u out of %u\n", mapped, Count);
593 if (mapped == Count) return STATUS_SUCCESS;
594 if (mapped) return STATUS_SOME_NOT_MAPPED;
595 return STATUS_NONE_MAPPED;
598 /******************************************************************************
599 * LsaNtStatusToWinError [ADVAPI32.@]
601 * Converts an LSA NTSTATUS code to a Windows error code.
603 * PARAMS
604 * Status [I] NTSTATUS code.
606 * RETURNS
607 * Success: Corresponding Windows error code.
608 * Failure: ERROR_MR_MID_NOT_FOUND.
610 ULONG WINAPI LsaNtStatusToWinError(NTSTATUS Status)
612 return RtlNtStatusToDosError(Status);
615 /******************************************************************************
616 * LsaOpenPolicy [ADVAPI32.@]
618 * Opens a handle to the Policy object on a local or remote system.
620 * PARAMS
621 * SystemName [I] Name of the target system.
622 * ObjectAttributes [I] Connection attributes.
623 * DesiredAccess [I] Requested access rights.
624 * PolicyHandle [I/O] Handle to the Policy object.
626 * RETURNS
627 * Success: STATUS_SUCCESS.
628 * Failure: NTSTATUS code.
630 * NOTES
631 * Set SystemName to NULL to open the local Policy object.
633 NTSTATUS WINAPI LsaOpenPolicy(
634 IN PLSA_UNICODE_STRING SystemName,
635 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
636 IN ACCESS_MASK DesiredAccess,
637 IN OUT PLSA_HANDLE PolicyHandle)
639 FIXME("(%s,%p,0x%08x,%p) stub\n",
640 SystemName?debugstr_w(SystemName->Buffer):"(null)",
641 ObjectAttributes, DesiredAccess, PolicyHandle);
643 ADVAPI_ForceLocalComputer(SystemName ? SystemName->Buffer : NULL,
644 STATUS_ACCESS_VIOLATION);
645 dumpLsaAttributes(ObjectAttributes);
647 if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe;
648 return STATUS_SUCCESS;
651 /******************************************************************************
652 * LsaOpenTrustedDomainByName [ADVAPI32.@]
655 NTSTATUS WINAPI LsaOpenTrustedDomainByName(
656 LSA_HANDLE policy,
657 PLSA_UNICODE_STRING name,
658 ACCESS_MASK access,
659 PLSA_HANDLE handle)
661 FIXME("(%p,%p,0x%08x,%p) stub\n", policy, name, access, handle);
662 return STATUS_OBJECT_NAME_NOT_FOUND;
665 /******************************************************************************
666 * LsaQueryInformationPolicy [ADVAPI32.@]
668 * Returns information about a Policy object.
670 * PARAMS
671 * PolicyHandle [I] Handle to a Policy object.
672 * InformationClass [I] Type of information to retrieve.
673 * Buffer [O] Pointer to the requested information.
675 * RETURNS
676 * Success: STATUS_SUCCESS.
677 * Failure: NTSTATUS code.
679 NTSTATUS WINAPI LsaQueryInformationPolicy(
680 IN LSA_HANDLE PolicyHandle,
681 IN POLICY_INFORMATION_CLASS InformationClass,
682 OUT PVOID *Buffer)
684 TRACE("(%p,0x%08x,%p)\n", PolicyHandle, InformationClass, Buffer);
686 if(!Buffer) return STATUS_INVALID_PARAMETER;
687 switch (InformationClass)
689 case PolicyAuditEventsInformation: /* 2 */
691 PPOLICY_AUDIT_EVENTS_INFO p = heap_alloc_zero(sizeof(POLICY_AUDIT_EVENTS_INFO));
692 p->AuditingMode = FALSE; /* no auditing */
693 *Buffer = p;
695 break;
696 case PolicyPrimaryDomainInformation: /* 3 */
698 /* Only the domain name is valid for the local computer.
699 * All other fields are zero.
701 PPOLICY_PRIMARY_DOMAIN_INFO pinfo;
703 pinfo = ADVAPI_GetDomainName(sizeof(*pinfo), offsetof(POLICY_PRIMARY_DOMAIN_INFO, Name));
705 TRACE("setting domain to %s\n", debugstr_w(pinfo->Name.Buffer));
707 *Buffer = pinfo;
709 break;
710 case PolicyAccountDomainInformation: /* 5 */
712 struct di
714 POLICY_ACCOUNT_DOMAIN_INFO info;
715 SID sid;
716 DWORD padding[3];
717 WCHAR domain[MAX_COMPUTERNAME_LENGTH + 1];
720 DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
721 struct di * xdi = heap_alloc_zero(sizeof(*xdi));
723 xdi->info.DomainName.MaximumLength = dwSize * sizeof(WCHAR);
724 xdi->info.DomainName.Buffer = xdi->domain;
725 if (GetComputerNameW(xdi->info.DomainName.Buffer, &dwSize))
726 xdi->info.DomainName.Length = dwSize * sizeof(WCHAR);
728 TRACE("setting name to %s\n", debugstr_w(xdi->info.DomainName.Buffer));
730 xdi->info.DomainSid = &xdi->sid;
732 if (!ADVAPI_GetComputerSid(&xdi->sid))
734 heap_free(xdi);
736 WARN("Computer SID not found\n");
738 return STATUS_UNSUCCESSFUL;
741 TRACE("setting SID to %s\n", debugstr_sid(&xdi->sid));
743 *Buffer = xdi;
745 break;
746 case PolicyDnsDomainInformation: /* 12 (0xc) */
748 /* Only the domain name is valid for the local computer.
749 * All other fields are zero.
751 PPOLICY_DNS_DOMAIN_INFO pinfo;
753 pinfo = ADVAPI_GetDomainName(sizeof(*pinfo), offsetof(POLICY_DNS_DOMAIN_INFO, Name));
755 TRACE("setting domain to %s\n", debugstr_w(pinfo->Name.Buffer));
757 *Buffer = pinfo;
759 break;
760 case PolicyAuditLogInformation:
761 case PolicyPdAccountInformation:
762 case PolicyLsaServerRoleInformation:
763 case PolicyReplicaSourceInformation:
764 case PolicyDefaultQuotaInformation:
765 case PolicyModificationInformation:
766 case PolicyAuditFullSetInformation:
767 case PolicyAuditFullQueryInformation:
769 FIXME("category %d not implemented\n", InformationClass);
770 return STATUS_UNSUCCESSFUL;
773 return STATUS_SUCCESS;
776 /******************************************************************************
777 * LsaQueryTrustedDomainInfo [ADVAPI32.@]
780 NTSTATUS WINAPI LsaQueryTrustedDomainInfo(
781 LSA_HANDLE policy,
782 PSID sid,
783 TRUSTED_INFORMATION_CLASS class,
784 PVOID *buffer)
786 FIXME("(%p,%p,%d,%p) stub\n", policy, sid, class, buffer);
787 return STATUS_OBJECT_NAME_NOT_FOUND;
790 /******************************************************************************
791 * LsaQueryTrustedDomainInfoByName [ADVAPI32.@]
794 NTSTATUS WINAPI LsaQueryTrustedDomainInfoByName(
795 LSA_HANDLE policy,
796 PLSA_UNICODE_STRING name,
797 TRUSTED_INFORMATION_CLASS class,
798 PVOID *buffer)
800 FIXME("(%p,%p,%d,%p) stub\n", policy, name, class, buffer);
801 return STATUS_OBJECT_NAME_NOT_FOUND;
804 /******************************************************************************
805 * LsaRegisterPolicyChangeNotification [ADVAPI32.@]
808 NTSTATUS WINAPI LsaRegisterPolicyChangeNotification(
809 POLICY_NOTIFICATION_INFORMATION_CLASS class,
810 HANDLE event)
812 FIXME("(%d,%p) stub\n", class, event);
813 return STATUS_UNSUCCESSFUL;
816 /******************************************************************************
817 * LsaRemoveAccountRights [ADVAPI32.@]
820 NTSTATUS WINAPI LsaRemoveAccountRights(
821 LSA_HANDLE policy,
822 PSID sid,
823 BOOLEAN all,
824 PLSA_UNICODE_STRING rights,
825 ULONG count)
827 FIXME("(%p,%p,%d,%p,0x%08x) stub\n", policy, sid, all, rights, count);
828 return STATUS_SUCCESS;
831 /******************************************************************************
832 * LsaRetrievePrivateData [ADVAPI32.@]
834 * Retrieves data stored by LsaStorePrivateData.
836 * PARAMS
837 * PolicyHandle [I] Handle to a Policy object.
838 * KeyName [I] Name of the key where the data is stored.
839 * PrivateData [O] Pointer to the private data.
841 * RETURNS
842 * Success: STATUS_SUCCESS.
843 * Failure: STATUS_OBJECT_NAME_NOT_FOUND or NTSTATUS code.
845 NTSTATUS WINAPI LsaRetrievePrivateData(
846 IN LSA_HANDLE PolicyHandle,
847 IN PLSA_UNICODE_STRING KeyName,
848 OUT PLSA_UNICODE_STRING* PrivateData)
850 FIXME("(%p,%p,%p) stub\n", PolicyHandle, KeyName, PrivateData);
851 return STATUS_OBJECT_NAME_NOT_FOUND;
854 /******************************************************************************
855 * LsaSetInformationPolicy [ADVAPI32.@]
857 * Modifies information in a Policy object.
859 * PARAMS
860 * PolicyHandle [I] Handle to a Policy object.
861 * InformationClass [I] Type of information to set.
862 * Buffer [I] Pointer to the information to set.
864 * RETURNS
865 * Success: STATUS_SUCCESS.
866 * Failure: NTSTATUS code.
868 NTSTATUS WINAPI LsaSetInformationPolicy(
869 IN LSA_HANDLE PolicyHandle,
870 IN POLICY_INFORMATION_CLASS InformationClass,
871 IN PVOID Buffer)
873 FIXME("(%p,0x%08x,%p) stub\n", PolicyHandle, InformationClass, Buffer);
875 return STATUS_UNSUCCESSFUL;
878 /******************************************************************************
879 * LsaSetSecret [ADVAPI32.@]
881 * Set old and new values on a secret handle
883 * PARAMS
884 * SecretHandle [I] Handle to a secret object.
885 * EncryptedCurrentValue [I] Pointer to encrypted new value, can be NULL
886 * EncryptedOldValue [I] Pointer to encrypted old value, can be NULL
888 * RETURNS
889 * Success: STATUS_SUCCESS
890 * Failure: NTSTATUS code.
892 NTSTATUS WINAPI LsaSetSecret(
893 IN LSA_HANDLE SecretHandle,
894 IN PLSA_UNICODE_STRING EncryptedCurrentValue,
895 IN PLSA_UNICODE_STRING EncryptedOldValue)
897 FIXME("(%p,%p,%p) stub\n", SecretHandle, EncryptedCurrentValue,
898 EncryptedOldValue);
899 return STATUS_SUCCESS;
902 /******************************************************************************
903 * LsaSetTrustedDomainInfoByName [ADVAPI32.@]
906 NTSTATUS WINAPI LsaSetTrustedDomainInfoByName(
907 LSA_HANDLE policy,
908 PLSA_UNICODE_STRING name,
909 TRUSTED_INFORMATION_CLASS class,
910 PVOID buffer)
912 FIXME("(%p,%p,%d,%p) stub\n", policy, name, class, buffer);
913 return STATUS_SUCCESS;
916 /******************************************************************************
917 * LsaSetTrustedDomainInformation [ADVAPI32.@]
920 NTSTATUS WINAPI LsaSetTrustedDomainInformation(
921 LSA_HANDLE policy,
922 PSID sid,
923 TRUSTED_INFORMATION_CLASS class,
924 PVOID buffer)
926 FIXME("(%p,%p,%d,%p) stub\n", policy, sid, class, buffer);
927 return STATUS_SUCCESS;
930 /******************************************************************************
931 * LsaStorePrivateData [ADVAPI32.@]
933 * Stores or deletes a Policy object's data under the specified reg key.
935 * PARAMS
936 * PolicyHandle [I] Handle to a Policy object.
937 * KeyName [I] Name of the key where the data will be stored.
938 * PrivateData [O] Pointer to the private data.
940 * RETURNS
941 * Success: STATUS_SUCCESS.
942 * Failure: STATUS_OBJECT_NAME_NOT_FOUND or NTSTATUS code.
944 NTSTATUS WINAPI LsaStorePrivateData(
945 IN LSA_HANDLE PolicyHandle,
946 IN PLSA_UNICODE_STRING KeyName,
947 IN PLSA_UNICODE_STRING PrivateData)
949 FIXME("(%p,%p,%p) stub\n", PolicyHandle, KeyName, PrivateData);
950 return STATUS_OBJECT_NAME_NOT_FOUND;
953 /******************************************************************************
954 * LsaUnregisterPolicyChangeNotification [ADVAPI32.@]
957 NTSTATUS WINAPI LsaUnregisterPolicyChangeNotification(
958 POLICY_NOTIFICATION_INFORMATION_CLASS class,
959 HANDLE event)
961 FIXME("(%d,%p) stub\n", class, event);
962 return STATUS_SUCCESS;