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 LSA_UNICODE_STRING domain
;
375 BOOL handled
= FALSE
;
380 TRACE("(%p,0x%08x,0x%08x,%p,%p,%p)\n", policy
, flags
, count
, names
, domains
, sids
);
383 for (i
= 0; i
< count
; i
++)
386 sid_size
= domain_size
= 0;
387 lookup_name( &names
[i
], NULL
, &sid_size
, NULL
, &domain_size
, &use
, &handled
);
390 sid_size_total
+= sid_size
;
391 domainname_size_total
+= domain_size
;
394 if (domain_size
> domain_size_max
)
395 domain_size_max
= domain_size
;
400 TRACE("mapped %u out of %u\n", mapped
, count
);
402 size
= sizeof(LSA_TRANSLATED_SID2
) * count
+ sid_size_total
;
403 if (!(*sids
= heap_alloc(size
))) return STATUS_NO_MEMORY
;
405 sid
= (SID
*)(*sids
+ count
);
407 /* use maximum domain count */
408 if (!(*domains
= heap_alloc(sizeof(LSA_REFERENCED_DOMAIN_LIST
) + sizeof(LSA_TRUST_INFORMATION
)*count
+
409 sid_size_total
+ domainname_size_total
*sizeof(WCHAR
))))
412 return STATUS_NO_MEMORY
;
414 (*domains
)->Entries
= 0;
415 (*domains
)->Domains
= (LSA_TRUST_INFORMATION
*)((char*)*domains
+ sizeof(LSA_REFERENCED_DOMAIN_LIST
));
416 domain_data
= (char*)(*domains
)->Domains
+ sizeof(LSA_TRUST_INFORMATION
)*count
;
418 domain
.Buffer
= heap_alloc(domain_size_max
*sizeof(WCHAR
));
419 for (i
= 0; i
< count
; i
++)
421 domain
.Length
= domain_size_max
*sizeof(WCHAR
);
422 domain
.MaximumLength
= domain_size_max
*sizeof(WCHAR
);
424 (*sids
)[i
].Use
= SidTypeUnknown
;
425 (*sids
)[i
].DomainIndex
= -1;
426 (*sids
)[i
].Flags
= 0;
429 sid_size
= sid_size_total
;
430 domain_size
= domain_size_max
;
431 lookup_name( &names
[i
], sid
, &sid_size
, domain
.Buffer
, &domain_size
, &use
, &handled
);
434 (*sids
)[i
].Sid
= sid
;
435 (*sids
)[i
].Use
= use
;
437 sid
= (SID
*)((char *)sid
+ sid_size
);
438 sid_size_total
-= sid_size
;
441 domain
.Length
= domain_size
* sizeof(WCHAR
);
442 domain
.MaximumLength
= (domain_size
+ 1) * sizeof(WCHAR
);
443 (*sids
)[i
].DomainIndex
= lsa_reflist_add_domain(*domains
, &domain
, &domain_data
);
447 heap_free(domain
.Buffer
);
449 if (mapped
== count
) return STATUS_SUCCESS
;
450 if (mapped
> 0 && mapped
< count
) return STATUS_SOME_NOT_MAPPED
;
451 return STATUS_NONE_MAPPED
;
454 /******************************************************************************
455 * LsaLookupSids [ADVAPI32.@]
457 * Looks up the names that correspond to an array of SIDs.
460 * PolicyHandle [I] Handle to a Policy object.
461 * Count [I] Number of SIDs in the Sids array.
462 * Sids [I] Array of SIDs to lookup.
463 * ReferencedDomains [O] Array of domains where the sids were found.
464 * Names [O] Array of names corresponding to Sids.
467 * Success: STATUS_SUCCESS,
468 * STATUS_SOME_NOT_MAPPED
469 * Failure: STATUS_NONE_MAPPED or NTSTATUS code.
471 NTSTATUS WINAPI
LsaLookupSids(
472 LSA_HANDLE PolicyHandle
,
475 LSA_REFERENCED_DOMAIN_LIST
**ReferencedDomains
,
476 LSA_TRANSLATED_NAME
**Names
)
478 ULONG i
, mapped
, name_fullsize
, domain_fullsize
;
479 ULONG name_size
, domain_size
;
480 LSA_UNICODE_STRING domain
;
485 TRACE("(%p, %u, %p, %p, %p)\n", PolicyHandle
, Count
, Sids
, ReferencedDomains
, Names
);
487 /* this length does not include actual string length yet */
488 name_fullsize
= sizeof(LSA_TRANSLATED_NAME
) * Count
;
489 if (!(*Names
= heap_alloc(name_fullsize
))) return STATUS_NO_MEMORY
;
490 /* maximum count of stored domain infos is Count, allocate it like that cause really needed
491 count could only be computed after sid data is retrieved */
492 domain_fullsize
= sizeof(LSA_REFERENCED_DOMAIN_LIST
) + sizeof(LSA_TRUST_INFORMATION
)*Count
;
493 if (!(*ReferencedDomains
= heap_alloc(domain_fullsize
)))
496 return STATUS_NO_MEMORY
;
498 (*ReferencedDomains
)->Entries
= 0;
499 (*ReferencedDomains
)->Domains
= (LSA_TRUST_INFORMATION
*)((char*)*ReferencedDomains
+ sizeof(LSA_REFERENCED_DOMAIN_LIST
));
501 /* Get full names data length and full length needed to store domain name and SID */
502 for (i
= 0; i
< Count
; i
++)
504 (*Names
)[i
].Use
= SidTypeUnknown
;
505 (*Names
)[i
].DomainIndex
= -1;
506 (*Names
)[i
].Name
.Buffer
= NULL
;
508 memset(&(*ReferencedDomains
)->Domains
[i
], 0, sizeof(LSA_TRUST_INFORMATION
));
510 name_size
= domain_size
= 0;
511 if (!LookupAccountSidW(NULL
, Sids
[i
], NULL
, &name_size
, NULL
, &domain_size
, &use
) &&
512 GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
516 (*Names
)[i
].Name
.Length
= (name_size
- 1) * sizeof(WCHAR
);
517 (*Names
)[i
].Name
.MaximumLength
= name_size
* sizeof(WCHAR
);
518 name_fullsize
+= (*Names
)[i
].Name
.MaximumLength
;
522 (*Names
)[i
].Name
.Length
= 0;
523 (*Names
)[i
].Name
.MaximumLength
= 0;
526 /* This potentially allocates more than needed, cause different names will reuse same domain index.
527 Also it's not possible to store domain name length right here for the same reason. */
531 BOOL handled
= FALSE
;
534 domain_fullsize
+= domain_size
* sizeof(WCHAR
);
536 /* get domain SID size too */
537 name
= heap_alloc(domain_size
* sizeof(WCHAR
));
539 LookupAccountSidW(NULL
, Sids
[i
], NULL
, &name_size
, name
, &domain_size
, &use
);
541 domain
.Buffer
= name
;
542 domain
.Length
= domain_size
* sizeof(WCHAR
);
543 domain
.MaximumLength
= domain_size
* sizeof(WCHAR
);
545 lookup_name(&domain
, NULL
, &sid_size
, NULL
, &domain_size
, &use
, &handled
);
546 domain_fullsize
+= sid_size
;
553 /* now we have full length needed for both */
554 *Names
= heap_realloc(*Names
, name_fullsize
);
555 name_buffer
= (WCHAR
*)((char*)*Names
+ sizeof(LSA_TRANSLATED_NAME
)*Count
);
557 *ReferencedDomains
= heap_realloc(*ReferencedDomains
, domain_fullsize
);
558 /* fix pointer after reallocation */
559 (*ReferencedDomains
)->Domains
= (LSA_TRUST_INFORMATION
*)((char*)*ReferencedDomains
+ sizeof(LSA_REFERENCED_DOMAIN_LIST
));
560 domain_data
= (char*)(*ReferencedDomains
)->Domains
+ sizeof(LSA_TRUST_INFORMATION
)*Count
;
563 for (i
= 0; i
< Count
; i
++)
565 name_size
= domain_size
= 0;
567 if (!LookupAccountSidW(NULL
, Sids
[i
], NULL
, &name_size
, NULL
, &domain_size
, &use
) &&
568 GetLastError() == ERROR_INSUFFICIENT_BUFFER
)
574 domain
.Length
= (domain_size
- 1) * sizeof(WCHAR
);
575 domain
.MaximumLength
= domain_size
* sizeof(WCHAR
);
576 domain
.Buffer
= heap_alloc(domain
.MaximumLength
);
579 (*Names
)[i
].Name
.Buffer
= name_buffer
;
580 LookupAccountSidW(NULL
, Sids
[i
], (*Names
)[i
].Name
.Buffer
, &name_size
, domain
.Buffer
, &domain_size
, &use
);
581 (*Names
)[i
].Use
= use
;
585 (*Names
)[i
].DomainIndex
= lsa_reflist_add_domain(*ReferencedDomains
, &domain
, &domain_data
);
586 heap_free(domain
.Buffer
);
590 name_buffer
+= name_size
;
592 TRACE("mapped %u out of %u\n", mapped
, Count
);
594 if (mapped
== Count
) return STATUS_SUCCESS
;
595 if (mapped
) return STATUS_SOME_NOT_MAPPED
;
596 return STATUS_NONE_MAPPED
;
599 /******************************************************************************
600 * LsaNtStatusToWinError [ADVAPI32.@]
602 * Converts an LSA NTSTATUS code to a Windows error code.
605 * Status [I] NTSTATUS code.
608 * Success: Corresponding Windows error code.
609 * Failure: ERROR_MR_MID_NOT_FOUND.
611 ULONG WINAPI
LsaNtStatusToWinError(NTSTATUS Status
)
613 return RtlNtStatusToDosError(Status
);
616 /******************************************************************************
617 * LsaOpenPolicy [ADVAPI32.@]
619 * Opens a handle to the Policy object on a local or remote system.
622 * SystemName [I] Name of the target system.
623 * ObjectAttributes [I] Connection attributes.
624 * DesiredAccess [I] Requested access rights.
625 * PolicyHandle [I/O] Handle to the Policy object.
628 * Success: STATUS_SUCCESS.
629 * Failure: NTSTATUS code.
632 * Set SystemName to NULL to open the local Policy object.
634 NTSTATUS WINAPI
LsaOpenPolicy(
635 IN PLSA_UNICODE_STRING SystemName
,
636 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes
,
637 IN ACCESS_MASK DesiredAccess
,
638 IN OUT PLSA_HANDLE PolicyHandle
)
640 FIXME("(%s,%p,0x%08x,%p) stub\n",
641 SystemName
?debugstr_w(SystemName
->Buffer
):"(null)",
642 ObjectAttributes
, DesiredAccess
, PolicyHandle
);
644 ADVAPI_ForceLocalComputer(SystemName
? SystemName
->Buffer
: NULL
,
645 STATUS_ACCESS_VIOLATION
);
646 dumpLsaAttributes(ObjectAttributes
);
648 if(PolicyHandle
) *PolicyHandle
= (LSA_HANDLE
)0xcafe;
649 return STATUS_SUCCESS
;
652 /******************************************************************************
653 * LsaOpenTrustedDomainByName [ADVAPI32.@]
656 NTSTATUS WINAPI
LsaOpenTrustedDomainByName(
658 PLSA_UNICODE_STRING name
,
662 FIXME("(%p,%p,0x%08x,%p) stub\n", policy
, name
, access
, handle
);
663 return STATUS_OBJECT_NAME_NOT_FOUND
;
666 /******************************************************************************
667 * LsaQueryInformationPolicy [ADVAPI32.@]
669 * Returns information about a Policy object.
672 * PolicyHandle [I] Handle to a Policy object.
673 * InformationClass [I] Type of information to retrieve.
674 * Buffer [O] Pointer to the requested information.
677 * Success: STATUS_SUCCESS.
678 * Failure: NTSTATUS code.
680 NTSTATUS WINAPI
LsaQueryInformationPolicy(
681 IN LSA_HANDLE PolicyHandle
,
682 IN POLICY_INFORMATION_CLASS InformationClass
,
685 TRACE("(%p,0x%08x,%p)\n", PolicyHandle
, InformationClass
, Buffer
);
687 if(!Buffer
) return STATUS_INVALID_PARAMETER
;
688 switch (InformationClass
)
690 case PolicyAuditEventsInformation
: /* 2 */
692 PPOLICY_AUDIT_EVENTS_INFO p
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
693 sizeof(POLICY_AUDIT_EVENTS_INFO
));
694 p
->AuditingMode
= FALSE
; /* no auditing */
698 case PolicyPrimaryDomainInformation
: /* 3 */
700 /* Only the domain name is valid for the local computer.
701 * All other fields are zero.
703 PPOLICY_PRIMARY_DOMAIN_INFO pinfo
;
705 pinfo
= ADVAPI_GetDomainName(sizeof(*pinfo
), offsetof(POLICY_PRIMARY_DOMAIN_INFO
, Name
));
707 TRACE("setting domain to %s\n", debugstr_w(pinfo
->Name
.Buffer
));
712 case PolicyAccountDomainInformation
: /* 5 */
716 POLICY_ACCOUNT_DOMAIN_INFO info
;
719 WCHAR domain
[MAX_COMPUTERNAME_LENGTH
+ 1];
722 DWORD dwSize
= MAX_COMPUTERNAME_LENGTH
+ 1;
723 struct di
* xdi
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(*xdi
));
725 xdi
->info
.DomainName
.MaximumLength
= dwSize
* sizeof(WCHAR
);
726 xdi
->info
.DomainName
.Buffer
= xdi
->domain
;
727 if (GetComputerNameW(xdi
->info
.DomainName
.Buffer
, &dwSize
))
728 xdi
->info
.DomainName
.Length
= dwSize
* sizeof(WCHAR
);
730 TRACE("setting name to %s\n", debugstr_w(xdi
->info
.DomainName
.Buffer
));
732 xdi
->info
.DomainSid
= &xdi
->sid
;
734 if (!ADVAPI_GetComputerSid(&xdi
->sid
))
736 HeapFree(GetProcessHeap(), 0, xdi
);
738 WARN("Computer SID not found\n");
740 return STATUS_UNSUCCESSFUL
;
743 TRACE("setting SID to %s\n", debugstr_sid(&xdi
->sid
));
748 case PolicyDnsDomainInformation
: /* 12 (0xc) */
750 /* Only the domain name is valid for the local computer.
751 * All other fields are zero.
753 PPOLICY_DNS_DOMAIN_INFO pinfo
;
755 pinfo
= ADVAPI_GetDomainName(sizeof(*pinfo
), offsetof(POLICY_DNS_DOMAIN_INFO
, Name
));
757 TRACE("setting domain to %s\n", debugstr_w(pinfo
->Name
.Buffer
));
762 case PolicyAuditLogInformation
:
763 case PolicyPdAccountInformation
:
764 case PolicyLsaServerRoleInformation
:
765 case PolicyReplicaSourceInformation
:
766 case PolicyDefaultQuotaInformation
:
767 case PolicyModificationInformation
:
768 case PolicyAuditFullSetInformation
:
769 case PolicyAuditFullQueryInformation
:
771 FIXME("category %d not implemented\n", InformationClass
);
772 return STATUS_UNSUCCESSFUL
;
775 return STATUS_SUCCESS
;
778 /******************************************************************************
779 * LsaQueryTrustedDomainInfo [ADVAPI32.@]
782 NTSTATUS WINAPI
LsaQueryTrustedDomainInfo(
785 TRUSTED_INFORMATION_CLASS
class,
788 FIXME("(%p,%p,%d,%p) stub\n", policy
, sid
, class, buffer
);
789 return STATUS_OBJECT_NAME_NOT_FOUND
;
792 /******************************************************************************
793 * LsaQueryTrustedDomainInfoByName [ADVAPI32.@]
796 NTSTATUS WINAPI
LsaQueryTrustedDomainInfoByName(
798 PLSA_UNICODE_STRING name
,
799 TRUSTED_INFORMATION_CLASS
class,
802 FIXME("(%p,%p,%d,%p) stub\n", policy
, name
, class, buffer
);
803 return STATUS_OBJECT_NAME_NOT_FOUND
;
806 /******************************************************************************
807 * LsaRegisterPolicyChangeNotification [ADVAPI32.@]
810 NTSTATUS WINAPI
LsaRegisterPolicyChangeNotification(
811 POLICY_NOTIFICATION_INFORMATION_CLASS
class,
814 FIXME("(%d,%p) stub\n", class, event
);
815 return STATUS_UNSUCCESSFUL
;
818 /******************************************************************************
819 * LsaRemoveAccountRights [ADVAPI32.@]
822 NTSTATUS WINAPI
LsaRemoveAccountRights(
826 PLSA_UNICODE_STRING rights
,
829 FIXME("(%p,%p,%d,%p,0x%08x) stub\n", policy
, sid
, all
, rights
, count
);
830 return STATUS_SUCCESS
;
833 /******************************************************************************
834 * LsaRetrievePrivateData [ADVAPI32.@]
836 * Retrieves data stored by LsaStorePrivateData.
839 * PolicyHandle [I] Handle to a Policy object.
840 * KeyName [I] Name of the key where the data is stored.
841 * PrivateData [O] Pointer to the private data.
844 * Success: STATUS_SUCCESS.
845 * Failure: STATUS_OBJECT_NAME_NOT_FOUND or NTSTATUS code.
847 NTSTATUS WINAPI
LsaRetrievePrivateData(
848 IN LSA_HANDLE PolicyHandle
,
849 IN PLSA_UNICODE_STRING KeyName
,
850 OUT PLSA_UNICODE_STRING
* PrivateData
)
852 FIXME("(%p,%p,%p) stub\n", PolicyHandle
, KeyName
, PrivateData
);
853 return STATUS_OBJECT_NAME_NOT_FOUND
;
856 /******************************************************************************
857 * LsaSetInformationPolicy [ADVAPI32.@]
859 * Modifies information in a Policy object.
862 * PolicyHandle [I] Handle to a Policy object.
863 * InformationClass [I] Type of information to set.
864 * Buffer [I] Pointer to the information to set.
867 * Success: STATUS_SUCCESS.
868 * Failure: NTSTATUS code.
870 NTSTATUS WINAPI
LsaSetInformationPolicy(
871 IN LSA_HANDLE PolicyHandle
,
872 IN POLICY_INFORMATION_CLASS InformationClass
,
875 FIXME("(%p,0x%08x,%p) stub\n", PolicyHandle
, InformationClass
, Buffer
);
877 return STATUS_UNSUCCESSFUL
;
880 /******************************************************************************
881 * LsaSetSecret [ADVAPI32.@]
883 * Set old and new values on a secret handle
886 * SecretHandle [I] Handle to a secret object.
887 * EncryptedCurrentValue [I] Pointer to encrypted new value, can be NULL
888 * EncryptedOldValue [I] Pointer to encrypted old value, can be NULL
891 * Success: STATUS_SUCCESS
892 * Failure: NTSTATUS code.
894 NTSTATUS WINAPI
LsaSetSecret(
895 IN LSA_HANDLE SecretHandle
,
896 IN PLSA_UNICODE_STRING EncryptedCurrentValue
,
897 IN PLSA_UNICODE_STRING EncryptedOldValue
)
899 FIXME("(%p,%p,%p) stub\n", SecretHandle
, EncryptedCurrentValue
,
901 return STATUS_SUCCESS
;
904 /******************************************************************************
905 * LsaSetTrustedDomainInfoByName [ADVAPI32.@]
908 NTSTATUS WINAPI
LsaSetTrustedDomainInfoByName(
910 PLSA_UNICODE_STRING name
,
911 TRUSTED_INFORMATION_CLASS
class,
914 FIXME("(%p,%p,%d,%p) stub\n", policy
, name
, class, buffer
);
915 return STATUS_SUCCESS
;
918 /******************************************************************************
919 * LsaSetTrustedDomainInformation [ADVAPI32.@]
922 NTSTATUS WINAPI
LsaSetTrustedDomainInformation(
925 TRUSTED_INFORMATION_CLASS
class,
928 FIXME("(%p,%p,%d,%p) stub\n", policy
, sid
, class, buffer
);
929 return STATUS_SUCCESS
;
932 /******************************************************************************
933 * LsaStorePrivateData [ADVAPI32.@]
935 * Stores or deletes a Policy object's data under the specified reg key.
938 * PolicyHandle [I] Handle to a Policy object.
939 * KeyName [I] Name of the key where the data will be stored.
940 * PrivateData [O] Pointer to the private data.
943 * Success: STATUS_SUCCESS.
944 * Failure: STATUS_OBJECT_NAME_NOT_FOUND or NTSTATUS code.
946 NTSTATUS WINAPI
LsaStorePrivateData(
947 IN LSA_HANDLE PolicyHandle
,
948 IN PLSA_UNICODE_STRING KeyName
,
949 IN PLSA_UNICODE_STRING PrivateData
)
951 FIXME("(%p,%p,%p) stub\n", PolicyHandle
, KeyName
, PrivateData
);
952 return STATUS_OBJECT_NAME_NOT_FOUND
;
955 /******************************************************************************
956 * LsaUnregisterPolicyChangeNotification [ADVAPI32.@]
959 NTSTATUS WINAPI
LsaUnregisterPolicyChangeNotification(
960 POLICY_NOTIFICATION_INFORMATION_CLASS
class,
963 FIXME("(%d,%p) stub\n", class, event
);
964 return STATUS_SUCCESS
;