[ADVAPI32]
[reactos.git] / reactos / dll / win32 / advapi32 / sec / lsa.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: dll/win32/advapi32/sec/lsa.c
5 * PURPOSE: Local security authority functions
6 * PROGRAMMER: Emanuele Aliberti
7 * UPDATE HISTORY:
8 * 19990322 EA created
9 * 19990515 EA stubs
10 * 20030202 KJK compressed stubs
11 *
12 */
13
14 #include <advapi32.h>
15
16 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
17
18
19 static
20 BOOL
21 LsapIsLocalComputer(PLSA_UNICODE_STRING ServerName)
22 {
23 DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
24 BOOL Result;
25 LPWSTR buf;
26
27 if (ServerName == NULL || ServerName->Length == 0 || ServerName->Buffer == NULL)
28 return TRUE;
29
30 buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
31 Result = GetComputerNameW(buf, &dwSize);
32 if (Result && (ServerName->Buffer[0] == '\\') && (ServerName->Buffer[1] == '\\'))
33 ServerName += 2;
34 Result = Result && !lstrcmpW(ServerName->Buffer, buf);
35 HeapFree(GetProcessHeap(), 0, buf);
36
37 return Result;
38 }
39
40
41 handle_t
42 __RPC_USER
43 PLSAPR_SERVER_NAME_bind(PLSAPR_SERVER_NAME pszSystemName)
44 {
45 handle_t hBinding = NULL;
46 LPWSTR pszStringBinding;
47 RPC_STATUS status;
48
49 TRACE("PLSAPR_SERVER_NAME_bind() called\n");
50
51 status = RpcStringBindingComposeW(NULL,
52 L"ncacn_np",
53 pszSystemName,
54 L"\\pipe\\lsarpc",
55 NULL,
56 &pszStringBinding);
57 if (status)
58 {
59 TRACE("RpcStringBindingCompose returned 0x%x\n", status);
60 return NULL;
61 }
62
63 /* Set the binding handle that will be used to bind to the server. */
64 status = RpcBindingFromStringBindingW(pszStringBinding,
65 &hBinding);
66 if (status)
67 {
68 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status);
69 }
70
71 status = RpcStringFreeW(&pszStringBinding);
72 if (status)
73 {
74 TRACE("RpcStringFree returned 0x%x\n", status);
75 }
76
77 return hBinding;
78 }
79
80
81 void
82 __RPC_USER
83 PLSAPR_SERVER_NAME_unbind(PLSAPR_SERVER_NAME pszSystemName,
84 handle_t hBinding)
85 {
86 RPC_STATUS status;
87
88 TRACE("PLSAPR_SERVER_NAME_unbind() called\n");
89
90 status = RpcBindingFree(&hBinding);
91 if (status)
92 {
93 TRACE("RpcBindingFree returned 0x%x\n", status);
94 }
95 }
96
97
98 /*
99 * @implemented
100 */
101 NTSTATUS
102 WINAPI
103 LsaAddAccountRights(IN LSA_HANDLE PolicyHandle,
104 IN PSID AccountSid,
105 IN PLSA_UNICODE_STRING UserRights,
106 IN ULONG CountOfRights)
107 {
108 LSAPR_USER_RIGHT_SET UserRightSet;
109 NTSTATUS Status;
110
111 TRACE("LsaAddAccountRights(%p %p %p 0x%08x)\n",
112 PolicyHandle, AccountSid, UserRights, CountOfRights);
113
114 UserRightSet.Entries = CountOfRights;
115 UserRightSet.UserRights = (PRPC_UNICODE_STRING)UserRights;
116
117 RpcTryExcept
118 {
119 Status = LsarAddAccountRights((LSAPR_HANDLE)PolicyHandle,
120 (PRPC_SID)AccountSid,
121 &UserRightSet);
122
123 }
124 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
125 {
126 Status = I_RpcMapWin32Status(RpcExceptionCode());
127 }
128 RpcEndExcept;
129
130 return Status;
131 }
132
133
134 /*
135 * @implemented
136 */
137 NTSTATUS
138 WINAPI
139 LsaAddPrivilegesToAccount(IN LSA_HANDLE AccountHandle,
140 IN PPRIVILEGE_SET PrivilegeSet)
141 {
142 NTSTATUS Status;
143
144 TRACE("LsaAddPrivilegesToAccount(%p %p)\n",
145 AccountHandle, PrivilegeSet);
146
147 RpcTryExcept
148 {
149 Status = LsarAddPrivilegesToAccount((LSAPR_HANDLE)AccountHandle,
150 (PLSAPR_PRIVILEGE_SET)PrivilegeSet);
151 }
152 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
153 {
154 Status = I_RpcMapWin32Status(RpcExceptionCode());
155 }
156 RpcEndExcept;
157
158 return Status;
159 }
160
161
162 /*
163 * @implemented
164 */
165 NTSTATUS
166 NTAPI
167 LsaClearAuditLog(IN LSA_HANDLE PolicyHandle)
168 {
169 NTSTATUS Status;
170
171 TRACE("LsaClearAuditLog(%p)\n", PolicyHandle);
172
173 RpcTryExcept
174 {
175 Status = LsarClearAuditLog((LSAPR_HANDLE)PolicyHandle);
176 }
177 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
178 {
179 Status = I_RpcMapWin32Status(RpcExceptionCode());
180 }
181 RpcEndExcept;
182
183 return Status;
184 }
185
186
187 /*
188 * @implemented
189 */
190 NTSTATUS
191 WINAPI
192 LsaClose(IN LSA_HANDLE ObjectHandle)
193 {
194 NTSTATUS Status;
195
196 TRACE("LsaClose(%p) called\n", ObjectHandle);
197
198 RpcTryExcept
199 {
200 Status = LsarClose((PLSAPR_HANDLE)&ObjectHandle);
201 }
202 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
203 {
204 Status = I_RpcMapWin32Status(RpcExceptionCode());
205 }
206 RpcEndExcept;
207
208 return Status;
209 }
210
211
212 /*
213 * @implemented
214 */
215 NTSTATUS
216 WINAPI
217 LsaCreateAccount(IN LSA_HANDLE PolicyHandle,
218 IN PSID AccountSid,
219 IN ACCESS_MASK DesiredAccess,
220 OUT PLSA_HANDLE AccountHandle)
221 {
222 NTSTATUS Status;
223
224 TRACE("LsaCreateAccount(%p %p 0x%08lx %p)\n",
225 PolicyHandle, AccountSid, DesiredAccess, AccountHandle);
226
227 RpcTryExcept
228 {
229 Status = LsarCreateAccount((LSAPR_HANDLE)PolicyHandle,
230 AccountSid,
231 DesiredAccess,
232 AccountHandle);
233 }
234 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
235 {
236 Status = I_RpcMapWin32Status(RpcExceptionCode());
237 }
238 RpcEndExcept;
239
240 return Status;
241 }
242
243
244 /*
245 * @implemented
246 */
247 NTSTATUS
248 WINAPI
249 LsaCreateSecret(IN LSA_HANDLE PolicyHandle,
250 IN PLSA_UNICODE_STRING SecretName,
251 IN ACCESS_MASK DesiredAccess,
252 OUT PLSA_HANDLE SecretHandle)
253 {
254 NTSTATUS Status;
255
256 TRACE("LsaCreateSecret(%p %p 0x%08lx %p)\n",
257 PolicyHandle, SecretName, DesiredAccess, SecretHandle);
258
259 RpcTryExcept
260 {
261 Status = LsarCreateSecret((LSAPR_HANDLE)PolicyHandle,
262 (PRPC_UNICODE_STRING)SecretName,
263 DesiredAccess,
264 SecretHandle);
265 }
266 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
267 {
268 Status = I_RpcMapWin32Status(RpcExceptionCode());
269 }
270 RpcEndExcept;
271
272 return Status;
273 }
274
275
276 /*
277 * @implemented
278 */
279 NTSTATUS
280 WINAPI
281 LsaCreateTrustedDomain(IN LSA_HANDLE PolicyHandle,
282 IN PLSA_TRUST_INFORMATION TrustedDomainInformation,
283 IN ACCESS_MASK DesiredAccess,
284 OUT PLSA_HANDLE TrustedDomainHandle)
285 {
286 NTSTATUS Status;
287
288 TRACE("LsaCreateTrustedDomain(%p %p 0x%08lx %p)\n",
289 PolicyHandle, TrustedDomainInformation, DesiredAccess, TrustedDomainHandle);
290
291 RpcTryExcept
292 {
293 Status = LsarCreateTrustedDomain((LSAPR_HANDLE)PolicyHandle,
294 (PLSAPR_TRUST_INFORMATION)TrustedDomainInformation,
295 DesiredAccess,
296 (PLSAPR_HANDLE)TrustedDomainHandle);
297 }
298 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
299 {
300 Status = I_RpcMapWin32Status(RpcExceptionCode());
301 }
302 RpcEndExcept;
303
304 return Status;
305 }
306
307
308 /*
309 * @unimplemented
310 */
311 NTSTATUS
312 WINAPI
313 LsaCreateTrustedDomainEx(IN LSA_HANDLE PolicyHandle,
314 IN PTRUSTED_DOMAIN_INFORMATION_EX TrustedDomainInformation,
315 IN PTRUSTED_DOMAIN_AUTH_INFORMATION AuthenticationInformation,
316 IN ACCESS_MASK DesiredAccess,
317 OUT PLSA_HANDLE TrustedDomainHandle)
318 {
319 PLSAPR_TRUSTED_DOMAIN_AUTH_INFORMATION_INTERNAL EncryptedAuthInfo = NULL;
320 NTSTATUS Status;
321
322 TRACE("LsaCreateTrustedDomainEx(%p %p %p 0x%08lx %p) stub\n",
323 PolicyHandle, TrustedDomainInformation, AuthenticationInformation,
324 DesiredAccess, TrustedDomainHandle);
325
326 RpcTryExcept
327 {
328 /* FIXME: Encrypt AuthenticationInformation */
329
330 Status = LsarCreateTrustedDomainEx2((LSAPR_HANDLE)PolicyHandle,
331 (PLSAPR_TRUSTED_DOMAIN_INFORMATION_EX)TrustedDomainInformation,
332 EncryptedAuthInfo,
333 DesiredAccess,
334 (PLSAPR_HANDLE)TrustedDomainHandle);
335 }
336 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
337 {
338 Status = I_RpcMapWin32Status(RpcExceptionCode());
339 }
340 RpcEndExcept;
341
342 return Status;
343 }
344
345
346 /*
347 * @implemented
348 */
349 NTSTATUS
350 WINAPI
351 LsaDelete(IN LSA_HANDLE ObjectHandle)
352 {
353 NTSTATUS Status;
354
355 TRACE("LsaDelete(%p)\n", ObjectHandle);
356
357 RpcTryExcept
358 {
359 Status = LsarDelete((LSAPR_HANDLE)ObjectHandle);
360 }
361 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
362 {
363 Status = I_RpcMapWin32Status(RpcExceptionCode());
364 }
365 RpcEndExcept;
366
367 return Status;
368 }
369
370
371 /*
372 * @implemented
373 */
374 NTSTATUS
375 WINAPI
376 LsaDeleteTrustedDomain(IN LSA_HANDLE PolicyHandle,
377 IN PSID TrustedDomainSid)
378 {
379 NTSTATUS Status;
380
381 TRACE("LsaDeleteTrustedDomain(%p %p)\n",
382 PolicyHandle, TrustedDomainSid);
383
384 RpcTryExcept
385 {
386 Status = LsarDeleteTrustedDomain((LSAPR_HANDLE)PolicyHandle,
387 TrustedDomainSid);
388 }
389 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
390 {
391 Status = I_RpcMapWin32Status(RpcExceptionCode());
392 }
393 RpcEndExcept;
394
395 return Status;
396 }
397
398
399 /*
400 * @implemented
401 */
402 NTSTATUS
403 WINAPI
404 LsaEnumerateAccountRights(IN LSA_HANDLE PolicyHandle,
405 IN PSID AccountSid,
406 OUT PLSA_UNICODE_STRING *UserRights,
407 OUT PULONG CountOfRights)
408 {
409 LSAPR_USER_RIGHT_SET UserRightsSet;
410 NTSTATUS Status;
411
412 TRACE("LsaEnumerateAccountRights(%p %p %p %p)\n",
413 PolicyHandle, AccountSid, UserRights, CountOfRights);
414
415 UserRightsSet.Entries = 0;
416 UserRightsSet.UserRights = NULL;
417
418 RpcTryExcept
419 {
420 Status = LsarEnmuerateAccountRights((LSAPR_HANDLE)PolicyHandle,
421 AccountSid,
422 &UserRightsSet);
423
424 *UserRights = (PUNICODE_STRING)UserRightsSet.UserRights;
425 *CountOfRights = UserRightsSet.Entries;
426 }
427 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
428 {
429 Status = I_RpcMapWin32Status(RpcExceptionCode());
430
431 if (UserRightsSet.UserRights != NULL)
432 MIDL_user_free(UserRightsSet.UserRights);
433 }
434 RpcEndExcept;
435
436 return Status;
437 }
438
439
440 /*
441 * @implemented
442 */
443 NTSTATUS
444 WINAPI
445 LsaEnumerateAccounts(IN LSA_HANDLE PolicyHandle,
446 IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
447 OUT PVOID *Buffer,
448 IN ULONG PreferedMaximumLength,
449 OUT PULONG CountReturned)
450 {
451 LSAPR_ACCOUNT_ENUM_BUFFER AccountEnumBuffer;
452 NTSTATUS Status;
453
454 TRACE("LsaEnumerateAccounts(%p %p %p %lu %p)\n",
455 PolicyHandle, EnumerationContext, Buffer,
456 PreferedMaximumLength, CountReturned);
457
458 AccountEnumBuffer.EntriesRead = 0;
459 AccountEnumBuffer.Information = NULL;
460
461 RpcTryExcept
462 {
463 Status = LsarEnumerateAccounts((LSAPR_HANDLE)PolicyHandle,
464 EnumerationContext,
465 &AccountEnumBuffer,
466 PreferedMaximumLength);
467
468 *Buffer = AccountEnumBuffer.Information;
469 *CountReturned = AccountEnumBuffer.EntriesRead;
470 }
471 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
472 {
473 if (AccountEnumBuffer.Information != NULL)
474 MIDL_user_free(AccountEnumBuffer.Information);
475
476 Status = I_RpcMapWin32Status(RpcExceptionCode());
477 }
478 RpcEndExcept;
479
480 return Status;
481 }
482
483
484 /*
485 * @implemented
486 */
487 NTSTATUS
488 WINAPI
489 LsaEnumerateAccountsWithUserRight(IN LSA_HANDLE PolicyHandle,
490 IN PLSA_UNICODE_STRING UserRight OPTIONAL,
491 OUT PVOID *Buffer,
492 OUT PULONG CountReturned)
493 {
494 LSAPR_ACCOUNT_ENUM_BUFFER AccountEnumBuffer;
495 NTSTATUS Status;
496
497 TRACE("LsaEnumerateAccountsWithUserRight(%p %p %p %p) stub\n",
498 PolicyHandle, UserRight, Buffer, CountReturned);
499
500 AccountEnumBuffer.EntriesRead = 0;
501 AccountEnumBuffer.Information = NULL;
502
503 RpcTryExcept
504 {
505 Status = LsarEnumerateAccountsWithUserRight((LSAPR_HANDLE)PolicyHandle,
506 (PRPC_UNICODE_STRING)UserRight,
507 &AccountEnumBuffer);
508
509 *Buffer = AccountEnumBuffer.Information;
510 *CountReturned = AccountEnumBuffer.EntriesRead;
511 }
512 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
513 {
514 if (AccountEnumBuffer.Information != NULL)
515 MIDL_user_free(AccountEnumBuffer.Information);
516
517 Status = I_RpcMapWin32Status(RpcExceptionCode());
518 }
519 RpcEndExcept;
520
521 return Status;
522 }
523
524
525 /*
526 * @implemented
527 */
528 NTSTATUS
529 WINAPI
530 LsaEnumeratePrivileges(IN LSA_HANDLE PolicyHandle,
531 IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
532 OUT PVOID *Buffer,
533 IN ULONG PreferedMaximumLength,
534 OUT PULONG CountReturned)
535 {
536 LSAPR_PRIVILEGE_ENUM_BUFFER PrivilegeEnumBuffer;
537 NTSTATUS Status;
538
539 TRACE("LsaEnumeratePrivileges(%p %p %p %lu %p)\n",
540 PolicyHandle, EnumerationContext, Buffer,
541 PreferedMaximumLength, CountReturned);
542
543 PrivilegeEnumBuffer.Entries = 0;
544 PrivilegeEnumBuffer.Privileges = NULL;
545
546 RpcTryExcept
547 {
548 Status = LsarEnumeratePrivileges((LSAPR_HANDLE)PolicyHandle,
549 EnumerationContext,
550 &PrivilegeEnumBuffer,
551 PreferedMaximumLength);
552
553 *Buffer = PrivilegeEnumBuffer.Privileges;
554 *CountReturned = PrivilegeEnumBuffer.Entries;
555
556 }
557 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
558 {
559 if (PrivilegeEnumBuffer.Privileges != NULL)
560 MIDL_user_free(PrivilegeEnumBuffer.Privileges);
561
562 Status = I_RpcMapWin32Status(RpcExceptionCode());
563 }
564 RpcEndExcept;
565
566 return Status;
567 }
568
569
570 /*
571 * @implemented
572 */
573 NTSTATUS
574 WINAPI
575 LsaEnumeratePrivilegesOfAccount(IN LSA_HANDLE AccountHandle,
576 OUT PPRIVILEGE_SET *Privileges)
577 {
578 NTSTATUS Status;
579
580 TRACE("LsaEnumeratePrivilegesOfAccount(%p %p)\n",
581 AccountHandle, Privileges);
582
583 RpcTryExcept
584 {
585 Status = LsarEnumeratePrivilegesAccount((LSAPR_HANDLE)AccountHandle,
586 (LSAPR_PRIVILEGE_SET **)Privileges);
587 }
588 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
589 {
590 Status = I_RpcMapWin32Status(RpcExceptionCode());
591 }
592 RpcEndExcept;
593
594 return Status;
595 }
596
597
598 /*
599 * @unimplemented
600 */
601 NTSTATUS
602 WINAPI
603 LsaEnumerateTrustedDomains(IN LSA_HANDLE PolicyHandle,
604 IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
605 OUT PVOID *Buffer,
606 IN ULONG PreferedMaximumLength,
607 OUT PULONG CountReturned)
608 {
609 FIXME("LsaEnumerateTrustedDomains(%p %p %p %lu %p) stub\n",
610 PolicyHandle, EnumerationContext, Buffer,
611 PreferedMaximumLength, CountReturned);
612
613 if (CountReturned)
614 *CountReturned = 0;
615
616 return STATUS_SUCCESS;
617 }
618
619
620 /*
621 * @unimplemented
622 */
623 NTSTATUS
624 WINAPI
625 LsaEnumerateTrustedDomainsEx(IN LSA_HANDLE PolicyHandle,
626 IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
627 OUT PVOID *Buffer,
628 IN ULONG PreferedMaximumLength,
629 OUT PULONG CountReturned)
630 {
631 FIXME("LsaEnumerateTrustedDomainsEx(%p %p %p %lu %p) stub\n",
632 PolicyHandle, EnumerationContext, Buffer,
633 PreferedMaximumLength, CountReturned);
634
635 if (CountReturned)
636 *CountReturned = 0;
637
638 return STATUS_SUCCESS;
639 }
640
641
642 /*
643 * @implemented
644 */
645 NTSTATUS
646 WINAPI
647 LsaFreeMemory(IN PVOID Buffer)
648 {
649 TRACE("LsaFreeMemory(%p)\n", Buffer);
650 return RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
651 }
652
653
654 /*
655 * @implemented
656 */
657 NTSTATUS
658 WINAPI
659 LsaGetQuotasForAccount(IN LSA_HANDLE AccountHandle,
660 OUT PQUOTA_LIMITS QuotaLimits)
661 {
662 NTSTATUS Status;
663
664 TRACE("LsaGetQuotasForAccount(%p %p)\n",
665 AccountHandle, QuotaLimits);
666
667 RpcTryExcept
668 {
669 Status = LsarGetQuotasForAccount((LSAPR_HANDLE)AccountHandle,
670 QuotaLimits);
671 }
672 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
673 {
674 Status = I_RpcMapWin32Status(RpcExceptionCode());
675 }
676 RpcEndExcept;
677
678 return Status;
679 }
680
681
682 /*
683 * @implemented
684 */
685 NTSTATUS
686 WINAPI
687 LsaGetSystemAccessAccount(IN LSA_HANDLE AccountHandle,
688 OUT PULONG SystemAccess)
689 {
690 NTSTATUS Status;
691
692 TRACE("LsaGetSystemAccessAccount(%p %p)\n",
693 AccountHandle, SystemAccess);
694
695 RpcTryExcept
696 {
697 Status = LsarGetSystemAccessAccount((LSAPR_HANDLE)AccountHandle,
698 (ACCESS_MASK *)SystemAccess);
699 }
700 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
701 {
702 Status = I_RpcMapWin32Status(RpcExceptionCode());
703 }
704 RpcEndExcept;
705
706 return Status;
707 }
708
709
710 /*
711 * @implemented
712 */
713 NTSTATUS
714 WINAPI
715 LsaGetUserName(OUT PUNICODE_STRING *UserName,
716 OUT PUNICODE_STRING *DomainName OPTIONAL)
717 {
718 PRPC_UNICODE_STRING UserNameString = NULL;
719 PRPC_UNICODE_STRING DomainNameString = NULL;
720 NTSTATUS Status;
721
722 TRACE("LsaGetUserName(%p %p)\n",
723 UserName, DomainName);
724
725 RpcTryExcept
726 {
727 Status = LsarGetUserName(NULL,
728 &UserNameString,
729 (DomainName != NULL) ? &DomainNameString : NULL);
730
731 *UserName = (PUNICODE_STRING)UserNameString;
732
733 if (DomainName != NULL)
734 *DomainName = (PUNICODE_STRING)DomainNameString;
735 }
736 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
737 {
738 if (UserNameString != NULL)
739 MIDL_user_free(UserNameString);
740
741 if (DomainNameString != NULL)
742 MIDL_user_free(DomainNameString);
743
744 Status = I_RpcMapWin32Status(RpcExceptionCode());
745 }
746 RpcEndExcept;
747
748 return Status;
749 }
750
751
752 /*
753 * @implemented
754 */
755 NTSTATUS
756 WINAPI
757 LsaLookupNames(IN LSA_HANDLE PolicyHandle,
758 IN ULONG Count,
759 IN PLSA_UNICODE_STRING Names,
760 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
761 OUT PLSA_TRANSLATED_SID *Sids)
762 {
763 LSAPR_TRANSLATED_SIDS TranslatedSids = {0, NULL};
764 ULONG MappedCount = 0;
765 NTSTATUS Status;
766
767 TRACE("LsaLookupNames(%p %lu %p %p %p)\n",
768 PolicyHandle, Count, Names, ReferencedDomains, Sids);
769
770 if (ReferencedDomains == NULL || Sids == NULL)
771 return STATUS_INVALID_PARAMETER;
772
773 RpcTryExcept
774 {
775 *ReferencedDomains = NULL;
776 *Sids = NULL;
777
778 TranslatedSids.Entries = Count;
779
780 Status = LsarLookupNames((LSAPR_HANDLE)PolicyHandle,
781 Count,
782 (PRPC_UNICODE_STRING)Names,
783 (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
784 &TranslatedSids,
785 LsapLookupWksta,
786 &MappedCount);
787
788 *Sids = (PLSA_TRANSLATED_SID)TranslatedSids.Sids;
789 }
790 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
791 {
792 if (TranslatedSids.Sids != NULL)
793 MIDL_user_free(TranslatedSids.Sids);
794
795 Status = I_RpcMapWin32Status(RpcExceptionCode());
796 }
797 RpcEndExcept;
798
799 return Status;
800 }
801
802
803 /*
804 * @implemented
805 */
806 NTSTATUS
807 WINAPI
808 LsaLookupNames2(IN LSA_HANDLE PolicyHandle,
809 IN ULONG Flags,
810 IN ULONG Count,
811 IN PLSA_UNICODE_STRING Names,
812 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
813 OUT PLSA_TRANSLATED_SID2 *Sids)
814 {
815 LSAPR_TRANSLATED_SIDS_EX2 TranslatedSids = {0, NULL};
816 ULONG MappedCount = 0;
817 NTSTATUS Status;
818
819 TRACE("LsaLookupNames2(%p 0x%08x %lu %p %p %p)\n",
820 PolicyHandle, Flags, Count, Names, ReferencedDomains, Sids);
821
822 if (ReferencedDomains == NULL || Sids == NULL)
823 return STATUS_INVALID_PARAMETER;
824
825 RpcTryExcept
826 {
827 *ReferencedDomains = NULL;
828 *Sids = NULL;
829
830 TranslatedSids.Entries = Count;
831
832 Status = LsarLookupNames3((LSAPR_HANDLE)PolicyHandle,
833 Count,
834 (PRPC_UNICODE_STRING)Names,
835 (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
836 &TranslatedSids,
837 LsapLookupWksta,
838 &MappedCount,
839 Flags,
840 2);
841
842 *Sids = (PLSA_TRANSLATED_SID2)TranslatedSids.Sids;
843 }
844 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
845 {
846 if (TranslatedSids.Sids != NULL)
847 MIDL_user_free(TranslatedSids.Sids);
848
849 Status = I_RpcMapWin32Status(RpcExceptionCode());
850 }
851 RpcEndExcept;
852
853 return Status;
854 }
855
856
857 /*
858 * @implemented
859 */
860 NTSTATUS
861 WINAPI
862 LsaLookupPrivilegeName(IN LSA_HANDLE PolicyHandle,
863 IN PLUID Value,
864 OUT PUNICODE_STRING *Name)
865 {
866 PRPC_UNICODE_STRING NameBuffer = NULL;
867 NTSTATUS Status;
868
869 TRACE("LsaLookupPrivilegeName(%p %p %p)\n",
870 PolicyHandle, Value, Name);
871
872 RpcTryExcept
873 {
874 Status = LsarLookupPrivilegeName(PolicyHandle,
875 Value,
876 &NameBuffer);
877
878 *Name = (PUNICODE_STRING)NameBuffer;
879 }
880 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
881 {
882 if (NameBuffer != NULL)
883 MIDL_user_free(NameBuffer);
884
885 Status = I_RpcMapWin32Status(RpcExceptionCode());
886 }
887 RpcEndExcept;
888
889 return Status;
890 }
891
892
893 /*
894 * @implemented
895 */
896 NTSTATUS
897 WINAPI
898 LsaLookupPrivilegeValue(IN LSA_HANDLE PolicyHandle,
899 IN PLSA_UNICODE_STRING Name,
900 OUT PLUID Value)
901 {
902 LUID Luid;
903 NTSTATUS Status;
904
905 TRACE("LsaLookupPrivilegeValue(%p %p %p)\n",
906 PolicyHandle, Name, Value);
907
908 RpcTryExcept
909 {
910 Status = LsarLookupPrivilegeValue(PolicyHandle,
911 (PRPC_UNICODE_STRING)Name,
912 &Luid);
913 if (Status == STATUS_SUCCESS)
914 *Value = Luid;
915 }
916 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
917 {
918 Status = I_RpcMapWin32Status(RpcExceptionCode());
919 }
920 RpcEndExcept;
921
922 return Status;
923 }
924
925
926 /*
927 * @implemented
928 */
929 NTSTATUS
930 WINAPI
931 LsaLookupSids(IN LSA_HANDLE PolicyHandle,
932 IN ULONG Count,
933 IN PSID *Sids,
934 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
935 OUT PLSA_TRANSLATED_NAME *Names)
936 {
937 LSAPR_SID_ENUM_BUFFER SidEnumBuffer;
938 LSAPR_TRANSLATED_NAMES TranslatedNames;
939 ULONG MappedCount = 0;
940 NTSTATUS Status;
941
942 TRACE("LsaLookupSids(%p %lu %p %p %p)\n",
943 PolicyHandle, Count, Sids, ReferencedDomains, Names);
944
945 if (Count == 0)
946 return STATUS_INVALID_PARAMETER;
947
948 SidEnumBuffer.Entries = Count;
949 SidEnumBuffer.SidInfo = (PLSAPR_SID_INFORMATION)Sids;
950
951 RpcTryExcept
952 {
953 *ReferencedDomains = NULL;
954 *Names = NULL;
955
956 TranslatedNames.Entries = 0;
957 TranslatedNames.Names = NULL;
958
959 Status = LsarLookupSids((LSAPR_HANDLE)PolicyHandle,
960 &SidEnumBuffer,
961 (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
962 &TranslatedNames,
963 LsapLookupWksta,
964 &MappedCount);
965
966 *Names = (PLSA_TRANSLATED_NAME)TranslatedNames.Names;
967 }
968 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
969 {
970 if (TranslatedNames.Names != NULL)
971 {
972 MIDL_user_free(TranslatedNames.Names);
973 }
974
975 Status = I_RpcMapWin32Status(RpcExceptionCode());
976 }
977 RpcEndExcept;
978
979 return Status;
980 }
981
982
983 /******************************************************************************
984 * LsaNtStatusToWinError
985 *
986 * PARAMS
987 * Status [I]
988 *
989 * @implemented
990 */
991 ULONG
992 WINAPI
993 LsaNtStatusToWinError(IN NTSTATUS Status)
994 {
995 TRACE("LsaNtStatusToWinError(0x%lx)\n", Status);
996 return RtlNtStatusToDosError(Status);
997 }
998
999
1000 /*
1001 * @implemented
1002 */
1003 NTSTATUS
1004 WINAPI
1005 LsaOpenAccount(IN LSA_HANDLE PolicyHandle,
1006 IN PSID AccountSid,
1007 IN ACCESS_MASK DesiredAccess,
1008 OUT PLSA_HANDLE AccountHandle)
1009 {
1010 NTSTATUS Status;
1011
1012 TRACE("LsaOpenAccount(%p %p 0x%08lx %p)\n",
1013 PolicyHandle, AccountSid, DesiredAccess, AccountHandle);
1014
1015 RpcTryExcept
1016 {
1017 Status = LsarOpenAccount((LSAPR_HANDLE)PolicyHandle,
1018 AccountSid,
1019 DesiredAccess,
1020 AccountHandle);
1021 }
1022 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1023 {
1024 Status = I_RpcMapWin32Status(RpcExceptionCode());
1025 }
1026 RpcEndExcept;
1027
1028 return Status;
1029 }
1030
1031
1032 /******************************************************************************
1033 * LsaOpenPolicy
1034 *
1035 * PARAMS
1036 * x1 []
1037 * x2 []
1038 * x3 []
1039 * x4 []
1040 *
1041 * @implemented
1042 */
1043 NTSTATUS
1044 WINAPI
1045 LsaOpenPolicy(IN PLSA_UNICODE_STRING SystemName OPTIONAL,
1046 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
1047 IN ACCESS_MASK DesiredAccess,
1048 OUT PLSA_HANDLE PolicyHandle)
1049 {
1050 NTSTATUS Status;
1051
1052 TRACE("LsaOpenPolicy(%s %p 0x%08lx %p)\n",
1053 SystemName ? debugstr_w(SystemName->Buffer) : "(null)",
1054 ObjectAttributes, DesiredAccess, PolicyHandle);
1055
1056 /* FIXME: RPC should take care of this */
1057 if (!LsapIsLocalComputer(SystemName))
1058 return RPC_NT_SERVER_UNAVAILABLE;
1059
1060 RpcTryExcept
1061 {
1062 *PolicyHandle = NULL;
1063
1064 Status = LsarOpenPolicy(SystemName ? SystemName->Buffer : NULL,
1065 (PLSAPR_OBJECT_ATTRIBUTES)ObjectAttributes,
1066 DesiredAccess,
1067 PolicyHandle);
1068 }
1069 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1070 {
1071 Status = I_RpcMapWin32Status(RpcExceptionCode());
1072 }
1073 RpcEndExcept;
1074
1075 TRACE("LsaOpenPolicy() done (Status: 0x%08lx)\n", Status);
1076
1077 return Status;
1078 }
1079
1080
1081 NTSTATUS
1082 WINAPI
1083 LsaOpenSecret(IN LSA_HANDLE PolicyHandle,
1084 IN PLSA_UNICODE_STRING SecretName,
1085 IN ACCESS_MASK DesiredAccess,
1086 OUT PLSA_HANDLE SecretHandle)
1087 {
1088 NTSTATUS Status;
1089
1090 TRACE("LsaOpenSecret(%p %p 0x%08lx %p)\n",
1091 PolicyHandle, SecretName, DesiredAccess, SecretHandle);
1092
1093 RpcTryExcept
1094 {
1095 *SecretHandle = NULL;
1096
1097 Status = LsarOpenSecret((LSAPR_HANDLE)PolicyHandle,
1098 (PRPC_UNICODE_STRING)SecretName,
1099 DesiredAccess,
1100 SecretHandle);
1101 }
1102 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1103 {
1104 Status = I_RpcMapWin32Status(RpcExceptionCode());
1105 }
1106 RpcEndExcept;
1107
1108 TRACE("LsaOpenSecret() done (Status: 0x%08lx)\n", Status);
1109
1110 return Status;
1111 }
1112
1113
1114 /*
1115 * @implemented
1116 */
1117 NTSTATUS
1118 WINAPI
1119 LsaOpenTrustedDomain(IN LSA_HANDLE PolicyHandle,
1120 IN PSID TrustedDomainSid,
1121 IN ACCESS_MASK DesiredAccess,
1122 OUT PLSA_HANDLE TrustedDomainHandle)
1123 {
1124 NTSTATUS Status;
1125
1126 TRACE("LsaOpenTrustedDomain(%p %p 0x%08lx %p)\n",
1127 PolicyHandle, TrustedDomainSid, DesiredAccess, TrustedDomainHandle);
1128
1129 RpcTryExcept
1130 {
1131 Status = LsarOpenTrustedDomain((LSAPR_HANDLE)PolicyHandle,
1132 (PRPC_SID)TrustedDomainSid,
1133 DesiredAccess,
1134 (PLSAPR_HANDLE)TrustedDomainHandle);
1135 }
1136 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1137 {
1138 Status = I_RpcMapWin32Status(RpcExceptionCode());
1139 }
1140 RpcEndExcept;
1141
1142 return Status;
1143 }
1144
1145
1146 /*
1147 * @implemented
1148 */
1149 NTSTATUS
1150 WINAPI
1151 LsaOpenTrustedDomainByName(IN LSA_HANDLE PolicyHandle,
1152 IN PLSA_UNICODE_STRING TrustedDomainName,
1153 IN ACCESS_MASK DesiredAccess,
1154 OUT PLSA_HANDLE TrustedDomainHandle)
1155 {
1156 NTSTATUS Status;
1157
1158 TRACE("LsaOpenTrustedDomainByName(%p %p 0x%08lx %p)\n",
1159 PolicyHandle, TrustedDomainName, DesiredAccess, TrustedDomainHandle);
1160
1161 RpcTryExcept
1162 {
1163 Status = LsarOpenTrustedDomainByName((LSAPR_HANDLE)PolicyHandle,
1164 (PRPC_UNICODE_STRING)TrustedDomainName,
1165 DesiredAccess,
1166 TrustedDomainHandle);
1167 }
1168 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1169 {
1170 Status = I_RpcMapWin32Status(RpcExceptionCode());
1171 }
1172 RpcEndExcept;
1173
1174 return Status;
1175 }
1176
1177
1178 /*
1179 * @unimplemented
1180 */
1181 NTSTATUS
1182 WINAPI
1183 LsaQueryDomainInformationPolicy(IN LSA_HANDLE PolicyHandle,
1184 IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
1185 OUT PVOID *Buffer)
1186 {
1187 FIXME("LsaQueryDomainInformationPolicy(%p %lu %p) stub\n",
1188 PolicyHandle, InformationClass, Buffer);
1189 return STATUS_NOT_IMPLEMENTED;
1190 }
1191
1192
1193 /*
1194 * @unimplemented
1195 */
1196 NTSTATUS
1197 WINAPI
1198 LsaQueryForestTrustInformation(IN LSA_HANDLE PolicyHandle,
1199 IN PLSA_UNICODE_STRING TrustedDomainName,
1200 OUT PLSA_FOREST_TRUST_INFORMATION *ForestTrustInfo)
1201 {
1202 FIXME("LsaQueryForestTrustInformation(%p %p %p) stub\n",
1203 PolicyHandle, TrustedDomainName, ForestTrustInfo);
1204 return STATUS_NOT_IMPLEMENTED;
1205 }
1206
1207
1208 /*
1209 * @unimplemented
1210 */
1211 NTSTATUS
1212 WINAPI
1213 LsaQueryInfoTrustedDomain(IN LSA_HANDLE TrustedDomainHandle,
1214 IN TRUSTED_INFORMATION_CLASS InformationClass,
1215 OUT PVOID *Buffer)
1216 {
1217 FIXME("LsaQueryInfoTrustedDomain(%p %d %p) stub\n",
1218 TrustedDomainHandle, InformationClass, Buffer);
1219 return STATUS_NOT_IMPLEMENTED;
1220 }
1221
1222
1223 /*
1224 * @implemented
1225 */
1226 NTSTATUS
1227 WINAPI
1228 LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle,
1229 IN POLICY_INFORMATION_CLASS InformationClass,
1230 OUT PVOID *Buffer)
1231 {
1232 PLSAPR_POLICY_INFORMATION PolicyInformation = NULL;
1233 NTSTATUS Status;
1234
1235 TRACE("LsaQueryInformationPolicy(%p %d %p)\n",
1236 PolicyHandle, InformationClass, Buffer);
1237
1238 RpcTryExcept
1239 {
1240 Status = LsarQueryInformationPolicy((LSAPR_HANDLE)PolicyHandle,
1241 InformationClass,
1242 &PolicyInformation);
1243 *Buffer = PolicyInformation;
1244 }
1245 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1246 {
1247 if (PolicyInformation != NULL)
1248 MIDL_user_free(PolicyInformation);
1249
1250 Status = I_RpcMapWin32Status(RpcExceptionCode());
1251 }
1252 RpcEndExcept;
1253
1254 TRACE("Done (Status: 0x%08x)\n", Status);
1255
1256 return Status;
1257 }
1258
1259
1260 /*
1261 * @unimplemented
1262 */
1263 NTSTATUS
1264 WINAPI
1265 LsaQuerySecret(IN LSA_HANDLE SecretHandle,
1266 OUT PLSA_UNICODE_STRING *CurrentValue OPTIONAL,
1267 OUT PLARGE_INTEGER CurrentValueSetTime OPTIONAL,
1268 OUT PLSA_UNICODE_STRING *OldValue OPTIONAL,
1269 OUT PLARGE_INTEGER OldValueSetTime OPTIONAL)
1270 {
1271 PLSAPR_CR_CIPHER_VALUE EncryptedCurrentValue = NULL;
1272 PLSAPR_CR_CIPHER_VALUE EncryptedOldValue = NULL;
1273 PLSA_UNICODE_STRING DecryptedCurrentValue = NULL;
1274 PLSA_UNICODE_STRING DecryptedOldValue = NULL;
1275 SIZE_T BufferSize;
1276 NTSTATUS Status;
1277
1278 TRACE("LsaQuerySecret(%p %p %p %p %p)\n",
1279 SecretHandle, CurrentValue, CurrentValueSetTime,
1280 OldValue, OldValueSetTime);
1281
1282 RpcTryExcept
1283 {
1284 Status = LsarQuerySecret((PLSAPR_HANDLE)SecretHandle,
1285 &EncryptedCurrentValue,
1286 CurrentValueSetTime,
1287 &EncryptedOldValue,
1288 OldValueSetTime);
1289 }
1290 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1291 {
1292 Status = I_RpcMapWin32Status(RpcExceptionCode());
1293 }
1294 RpcEndExcept;
1295
1296 if (!NT_SUCCESS(Status))
1297 goto done;
1298
1299 /* Decrypt the current value */
1300 if (CurrentValue != NULL)
1301 {
1302 if (EncryptedCurrentValue == NULL)
1303 {
1304 *CurrentValue = NULL;
1305 }
1306 else
1307 {
1308 /* FIXME: Decrypt the current value */
1309 BufferSize = sizeof(LSA_UNICODE_STRING) + EncryptedCurrentValue->MaximumLength;
1310 DecryptedCurrentValue = midl_user_allocate(BufferSize);
1311 if (DecryptedCurrentValue == NULL)
1312 {
1313 Status = STATUS_INSUFFICIENT_RESOURCES;
1314 goto done;
1315 }
1316
1317 DecryptedCurrentValue->Length = (USHORT)EncryptedCurrentValue->Length;
1318 DecryptedCurrentValue->MaximumLength = (USHORT)EncryptedCurrentValue->MaximumLength;
1319 DecryptedCurrentValue->Buffer = (PWSTR)(DecryptedCurrentValue + 1);
1320 RtlCopyMemory(DecryptedCurrentValue->Buffer,
1321 EncryptedCurrentValue->Buffer,
1322 EncryptedCurrentValue->Length);
1323
1324 *CurrentValue = DecryptedCurrentValue;
1325 }
1326 }
1327
1328 /* Decrypt the old value */
1329 if (OldValue != NULL)
1330 {
1331 if (EncryptedOldValue == NULL)
1332 {
1333 *OldValue = NULL;
1334 }
1335 else
1336 {
1337 /* FIXME: Decrypt the old value */
1338 BufferSize = sizeof(LSA_UNICODE_STRING) + EncryptedOldValue->MaximumLength;
1339 DecryptedOldValue = midl_user_allocate(BufferSize);
1340 if (DecryptedOldValue == NULL)
1341 {
1342 Status = STATUS_INSUFFICIENT_RESOURCES;
1343 goto done;
1344 }
1345
1346 DecryptedOldValue->Length = (USHORT)EncryptedOldValue->Length;
1347 DecryptedOldValue->MaximumLength = (USHORT)EncryptedOldValue->MaximumLength;
1348 DecryptedOldValue->Buffer = (PWSTR)(DecryptedOldValue + 1);
1349 RtlCopyMemory(DecryptedOldValue->Buffer,
1350 EncryptedOldValue->Buffer,
1351 EncryptedOldValue->Length);
1352
1353 *OldValue = DecryptedOldValue;
1354 }
1355 }
1356
1357 done:
1358 if (!NT_SUCCESS(Status))
1359 {
1360 if (DecryptedCurrentValue != NULL)
1361 midl_user_free(DecryptedCurrentValue);
1362
1363 if (DecryptedOldValue != NULL)
1364 midl_user_free(DecryptedOldValue);
1365
1366 if (CurrentValue != NULL)
1367 *CurrentValue = NULL;
1368
1369 if (OldValue != NULL)
1370 *OldValue = NULL;
1371 }
1372
1373 if (EncryptedCurrentValue != NULL)
1374 midl_user_free(EncryptedCurrentValue);
1375
1376 if (EncryptedOldValue != NULL)
1377 midl_user_free(EncryptedOldValue);
1378
1379 return Status;
1380 }
1381
1382
1383 /*
1384 * @implemented
1385 */
1386 NTSTATUS
1387 WINAPI
1388 LsaQuerySecurityObject(IN LSA_HANDLE ObjectHandle,
1389 IN SECURITY_INFORMATION SecurityInformation,
1390 OUT PSECURITY_DESCRIPTOR *SecurityDescriptor)
1391 {
1392 LSAPR_SR_SECURITY_DESCRIPTOR SdBuffer;
1393 PLSAPR_SR_SECURITY_DESCRIPTOR SdPointer;
1394 NTSTATUS Status;
1395
1396 TRACE("LsaQuerySecurityObject(%p %lx %p)\n",
1397 ObjectHandle, SecurityInformation, SecurityDescriptor);
1398
1399 SdBuffer.Length = 0;
1400 SdBuffer.SecurityDescriptor = NULL;
1401
1402 SdPointer = &SdBuffer;
1403
1404 RpcTryExcept
1405 {
1406 Status = LsarQuerySecurityObject((LSAPR_HANDLE)ObjectHandle,
1407 SecurityInformation,
1408 &SdPointer);
1409 if (NT_SUCCESS(Status))
1410 {
1411 *SecurityDescriptor = SdBuffer.SecurityDescriptor;
1412 }
1413 else
1414 {
1415 *SecurityDescriptor = NULL;
1416 }
1417 }
1418 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1419 {
1420 Status = I_RpcMapWin32Status(RpcExceptionCode());
1421 }
1422 RpcEndExcept;
1423
1424 return Status;
1425 }
1426
1427
1428 /*
1429 * @unimplemented
1430 */
1431 NTSTATUS
1432 WINAPI
1433 LsaQueryTrustedDomainInfo(IN LSA_HANDLE PolicyHandle,
1434 IN PSID TrustedDomainSid,
1435 IN TRUSTED_INFORMATION_CLASS InformationClass,
1436 OUT PVOID *Buffer)
1437 {
1438 FIXME("LsaQueryTrustedDomainInfo(%p %p %d %p) stub\n",
1439 PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
1440 return STATUS_OBJECT_NAME_NOT_FOUND;
1441 }
1442
1443
1444 /*
1445 * @implemented
1446 */
1447 NTSTATUS
1448 WINAPI
1449 LsaQueryTrustedDomainInfoByName(IN LSA_HANDLE PolicyHandle,
1450 IN PLSA_UNICODE_STRING TrustedDomainName,
1451 IN TRUSTED_INFORMATION_CLASS InformationClass,
1452 OUT PVOID *Buffer)
1453 {
1454 NTSTATUS Status;
1455
1456 TRACE("LsaQueryTrustedDomainInfoByName(%p %p %d %p)\n",
1457 PolicyHandle, TrustedDomainName, InformationClass, Buffer);
1458
1459 if (InformationClass == TrustedDomainAuthInformationInternal ||
1460 InformationClass == TrustedDomainFullInformationInternal)
1461 return STATUS_INVALID_INFO_CLASS;
1462
1463 RpcTryExcept
1464 {
1465 Status = LsarQueryTrustedDomainInfoByName((LSAPR_HANDLE)PolicyHandle,
1466 (PRPC_UNICODE_STRING)TrustedDomainName,
1467 InformationClass,
1468 (unsigned long *)Buffer); // Shuld be: (PLSAPR_POLICY_INFORMATION *)Buffer
1469 }
1470 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1471 {
1472 Status = I_RpcMapWin32Status(RpcExceptionCode());
1473 }
1474 RpcEndExcept;
1475
1476 return Status;
1477 }
1478
1479
1480 /*
1481 * @unimplemented
1482 */
1483 NTSTATUS
1484 WINAPI
1485 LsaRegisterPolicyChangeNotification(IN POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
1486 IN HANDLE NotificationEventHandle)
1487 {
1488 FIXME("LsaRegisterPolicyChangeNotification(%d %p) stub\n",
1489 InformationClass, NotificationEventHandle);
1490 return STATUS_UNSUCCESSFUL;
1491 }
1492
1493
1494 /*
1495 * @implemented
1496 */
1497 NTSTATUS
1498 WINAPI
1499 LsaRemoveAccountRights(IN LSA_HANDLE PolicyHandle,
1500 IN PSID AccountSid,
1501 IN BOOLEAN AllRights,
1502 IN PLSA_UNICODE_STRING UserRights,
1503 IN ULONG CountOfRights)
1504 {
1505 LSAPR_USER_RIGHT_SET UserRightSet;
1506
1507 TRACE("LsaRemoveAccountRights(%p %p %d %p %lu)\n",
1508 PolicyHandle, AccountSid, AllRights, UserRights, CountOfRights);
1509
1510 UserRightSet.Entries = CountOfRights;
1511 UserRightSet.UserRights = (PRPC_UNICODE_STRING)UserRights;
1512
1513 RpcTryExcept
1514 {
1515 LsarRemoveAccountRights((LSAPR_HANDLE)PolicyHandle,
1516 (PRPC_SID)AccountSid,
1517 AllRights,
1518 &UserRightSet);
1519 }
1520 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1521 {
1522 I_RpcMapWin32Status(RpcExceptionCode());
1523 }
1524 RpcEndExcept;
1525
1526 return STATUS_SUCCESS;
1527 }
1528
1529
1530 /*
1531 * @unimplemented
1532 */
1533 NTSTATUS
1534 WINAPI
1535 LsaRetrievePrivateData(IN LSA_HANDLE PolicyHandle,
1536 IN PLSA_UNICODE_STRING KeyName,
1537 OUT PLSA_UNICODE_STRING *PrivateData)
1538 {
1539 FIXME("LsaRetrievePrivateData(%p %p %p) stub\n",
1540 PolicyHandle, KeyName, PrivateData);
1541 return STATUS_OBJECT_NAME_NOT_FOUND;
1542 }
1543
1544
1545 /*
1546 * @unimplemented
1547 */
1548 NTSTATUS
1549 WINAPI
1550 LsaSetDomainInformationPolicy(IN LSA_HANDLE PolicyHandle,
1551 IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
1552 IN PVOID Buffer OPTIONAL)
1553 {
1554 FIXME("LsaSetDomainInformationPolicy(%p %d %p) stub\n",
1555 PolicyHandle, InformationClass, Buffer);
1556 return STATUS_UNSUCCESSFUL;
1557 }
1558
1559
1560 /*
1561 * @unimplemented
1562 */
1563 NTSTATUS
1564 WINAPI
1565 LsaSetForestTrustInformation(IN LSA_HANDLE PolicyHandle,
1566 IN PLSA_UNICODE_STRING TrustedDomainName,
1567 IN PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo,
1568 IN BOOL CheckOnly,
1569 OUT PLSA_FOREST_TRUST_COLLISION_INFORMATION *CollisionInfo)
1570 {
1571 FIXME("LsaSetForestTrustInformation(%p %p %p %d %p) stub\n",
1572 PolicyHandle, TrustedDomainName, ForestTrustInfo, CheckOnly, CollisionInfo);
1573 return STATUS_NOT_IMPLEMENTED;
1574 }
1575
1576
1577 /*
1578 * @implemented
1579 */
1580 NTSTATUS
1581 WINAPI
1582 LsaSetInformationPolicy(IN LSA_HANDLE PolicyHandle,
1583 IN POLICY_INFORMATION_CLASS InformationClass,
1584 IN PVOID Buffer)
1585 {
1586 NTSTATUS Status;
1587
1588 TRACE("LsaSetInformationPolicy(%p %d %p)\n",
1589 PolicyHandle, InformationClass, Buffer);
1590
1591 RpcTryExcept
1592 {
1593 Status = LsarSetInformationPolicy((LSAPR_HANDLE)PolicyHandle,
1594 InformationClass,
1595 (PLSAPR_POLICY_INFORMATION)Buffer);
1596 }
1597 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1598 {
1599 Status = I_RpcMapWin32Status(RpcExceptionCode());
1600 }
1601 RpcEndExcept;
1602
1603 return Status;
1604 }
1605
1606
1607 /*
1608 * @implemented
1609 */
1610 NTSTATUS
1611 WINAPI
1612 LsaSetQuotasForAccount(IN LSA_HANDLE AccountHandle,
1613 IN PQUOTA_LIMITS QuotaLimits)
1614 {
1615 NTSTATUS Status;
1616
1617 TRACE("LsaSetQuotasForAccount(%p %p)\n",
1618 AccountHandle, QuotaLimits);
1619
1620 RpcTryExcept
1621 {
1622 Status = LsarSetQuotasForAccount((LSAPR_HANDLE)AccountHandle,
1623 QuotaLimits);
1624 }
1625 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1626 {
1627 Status = I_RpcMapWin32Status(RpcExceptionCode());
1628 }
1629 RpcEndExcept;
1630
1631 return Status;
1632 }
1633
1634
1635 /*
1636 * @implemented
1637 */
1638 NTSTATUS
1639 WINAPI
1640 LsaSetSecret(IN LSA_HANDLE SecretHandle,
1641 IN PLSA_UNICODE_STRING CurrentValue OPTIONAL,
1642 IN PLSA_UNICODE_STRING OldValue OPTIONAL)
1643 {
1644 PLSAPR_CR_CIPHER_VALUE EncryptedCurrentValue = NULL;
1645 PLSAPR_CR_CIPHER_VALUE EncryptedOldValue = NULL;
1646 SIZE_T BufferSize;
1647 NTSTATUS Status;
1648
1649 TRACE("LsaSetSecret(%p %p %p)\n",
1650 SecretHandle, EncryptedCurrentValue, EncryptedOldValue);
1651
1652 if (CurrentValue != NULL)
1653 {
1654 BufferSize = sizeof(LSAPR_CR_CIPHER_VALUE) + CurrentValue->MaximumLength;
1655 EncryptedCurrentValue = midl_user_allocate(BufferSize);
1656 if (EncryptedCurrentValue == NULL)
1657 {
1658 Status = STATUS_INSUFFICIENT_RESOURCES;
1659 goto done;
1660 }
1661
1662 EncryptedCurrentValue->Length = CurrentValue->Length;
1663 EncryptedCurrentValue->MaximumLength = CurrentValue->MaximumLength;
1664 EncryptedCurrentValue->Buffer = (BYTE *)(EncryptedCurrentValue + 1);
1665 if (EncryptedCurrentValue->Buffer != NULL)
1666 memcpy(EncryptedCurrentValue->Buffer, CurrentValue->Buffer, CurrentValue->Length);
1667 }
1668
1669 if (OldValue != NULL)
1670 {
1671 BufferSize = sizeof(LSAPR_CR_CIPHER_VALUE) + OldValue->MaximumLength;
1672 EncryptedOldValue = midl_user_allocate(BufferSize);
1673 if (EncryptedOldValue == NULL)
1674 {
1675 Status = STATUS_INSUFFICIENT_RESOURCES;
1676 goto done;
1677 }
1678
1679 EncryptedOldValue->Length = OldValue->Length;
1680 EncryptedOldValue->MaximumLength = OldValue->MaximumLength;
1681 EncryptedOldValue->Buffer = (BYTE*)(EncryptedOldValue + 1);
1682 if (EncryptedOldValue->Buffer != NULL)
1683 memcpy(EncryptedOldValue->Buffer, OldValue->Buffer, OldValue->Length);
1684 }
1685
1686 RpcTryExcept
1687 {
1688 Status = LsarSetSecret((LSAPR_HANDLE)SecretHandle,
1689 EncryptedCurrentValue,
1690 EncryptedOldValue);
1691 }
1692 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1693 {
1694 Status = I_RpcMapWin32Status(RpcExceptionCode());
1695 }
1696 RpcEndExcept;
1697
1698 done:
1699 if (EncryptedCurrentValue != NULL)
1700 midl_user_free(EncryptedCurrentValue);
1701
1702 if (EncryptedOldValue != NULL)
1703 midl_user_free(EncryptedOldValue);
1704
1705 return Status;
1706 }
1707
1708
1709 /*
1710 * @implemented
1711 */
1712 NTSTATUS
1713 WINAPI
1714 LsaSetSecurityObject(IN LSA_HANDLE ObjectHandle,
1715 IN SECURITY_INFORMATION SecurityInformation,
1716 IN PSECURITY_DESCRIPTOR SecurityDescriptor)
1717 {
1718 LSAPR_SR_SECURITY_DESCRIPTOR SdBuffer = {0, NULL};
1719 ULONG SdLength = 0;
1720 NTSTATUS Status;
1721
1722 TRACE("LsaSetSecurityObject(%p %lx %p)\n",
1723 ObjectHandle, SecurityInformation, SecurityDescriptor);
1724
1725 Status = RtlMakeSelfRelativeSD(SecurityDescriptor,
1726 NULL,
1727 &SdLength);
1728 if (Status != STATUS_BUFFER_TOO_SMALL)
1729 return STATUS_INVALID_PARAMETER;
1730
1731 SdBuffer.SecurityDescriptor = MIDL_user_allocate(SdLength);
1732 if (SdBuffer.SecurityDescriptor == NULL)
1733 return STATUS_INSUFFICIENT_RESOURCES;
1734
1735 Status = RtlMakeSelfRelativeSD(SecurityDescriptor,
1736 (PSECURITY_DESCRIPTOR)SdBuffer.SecurityDescriptor,
1737 &SdLength);
1738 if (!NT_SUCCESS(Status))
1739 goto done;
1740
1741 SdBuffer.Length = SdLength;
1742
1743 RpcTryExcept
1744 {
1745 Status = LsarSetSecurityObject((LSAPR_HANDLE)ObjectHandle,
1746 SecurityInformation,
1747 &SdBuffer);
1748 }
1749 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1750 {
1751 Status = I_RpcMapWin32Status(RpcExceptionCode());
1752 }
1753 RpcEndExcept;
1754
1755 done:
1756 if (SdBuffer.SecurityDescriptor != NULL)
1757 MIDL_user_free(SdBuffer.SecurityDescriptor);
1758
1759 return Status;
1760 }
1761
1762
1763 /*
1764 * @implemented
1765 */
1766 NTSTATUS
1767 WINAPI
1768 LsaSetSystemAccessAccount(IN LSA_HANDLE AccountHandle,
1769 IN ULONG SystemAccess)
1770 {
1771 NTSTATUS Status;
1772
1773 TRACE("LsaSetSystemAccessAccount(%p 0x%lx)\n",
1774 AccountHandle, SystemAccess);
1775
1776 RpcTryExcept
1777 {
1778 Status = LsarSetSystemAccessAccount((LSAPR_HANDLE)AccountHandle,
1779 SystemAccess);
1780 }
1781 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1782 {
1783 Status = I_RpcMapWin32Status(RpcExceptionCode());
1784 }
1785 RpcEndExcept;
1786
1787 return Status;
1788 }
1789
1790
1791 /*
1792 * @unimplemented
1793 */
1794 NTSTATUS
1795 WINAPI
1796 LsaSetTrustedDomainInfoByName(IN LSA_HANDLE PolicyHandle,
1797 IN PLSA_UNICODE_STRING TrustedDomainName,
1798 IN TRUSTED_INFORMATION_CLASS InformationClass,
1799 IN PVOID Buffer)
1800 {
1801 FIXME("LsaSetTrustedDomainInfoByName(%p %p %d %p) stub\n",
1802 PolicyHandle, TrustedDomainName, InformationClass, Buffer);
1803 return STATUS_SUCCESS;
1804 }
1805
1806
1807 /*
1808 * @unimplemented
1809 */
1810 NTSTATUS
1811 WINAPI
1812 LsaSetTrustedDomainInformation(IN LSA_HANDLE PolicyHandle,
1813 IN PSID TrustedDomainSid,
1814 IN TRUSTED_INFORMATION_CLASS InformationClass,
1815 IN PVOID Buffer)
1816 {
1817 FIXME("LsaSetTrustedDomainInformation(%p %p %d %p) stub\n",
1818 PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
1819 return STATUS_SUCCESS;
1820 }
1821
1822
1823 /*
1824 * @unimplemented
1825 */
1826 NTSTATUS
1827 WINAPI
1828 LsaStorePrivateData(IN LSA_HANDLE PolicyHandle,
1829 IN PLSA_UNICODE_STRING KeyName,
1830 IN PLSA_UNICODE_STRING PrivateData OPTIONAL)
1831 {
1832 FIXME("LsaStorePrivateData(%p %p %p) stub\n",
1833 PolicyHandle, KeyName, PrivateData);
1834 return STATUS_OBJECT_NAME_NOT_FOUND;
1835 }
1836
1837
1838 /*
1839 * @unimplemented
1840 */
1841 NTSTATUS
1842 WINAPI
1843 LsaUnregisterPolicyChangeNotification(IN POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
1844 IN HANDLE NotificationEventHandle)
1845 {
1846 FIXME("(%d %p) stub\n",
1847 InformationClass, NotificationEventHandle);
1848 return STATUS_SUCCESS;
1849 }
1850
1851 /* EOF */