1 /*
2 * Implementation of the Local Security Authority API
3 *
4 * Copyright 1999 Juergen Schmied
5 * Copyright 2002 Andriy Palamarchuk
6 * Copyright 2004 Mike McCormack
7 * Copyright 2005 Hans Leidekker
8 *
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.
13 *
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.
18 *
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
22 */
23
24 #include <stdarg.h>
25
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"
34
35 #include "wine/debug.h"
36 #include "wine/unicode.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
39
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; \
46 }
47
48 static void dumpLsaAttributes(const LSA_OBJECT_ATTRIBUTES *oa)
49 {
50 if (oa)
51 {
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);
57 }
58 }
59
60 static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
61 {
62 HKEY key;
63 LONG ret;
64 BYTE* ptr = NULL;
65 UNICODE_STRING* ustr;
66
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'};
72
73 ret = RegOpenKeyExW(HKEY_LOCAL_MACHINE, wVNETSUP, 0, KEY_READ, &key);
74 if (ret == ERROR_SUCCESS)
75 {
76 DWORD size = 0;
77 static const WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 };
78
79 ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size);
80 if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
81 {
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)
89 {
90 HeapFree(GetProcessHeap(), 0, ptr);
91 ptr = NULL;
92 }
93 else ustr->Length = size - sizeof(WCHAR);
94 }
95 RegCloseKey(key);
96 }
97 if (!ptr)
98 {
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));
108 }
109 return ptr;
110 }
111
112 /******************************************************************************
113 * LsaAddAccountRights [ADVAPI32.@]
114 *
115 */
116 NTSTATUS WINAPI LsaAddAccountRights(
117 LSA_HANDLE policy,
118 PSID sid,
119 PLSA_UNICODE_STRING rights,
120 ULONG count)
121 {
122 FIXME("(%p,%p,%p,0x%08x) stub\n", policy, sid, rights, count);
123 return STATUS_OBJECT_NAME_NOT_FOUND;
124 }
125
126 /******************************************************************************
127 * LsaClose [ADVAPI32.@]
128 *
129 * Closes a handle to a Policy or TrustedDomain.
130 *
131 * PARAMS
132 * ObjectHandle [I] Handle to a Policy or TrustedDomain.
133 *
134 * RETURNS
135 * Success: STATUS_SUCCESS.
136 * Failure: NTSTATUS code.
137 */
138 NTSTATUS WINAPI LsaClose(IN LSA_HANDLE ObjectHandle)
139 {
140 FIXME("(%p) stub\n", ObjectHandle);
141 return STATUS_SUCCESS;
142 }
143
144 /******************************************************************************
145 * LsaCreateTrustedDomainEx [ADVAPI32.@]
146 *
147 */
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)
154 {
155 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", policy, domain_info, auth_info,
156 access, domain);
157 return STATUS_SUCCESS;
158 }
159
160 /******************************************************************************
161 * LsaDeleteTrustedDomain [ADVAPI32.@]
162 *
163 */
164 NTSTATUS WINAPI LsaDeleteTrustedDomain(LSA_HANDLE policy, PSID sid)
165 {
166 FIXME("(%p,%p) stub\n", policy, sid);
167 return STATUS_SUCCESS;
168 }
169
170 /******************************************************************************
171 * LsaEnumerateAccountRights [ADVAPI32.@]
172 *
173 */
174 NTSTATUS WINAPI LsaEnumerateAccountRights(
175 LSA_HANDLE policy,
176 PSID sid,
177 PLSA_UNICODE_STRING *rights,
178 PULONG count)
179 {
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;
184 }
185
186 /******************************************************************************
187 * LsaEnumerateAccountsWithUserRight [ADVAPI32.@]
188 *
189 */
190 NTSTATUS WINAPI LsaEnumerateAccountsWithUserRight(
191 LSA_HANDLE policy,
192 PLSA_UNICODE_STRING rights,
193 PVOID *buffer,
194 PULONG count)
195 {
196 FIXME("(%p,%p,%p,%p) stub\n", policy, rights, buffer, count);
197 return STATUS_NO_MORE_ENTRIES;
198 }
199
200 /******************************************************************************
201 * LsaEnumerateTrustedDomains [ADVAPI32.@]
202 *
203 * Returns the names and SIDs of trusted domains.
204 *
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.
211 *
212 * RETURNS
213 * Success: STATUS_SUCCESS,
214 * STATUS_MORE_ENTRIES,
215 * STATUS_NO_MORE_ENTRIES
216 * Failure: NTSTATUS code.
217 *
218 * NOTES
219 * LsaEnumerateTrustedDomains can be called multiple times to enumerate
220 * all trusted domains.
221 */
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)
228 {
229 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", PolicyHandle, EnumerationContext,
230 Buffer, PreferredMaximumLength, CountReturned);
231
232 if (CountReturned) *CountReturned = 0;
233 return STATUS_SUCCESS;
234 }
235
236 /******************************************************************************
237 * LsaEnumerateTrustedDomainsEx [ADVAPI32.@]
238 *
239 */
240 NTSTATUS WINAPI LsaEnumerateTrustedDomainsEx(
241 LSA_HANDLE policy,
242 PLSA_ENUMERATION_HANDLE context,
243 PVOID *buffer,
244 ULONG length,
245 PULONG count)
246 {
247 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", policy, context, buffer, length, count);
248
249 if (count) *count = 0;
250 return STATUS_SUCCESS;
251 }
252
253 /******************************************************************************
254 * LsaFreeMemory [ADVAPI32.@]
255 *
256 * Frees memory allocated by a LSA function.
257 *
258 * PARAMS
259 * Buffer [I] Memory buffer to free.
260 *
261 * RETURNS
262 * Success: STATUS_SUCCESS.
263 * Failure: NTSTATUS code.
264 */
265 NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
266 {
267 TRACE("(%p)\n", Buffer);
268
269 HeapFree(GetProcessHeap(), 0, Buffer);
270 return STATUS_SUCCESS;
271 }
272
273 /******************************************************************************
274 * LsaLookupNames [ADVAPI32.@]
275 *
276 * Returns the SIDs of an array of user, group, or local group names.
277 *
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.
284 *
285 * RETURNS
286 * Success: STATUS_SUCCESS,
287 * STATUS_SOME_NOT_MAPPED
288 * Failure: STATUS_NONE_MAPPED or NTSTATUS code.
289 */
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)
296 {
297 FIXME("(%p,0x%08x,%p,%p,%p) stub\n", PolicyHandle, Count, Names,
298 ReferencedDomains, Sids);
299
300 return STATUS_NONE_MAPPED;
301 }
302
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 )
305 {
306 BOOL ret;
307
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 );
311
312 return ret;
313 }
314
315 static INT build_domain(PLSA_REFERENCED_DOMAIN_LIST currentList, PLSA_UNICODE_STRING domain)
316 {
317 ULONG count;
318 ULONG sid_size = 0,domain_size = 0;
319 BOOL handled = FALSE;
320 SID_NAME_USE use;
321
322 for (count = 0; count < currentList->Entries; count ++)
323 {
324 if ((currentList->Domains[count].Name.Length == domain->Length) &&
325 (strncmpiW(currentList->Domains[count].Name.Buffer,domain->Buffer,(domain->Length / sizeof(WCHAR))) == 0))
326 {
327 HeapFree(GetProcessHeap(),0,domain->Buffer);
328 return count;
329 }
330 }
331
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));
336
337 currentList->Domains[currentList->Entries].Name = *domain;
338
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 );
343
344 currentList->Entries++;
345 return currentList->Entries-1;
346 }
347
348 /******************************************************************************
349 * LsaLookupNames2 [ADVAPI32.@]
350 *
351 */
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 )
355 {
356 ULONG i, sid_size_total = 0, domain_size_max = 0, size;
357 ULONG sid_size, domain_size, mapped;
358 BOOL ret, handled = FALSE;
359 SID_NAME_USE use;
360 SID *sid;
361
362 TRACE("(%p,0x%08x,0x%08x,%p,%p,%p)\n", policy, flags, count, names, domains, sids);
363
364 mapped = 0;
365 for (i = 0; i < count; i++)
366 {
367 handled = FALSE;
368 sid_size = domain_size = 0;
369 ret = lookup_name( &names[i], NULL, &sid_size, NULL, &domain_size, &use, &handled );
370 if (handled)
371 {
372 sid_size_total += sid_size;
373 if (domain_size)
374 {
375 if (domain_size > domain_size_max)
376 domain_size_max = domain_size;
377 }
378 mapped++;
379 }
380 }
381 TRACE("mapped %u out of %u\n", mapped, count);
382
383 size = sizeof(LSA_TRANSLATED_SID2) * count + sid_size_total;
384 if (!(*sids = HeapAlloc( GetProcessHeap(), 0, size) )) return STATUS_NO_MEMORY;
385
386 sid = (SID *)(*sids + count);
387
388 if (!(*domains = HeapAlloc( GetProcessHeap(), 0, sizeof(LSA_REFERENCED_DOMAIN_LIST) )))
389 {
390 HeapFree( GetProcessHeap(), 0, *sids );
391 return STATUS_NO_MEMORY;
392 }
393 (*domains)->Entries = 0;
394 (*domains)->Domains = NULL;
395
396 for (i = 0; i < count; i++)
397 {
398 LSA_UNICODE_STRING domain;
399
400 domain.Length = domain_size_max*sizeof(WCHAR);
401 domain.MaximumLength = domain_size_max*sizeof(WCHAR);
402 domain.Buffer = HeapAlloc(GetProcessHeap(),0,domain.Length);
403
404 (*sids)[i].Use = SidTypeUnknown;
405 (*sids)[i].DomainIndex = -1;
406 (*sids)[i].Flags = 0;
407
408 handled = FALSE;
409 sid_size = sid_size_total;
410 domain_size = domain_size_max;
411 ret = lookup_name( &names[i], sid, &sid_size, domain.Buffer, &domain_size, &use, &handled );
412 if (handled)
413 {
414 (*sids)[i].Sid = sid;
415 (*sids)[i].Use = use;
416
417 sid += sid_size;
418 sid_size_total -= sid_size;
419 if (domain_size)
420 {
421 domain.Length = domain_size * sizeof(WCHAR);
422 (*sids)[i].DomainIndex = build_domain(*domains, &domain);
423 }
424 else
425 HeapFree(GetProcessHeap(),0,domain.Buffer);
426 }
427 else
428 HeapFree(GetProcessHeap(),0,domain.Buffer);
429 }
430
431 if (mapped == count) return STATUS_SUCCESS;
432 if (mapped > 0 && mapped < count) return STATUS_SOME_NOT_MAPPED;
433 return STATUS_NONE_MAPPED;
434 }
435
436 /******************************************************************************
437 * LsaLookupSids [ADVAPI32.@]
438 *
439 * Looks up the names that correspond to an array of SIDs.
440 *
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.
447 *
448 * RETURNS
449 * Success: STATUS_SUCCESS,
450 * STATUS_SOME_NOT_MAPPED
451 * Failure: STATUS_NONE_MAPPED or NTSTATUS code.
452 */
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 )
459 {
460 ULONG i, mapped, size;
461 ULONG name_size, domain_size;
462 SID_NAME_USE use;
463
464 TRACE("(%p,%u,%p,%p,%p) stub\n", PolicyHandle, Count, Sids,
465 ReferencedDomains, Names);
466
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)) ))
470 {
471 HeapFree( GetProcessHeap(), 0, *Names);
472 return STATUS_NO_MEMORY;
473 }
474 (*ReferencedDomains)->Entries = 0;
475 (*ReferencedDomains)->Domains = NULL;
476
477 mapped = 0;
478 for (i = 0; i < Count; i++)
479 {
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;
486 if (LookupAccountSidW(NULL, Sids[i], NULL, &name_size, NULL, &domain_size, &use))
487 {
488 LSA_UNICODE_STRING domain;
489
490 mapped++;
491
492 if (domain_size)
493 {
494 domain.Length = domain_size*sizeof(WCHAR);
495 domain.MaximumLength = domain_size*sizeof(WCHAR);
496 domain.Buffer = HeapAlloc(GetProcessHeap(),0,domain.Length);
497 }
498 else
499 {
500 domain.Length = 0;
501 domain.MaximumLength = 0;
502 domain.Buffer = NULL;
503 }
504
505 (*Names)[i].Use = use;
506 (*Names)[i].Name.Length = name_size * sizeof(WCHAR);
507 (*Names)[i].Name.MaximumLength = name_size * sizeof(WCHAR);
508 (*Names)[i].Name.Buffer = HeapAlloc(GetProcessHeap(),0,name_size * sizeof(WCHAR));
509 LookupAccountSidW(NULL, Sids[i], (*Names)[i].Name.Buffer, &name_size, domain.Buffer, &domain_size, &use);
510
511 if (domain_size)
512 (*Names)[i].DomainIndex = build_domain(*ReferencedDomains, &domain);
513 }
514 }
515 TRACE("mapped %u out of %u\n",mapped,Count);
516
517 if (mapped == Count) return STATUS_SUCCESS;
518 if (mapped) return STATUS_SOME_NOT_MAPPED;
519 return STATUS_NONE_MAPPED;
520 }
521
522 /******************************************************************************
523 * LsaNtStatusToWinError [ADVAPI32.@]
524 *
525 * Converts an LSA NTSTATUS code to a Windows error code.
526 *
527 * PARAMS
528 * Status [I] NTSTATUS code.
529 *
530 * RETURNS
531 * Success: Corresponding Windows error code.
532 * Failure: ERROR_MR_MID_NOT_FOUND.
533 */
534 ULONG WINAPI LsaNtStatusToWinError(NTSTATUS Status)
535 {
536 return RtlNtStatusToDosError(Status);
537 }
538
539 /******************************************************************************
540 * LsaOpenPolicy [ADVAPI32.@]
541 *
542 * Opens a handle to the Policy object on a local or remote system.
543 *
544 * PARAMS
545 * SystemName [I] Name of the target system.
546 * ObjectAttributes [I] Connection attributes.
547 * DesiredAccess [I] Requested access rights.
548 * PolicyHandle [I/O] Handle to the Policy object.
549 *
550 * RETURNS
551 * Success: STATUS_SUCCESS.
552 * Failure: NTSTATUS code.
553 *
554 * NOTES
555 * Set SystemName to NULL to open the local Policy object.
556 */
557 NTSTATUS WINAPI LsaOpenPolicy(
558 IN PLSA_UNICODE_STRING SystemName,
559 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
560 IN ACCESS_MASK DesiredAccess,
561 IN OUT PLSA_HANDLE PolicyHandle)
562 {
563 FIXME("(%s,%p,0x%08x,%p) stub\n",
564 SystemName?debugstr_w(SystemName->Buffer):"(null)",
565 ObjectAttributes, DesiredAccess, PolicyHandle);
566
567 ADVAPI_ForceLocalComputer(SystemName ? SystemName->Buffer : NULL,
568 STATUS_ACCESS_VIOLATION);
569 dumpLsaAttributes(ObjectAttributes);
570
571 if(PolicyHandle) *PolicyHandle = (LSA_HANDLE)0xcafe;
572 return STATUS_SUCCESS;
573 }
574
575 /******************************************************************************
576 * LsaOpenTrustedDomainByName [ADVAPI32.@]
577 *
578 */
579 NTSTATUS WINAPI LsaOpenTrustedDomainByName(
580 LSA_HANDLE policy,
581 PLSA_UNICODE_STRING name,
582 ACCESS_MASK access,
583 PLSA_HANDLE handle)
584 {
585 FIXME("(%p,%p,0x%08x,%p) stub\n", policy, name, access, handle);
586 return STATUS_OBJECT_NAME_NOT_FOUND;
587 }
588
589 /******************************************************************************
590 * LsaQueryInformationPolicy [ADVAPI32.@]
591 *
592 * Returns information about a Policy object.
593 *
594 * PARAMS
595 * PolicyHandle [I] Handle to a Policy object.
596 * InformationClass [I] Type of information to retrieve.
597 * Buffer [O] Pointer to the requested information.
598 *
599 * RETURNS
600 * Success: STATUS_SUCCESS.
601 * Failure: NTSTATUS code.
602 */
603 NTSTATUS WINAPI LsaQueryInformationPolicy(
604 IN LSA_HANDLE PolicyHandle,
605 IN POLICY_INFORMATION_CLASS InformationClass,
606 OUT PVOID *Buffer)
607 {
608 TRACE("(%p,0x%08x,%p)\n", PolicyHandle, InformationClass, Buffer);
609
610 if(!Buffer) return STATUS_INVALID_PARAMETER;
611 switch (InformationClass)
612 {
613 case PolicyAuditEventsInformation: /* 2 */
614 {
615 PPOLICY_AUDIT_EVENTS_INFO p = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
616 sizeof(POLICY_AUDIT_EVENTS_INFO));
617 p->AuditingMode = FALSE; /* no auditing */
618 *Buffer = p;
619 }
620 break;
621 case PolicyPrimaryDomainInformation: /* 3 */
622 {
623 /* Only the domain name is valid for the local computer.
624 * All other fields are zero.
625 */
626 PPOLICY_PRIMARY_DOMAIN_INFO pinfo;
627
628 pinfo = ADVAPI_GetDomainName(sizeof(*pinfo), offsetof(POLICY_PRIMARY_DOMAIN_INFO, Name));
629
630 TRACE("setting domain to %s\n", debugstr_w(pinfo->Name.Buffer));
631
632 *Buffer = pinfo;
633 }
634 break;
635 case PolicyAccountDomainInformation: /* 5 */
636 {
637 struct di
638 {
639 POLICY_ACCOUNT_DOMAIN_INFO info;
640 SID sid;
641 DWORD padding[3];
642 WCHAR domain[MAX_COMPUTERNAME_LENGTH + 1];
643 };
644
645 DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
646 struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*xdi));
647
648 xdi->info.DomainName.MaximumLength = dwSize * sizeof(WCHAR);
649 xdi->info.DomainName.Buffer = xdi->domain;
650 if (GetComputerNameW(xdi->info.DomainName.Buffer, &dwSize))
651 xdi->info.DomainName.Length = dwSize * sizeof(WCHAR);
652
653 TRACE("setting name to %s\n", debugstr_w(xdi->info.DomainName.Buffer));
654
655 xdi->info.DomainSid = &xdi->sid;
656
657 /* read the computer SID from the registry */
658 if (!ADVAPI_GetComputerSid(&xdi->sid))
659 {
660 HeapFree(GetProcessHeap(), 0, xdi);
661
662 WARN("Computer SID not found\n");
663
664 return STATUS_UNSUCCESSFUL;
665 }
666
667 TRACE("setting SID to %s\n", debugstr_sid(&xdi->sid));
668
669 *Buffer = xdi;
670 }
671 break;
672 case PolicyDnsDomainInformation: /* 12 (0xc) */
673 {
674 /* Only the domain name is valid for the local computer.
675 * All other fields are zero.
676 */
677 PPOLICY_DNS_DOMAIN_INFO pinfo;
678
679 pinfo = ADVAPI_GetDomainName(sizeof(*pinfo), offsetof(POLICY_DNS_DOMAIN_INFO, Name));
680
681 TRACE("setting domain to %s\n", debugstr_w(pinfo->Name.Buffer));
682
683 *Buffer = pinfo;
684 }
685 break;
686 case PolicyAuditLogInformation:
687 case PolicyPdAccountInformation:
688 case PolicyLsaServerRoleInformation:
689 case PolicyReplicaSourceInformation:
690 case PolicyDefaultQuotaInformation:
691 case PolicyModificationInformation:
692 case PolicyAuditFullSetInformation:
693 case PolicyAuditFullQueryInformation:
694 {
695 FIXME("category %d not implemented\n", InformationClass);
696 return STATUS_UNSUCCESSFUL;
697 }
698 }
699 return STATUS_SUCCESS;
700 }
701
702 /******************************************************************************
703 * LsaQueryTrustedDomainInfo [ADVAPI32.@]
704 *
705 */
706 NTSTATUS WINAPI LsaQueryTrustedDomainInfo(
707 LSA_HANDLE policy,
708 PSID sid,
709 TRUSTED_INFORMATION_CLASS class,
710 PVOID *buffer)
711 {
712 FIXME("(%p,%p,%d,%p) stub\n", policy, sid, class, buffer);
713 return STATUS_OBJECT_NAME_NOT_FOUND;
714 }
715
716 /******************************************************************************
717 * LsaQueryTrustedDomainInfoByName [ADVAPI32.@]
718 *
719 */
720 NTSTATUS WINAPI LsaQueryTrustedDomainInfoByName(
721 LSA_HANDLE policy,
722 PLSA_UNICODE_STRING name,
723 TRUSTED_INFORMATION_CLASS class,
724 PVOID *buffer)
725 {
726 FIXME("(%p,%p,%d,%p) stub\n", policy, name, class, buffer);
727 return STATUS_OBJECT_NAME_NOT_FOUND;
728 }
729
730 /******************************************************************************
731 * LsaRegisterPolicyChangeNotification [ADVAPI32.@]
732 *
733 */
734 NTSTATUS WINAPI LsaRegisterPolicyChangeNotification(
735 POLICY_NOTIFICATION_INFORMATION_CLASS class,
736 HANDLE event)
737 {
738 FIXME("(%d,%p) stub\n", class, event);
739 return STATUS_UNSUCCESSFUL;
740 }
741
742 /******************************************************************************
743 * LsaRemoveAccountRights [ADVAPI32.@]
744 *
745 */
746 NTSTATUS WINAPI LsaRemoveAccountRights(
747 LSA_HANDLE policy,
748 PSID sid,
749 BOOLEAN all,
750 PLSA_UNICODE_STRING rights,
751 ULONG count)
752 {
753 FIXME("(%p,%p,%d,%p,0x%08x) stub\n", policy, sid, all, rights, count);
754 return STATUS_SUCCESS;
755 }
756
757 /******************************************************************************
758 * LsaRetrievePrivateData [ADVAPI32.@]
759 *
760 * Retrieves data stored by LsaStorePrivateData.
761 *
762 * PARAMS
763 * PolicyHandle [I] Handle to a Policy object.
764 * KeyName [I] Name of the key where the data is stored.
765 * PrivateData [O] Pointer to the private data.
766 *
767 * RETURNS
768 * Success: STATUS_SUCCESS.
769 * Failure: STATUS_OBJECT_NAME_NOT_FOUND or NTSTATUS code.
770 */
771 NTSTATUS WINAPI LsaRetrievePrivateData(
772 IN LSA_HANDLE PolicyHandle,
773 IN PLSA_UNICODE_STRING KeyName,
774 OUT PLSA_UNICODE_STRING* PrivateData)
775 {
776 FIXME("(%p,%p,%p) stub\n", PolicyHandle, KeyName, PrivateData);
777 return STATUS_OBJECT_NAME_NOT_FOUND;
778 }
779
780 /******************************************************************************
781 * LsaSetInformationPolicy [ADVAPI32.@]
782 *
783 * Modifies information in a Policy object.
784 *
785 * PARAMS
786 * PolicyHandle [I] Handle to a Policy object.
787 * InformationClass [I] Type of information to set.
788 * Buffer [I] Pointer to the information to set.
789 *
790 * RETURNS
791 * Success: STATUS_SUCCESS.
792 * Failure: NTSTATUS code.
793 */
794 NTSTATUS WINAPI LsaSetInformationPolicy(
795 IN LSA_HANDLE PolicyHandle,
796 IN POLICY_INFORMATION_CLASS InformationClass,
797 IN PVOID Buffer)
798 {
799 FIXME("(%p,0x%08x,%p) stub\n", PolicyHandle, InformationClass, Buffer);
800
801 return STATUS_UNSUCCESSFUL;
802 }
803
804 /******************************************************************************
805 * LsaSetSecret [ADVAPI32.@]
806 *
807 * Set old and new values on a secret handle
808 *
809 * PARAMS
810 * SecretHandle [I] Handle to a secret object.
811 * EncryptedCurrentValue [I] Pointer to encrypted new value, can be NULL
812 * EncryptedOldValue [I] Pointer to encrypted old value, can be NULL
813 *
814 * RETURNS
815 * Success: STATUS_SUCCESS
816 * Failure: NTSTATUS code.
817 */
818 NTSTATUS WINAPI LsaSetSecret(
819 IN LSA_HANDLE SecretHandle,
820 IN PLSA_UNICODE_STRING EncryptedCurrentValue,
821 IN PLSA_UNICODE_STRING EncryptedOldValue)
822 {
823 FIXME("(%p,%p,%p) stub\n", SecretHandle, EncryptedCurrentValue,
824 EncryptedOldValue);
825 return STATUS_SUCCESS;
826 }
827
828 /******************************************************************************
829 * LsaSetTrustedDomainInfoByName [ADVAPI32.@]
830 *
831 */
832 NTSTATUS WINAPI LsaSetTrustedDomainInfoByName(
833 LSA_HANDLE policy,
834 PLSA_UNICODE_STRING name,
835 TRUSTED_INFORMATION_CLASS class,
836 PVOID buffer)
837 {
838 FIXME("(%p,%p,%d,%p) stub\n", policy, name, class, buffer);
839 return STATUS_SUCCESS;
840 }
841
842 /******************************************************************************
843 * LsaSetTrustedDomainInformation [ADVAPI32.@]
844 *
845 */
846 NTSTATUS WINAPI LsaSetTrustedDomainInformation(
847 LSA_HANDLE policy,
848 PSID sid,
849 TRUSTED_INFORMATION_CLASS class,
850 PVOID buffer)
851 {
852 FIXME("(%p,%p,%d,%p) stub\n", policy, sid, class, buffer);
853 return STATUS_SUCCESS;
854 }
855
856 /******************************************************************************
857 * LsaStorePrivateData [ADVAPI32.@]
858 *
859 * Stores or deletes a Policy object's data under the specified reg key.
860 *
861 * PARAMS
862 * PolicyHandle [I] Handle to a Policy object.
863 * KeyName [I] Name of the key where the data will be stored.
864 * PrivateData [O] Pointer to the private data.
865 *
866 * RETURNS
867 * Success: STATUS_SUCCESS.
868 * Failure: STATUS_OBJECT_NAME_NOT_FOUND or NTSTATUS code.
869 */
870 NTSTATUS WINAPI LsaStorePrivateData(
871 IN LSA_HANDLE PolicyHandle,
872 IN PLSA_UNICODE_STRING KeyName,
873 IN PLSA_UNICODE_STRING PrivateData)
874 {
875 FIXME("(%p,%p,%p) stub\n", PolicyHandle, KeyName, PrivateData);
876 return STATUS_OBJECT_NAME_NOT_FOUND;
877 }
878
879 /******************************************************************************
880 * LsaUnregisterPolicyChangeNotification [ADVAPI32.@]
881 *
882 */
883 NTSTATUS WINAPI LsaUnregisterPolicyChangeNotification(
884 POLICY_NOTIFICATION_INFORMATION_CLASS class,
885 HANDLE event)
886 {
887 FIXME("(%d,%p) stub\n", class, event);
888 return STATUS_SUCCESS;
889 }
890
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.