f88cc664e66b1afb58482ce1b8af679388a8a522
[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 #include <advapi32.h>
14
15 #include <lsa_c.h>
16
17 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
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 WINAPI
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 = LsarEnumerateAccountRights((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 * @implemented
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 LSAPR_TRUSTED_ENUM_BUFFER TrustedEnumBuffer;
610 NTSTATUS Status;
611
612 TRACE("LsaEnumerateTrustedDomains(%p %p %p %lu %p)\n",
613 PolicyHandle, EnumerationContext, Buffer,
614 PreferedMaximumLength, CountReturned);
615
616 if (Buffer == NULL)
617 return STATUS_INVALID_PARAMETER;
618
619 TrustedEnumBuffer.EntriesRead = 0;
620 TrustedEnumBuffer.Information = NULL;
621
622 RpcTryExcept
623 {
624 Status = LsarEnumerateTrustedDomains((LSAPR_HANDLE)PolicyHandle,
625 EnumerationContext,
626 &TrustedEnumBuffer,
627 PreferedMaximumLength);
628
629 *Buffer = TrustedEnumBuffer.Information;
630 *CountReturned = TrustedEnumBuffer.EntriesRead;
631
632 }
633 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
634 {
635 if (TrustedEnumBuffer.Information != NULL)
636 MIDL_user_free(TrustedEnumBuffer.Information);
637
638 Status = I_RpcMapWin32Status(RpcExceptionCode());
639 }
640 RpcEndExcept;
641
642 return Status;
643 }
644
645
646 /*
647 * @implemented
648 */
649 NTSTATUS
650 WINAPI
651 LsaEnumerateTrustedDomainsEx(IN LSA_HANDLE PolicyHandle,
652 IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
653 OUT PVOID *Buffer,
654 IN ULONG PreferedMaximumLength,
655 OUT PULONG CountReturned)
656 {
657 LSAPR_TRUSTED_ENUM_BUFFER_EX TrustedEnumBuffer;
658 NTSTATUS Status;
659
660 TRACE("LsaEnumerateTrustedDomainsEx(%p %p %p %lu %p)\n",
661 PolicyHandle, EnumerationContext, Buffer,
662 PreferedMaximumLength, CountReturned);
663
664 if (Buffer == NULL)
665 return STATUS_INVALID_PARAMETER;
666
667 TrustedEnumBuffer.EntriesRead = 0;
668 TrustedEnumBuffer.EnumerationBuffer = NULL;
669
670 RpcTryExcept
671 {
672 Status = LsarEnumerateTrustedDomainsEx((LSAPR_HANDLE)PolicyHandle,
673 EnumerationContext,
674 &TrustedEnumBuffer,
675 PreferedMaximumLength);
676
677 *Buffer = TrustedEnumBuffer.EnumerationBuffer;
678 *CountReturned = TrustedEnumBuffer.EntriesRead;
679
680 }
681 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
682 {
683 if (TrustedEnumBuffer.EnumerationBuffer != NULL)
684 MIDL_user_free(TrustedEnumBuffer.EnumerationBuffer);
685
686 Status = I_RpcMapWin32Status(RpcExceptionCode());
687 }
688 RpcEndExcept;
689
690 return Status;
691 }
692
693
694 /*
695 * @implemented
696 */
697 NTSTATUS
698 WINAPI
699 LsaFreeMemory(IN PVOID Buffer)
700 {
701 TRACE("LsaFreeMemory(%p)\n", Buffer);
702 return RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
703 }
704
705
706 /*
707 * @implemented
708 */
709 NTSTATUS
710 WINAPI
711 LsaGetQuotasForAccount(IN LSA_HANDLE AccountHandle,
712 OUT PQUOTA_LIMITS QuotaLimits)
713 {
714 NTSTATUS Status;
715
716 TRACE("LsaGetQuotasForAccount(%p %p)\n",
717 AccountHandle, QuotaLimits);
718
719 RpcTryExcept
720 {
721 Status = LsarGetQuotasForAccount((LSAPR_HANDLE)AccountHandle,
722 QuotaLimits);
723 }
724 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
725 {
726 Status = I_RpcMapWin32Status(RpcExceptionCode());
727 }
728 RpcEndExcept;
729
730 return Status;
731 }
732
733
734 /*
735 * @implemented
736 */
737 NTSTATUS
738 WINAPI
739 LsaGetRemoteUserName(IN PLSA_UNICODE_STRING SystemName OPTIONAL,
740 OUT PLSA_UNICODE_STRING *UserName,
741 OUT PLSA_UNICODE_STRING *DomainName OPTIONAL)
742 {
743 PRPC_UNICODE_STRING UserNameString = NULL;
744 PRPC_UNICODE_STRING DomainNameString = NULL;
745 NTSTATUS Status;
746
747 TRACE("LsaGetRemoteUserName(%s %p %p)\n",
748 SystemName ? debugstr_w(SystemName->Buffer) : "(null)",
749 UserName, DomainName);
750
751 RpcTryExcept
752 {
753 Status = LsarGetUserName((PLSAPR_SERVER_NAME)SystemName,
754 &UserNameString,
755 (DomainName != NULL) ? &DomainNameString : NULL);
756
757 *UserName = (PLSA_UNICODE_STRING)UserNameString;
758
759 if (DomainName != NULL)
760 *DomainName = (PLSA_UNICODE_STRING)DomainNameString;
761 }
762 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
763 {
764 if (UserNameString != NULL)
765 MIDL_user_free(UserNameString);
766
767 if (DomainNameString != NULL)
768 MIDL_user_free(DomainNameString);
769
770 Status = I_RpcMapWin32Status(RpcExceptionCode());
771 }
772 RpcEndExcept;
773
774 return Status;
775 }
776
777
778 /*
779 * @implemented
780 */
781 NTSTATUS
782 WINAPI
783 LsaGetSystemAccessAccount(IN LSA_HANDLE AccountHandle,
784 OUT PULONG SystemAccess)
785 {
786 NTSTATUS Status;
787
788 TRACE("LsaGetSystemAccessAccount(%p %p)\n",
789 AccountHandle, SystemAccess);
790
791 RpcTryExcept
792 {
793 Status = LsarGetSystemAccessAccount((LSAPR_HANDLE)AccountHandle,
794 (ACCESS_MASK *)SystemAccess);
795 }
796 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
797 {
798 Status = I_RpcMapWin32Status(RpcExceptionCode());
799 }
800 RpcEndExcept;
801
802 return Status;
803 }
804
805
806 /*
807 * @implemented
808 */
809 NTSTATUS
810 WINAPI
811 LsaGetUserName(OUT PUNICODE_STRING *UserName,
812 OUT PUNICODE_STRING *DomainName OPTIONAL)
813 {
814 PRPC_UNICODE_STRING UserNameString = NULL;
815 PRPC_UNICODE_STRING DomainNameString = NULL;
816 NTSTATUS Status;
817
818 TRACE("LsaGetUserName(%p %p)\n",
819 UserName, DomainName);
820
821 RpcTryExcept
822 {
823 Status = LsarGetUserName(NULL,
824 &UserNameString,
825 (DomainName != NULL) ? &DomainNameString : NULL);
826
827 *UserName = (PUNICODE_STRING)UserNameString;
828
829 if (DomainName != NULL)
830 *DomainName = (PUNICODE_STRING)DomainNameString;
831 }
832 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
833 {
834 if (UserNameString != NULL)
835 MIDL_user_free(UserNameString);
836
837 if (DomainNameString != NULL)
838 MIDL_user_free(DomainNameString);
839
840 Status = I_RpcMapWin32Status(RpcExceptionCode());
841 }
842 RpcEndExcept;
843
844 return Status;
845 }
846
847
848 /*
849 * @implemented
850 */
851 NTSTATUS
852 WINAPI
853 LsaLookupNames(IN LSA_HANDLE PolicyHandle,
854 IN ULONG Count,
855 IN PLSA_UNICODE_STRING Names,
856 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
857 OUT PLSA_TRANSLATED_SID *Sids)
858 {
859 LSAPR_TRANSLATED_SIDS TranslatedSids = {0, NULL};
860 ULONG MappedCount = 0;
861 NTSTATUS Status;
862
863 TRACE("LsaLookupNames(%p %lu %p %p %p)\n",
864 PolicyHandle, Count, Names, ReferencedDomains, Sids);
865
866 if (ReferencedDomains == NULL || Sids == NULL)
867 return STATUS_INVALID_PARAMETER;
868
869 RpcTryExcept
870 {
871 *ReferencedDomains = NULL;
872 *Sids = NULL;
873
874 TranslatedSids.Entries = Count;
875
876 Status = LsarLookupNames((LSAPR_HANDLE)PolicyHandle,
877 Count,
878 (PRPC_UNICODE_STRING)Names,
879 (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
880 &TranslatedSids,
881 LsapLookupWksta,
882 &MappedCount);
883
884 *Sids = (PLSA_TRANSLATED_SID)TranslatedSids.Sids;
885 }
886 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
887 {
888 if (TranslatedSids.Sids != NULL)
889 MIDL_user_free(TranslatedSids.Sids);
890
891 Status = I_RpcMapWin32Status(RpcExceptionCode());
892 }
893 RpcEndExcept;
894
895 return Status;
896 }
897
898
899 /*
900 * @implemented
901 */
902 NTSTATUS
903 WINAPI
904 LsaLookupNames2(IN LSA_HANDLE PolicyHandle,
905 IN ULONG Flags,
906 IN ULONG Count,
907 IN PLSA_UNICODE_STRING Names,
908 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
909 OUT PLSA_TRANSLATED_SID2 *Sids)
910 {
911 LSAPR_TRANSLATED_SIDS_EX2 TranslatedSids = {0, NULL};
912 ULONG MappedCount = 0;
913 NTSTATUS Status;
914
915 TRACE("LsaLookupNames2(%p 0x%08x %lu %p %p %p)\n",
916 PolicyHandle, Flags, Count, Names, ReferencedDomains, Sids);
917
918 if (ReferencedDomains == NULL || Sids == NULL)
919 return STATUS_INVALID_PARAMETER;
920
921 RpcTryExcept
922 {
923 *ReferencedDomains = NULL;
924 *Sids = NULL;
925
926 TranslatedSids.Entries = Count;
927
928 Status = LsarLookupNames3((LSAPR_HANDLE)PolicyHandle,
929 Count,
930 (PRPC_UNICODE_STRING)Names,
931 (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
932 &TranslatedSids,
933 LsapLookupWksta,
934 &MappedCount,
935 Flags,
936 2);
937
938 *Sids = (PLSA_TRANSLATED_SID2)TranslatedSids.Sids;
939 }
940 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
941 {
942 if (TranslatedSids.Sids != NULL)
943 MIDL_user_free(TranslatedSids.Sids);
944
945 Status = I_RpcMapWin32Status(RpcExceptionCode());
946 }
947 RpcEndExcept;
948
949 return Status;
950 }
951
952
953 /*
954 * @implemented
955 */
956 NTSTATUS
957 WINAPI
958 LsaLookupPrivilegeDisplayName(IN LSA_HANDLE PolicyHandle,
959 IN PLSA_UNICODE_STRING Name,
960 OUT PLSA_UNICODE_STRING *DisplayName,
961 OUT PUSHORT LanguageReturned)
962 {
963 PRPC_UNICODE_STRING DisplayNameBuffer = NULL;
964 NTSTATUS Status;
965
966 TRACE("LsaLookupPrivilegeDisplayName(%p %p %p %p)\n",
967 PolicyHandle, Name, DisplayName, LanguageReturned);
968
969 RpcTryExcept
970 {
971 Status = LsarLookupPrivilegeDisplayName(PolicyHandle,
972 (PRPC_UNICODE_STRING)Name,
973 GetUserDefaultUILanguage(),
974 GetSystemDefaultUILanguage(),
975 &DisplayNameBuffer,
976 LanguageReturned);
977
978 *DisplayName = (PUNICODE_STRING)DisplayNameBuffer;
979 }
980 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
981 {
982 if (DisplayNameBuffer != NULL)
983 MIDL_user_free(DisplayNameBuffer);
984
985 Status = I_RpcMapWin32Status(RpcExceptionCode());
986 }
987 RpcEndExcept;
988
989 return Status;
990 }
991
992
993 /*
994 * @implemented
995 */
996 NTSTATUS
997 WINAPI
998 LsaLookupPrivilegeName(IN LSA_HANDLE PolicyHandle,
999 IN PLUID Value,
1000 OUT PUNICODE_STRING *Name)
1001 {
1002 PRPC_UNICODE_STRING NameBuffer = NULL;
1003 NTSTATUS Status;
1004
1005 TRACE("LsaLookupPrivilegeName(%p %p %p)\n",
1006 PolicyHandle, Value, Name);
1007
1008 RpcTryExcept
1009 {
1010 Status = LsarLookupPrivilegeName(PolicyHandle,
1011 Value,
1012 &NameBuffer);
1013
1014 *Name = (PUNICODE_STRING)NameBuffer;
1015 }
1016 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1017 {
1018 if (NameBuffer != NULL)
1019 MIDL_user_free(NameBuffer);
1020
1021 Status = I_RpcMapWin32Status(RpcExceptionCode());
1022 }
1023 RpcEndExcept;
1024
1025 return Status;
1026 }
1027
1028
1029 /*
1030 * @implemented
1031 */
1032 NTSTATUS
1033 WINAPI
1034 LsaLookupPrivilegeValue(IN LSA_HANDLE PolicyHandle,
1035 IN PLSA_UNICODE_STRING Name,
1036 OUT PLUID Value)
1037 {
1038 LUID Luid;
1039 NTSTATUS Status;
1040
1041 TRACE("LsaLookupPrivilegeValue(%p %p %p)\n",
1042 PolicyHandle, Name, Value);
1043
1044 RpcTryExcept
1045 {
1046 Status = LsarLookupPrivilegeValue(PolicyHandle,
1047 (PRPC_UNICODE_STRING)Name,
1048 &Luid);
1049 if (Status == STATUS_SUCCESS)
1050 *Value = Luid;
1051 }
1052 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1053 {
1054 Status = I_RpcMapWin32Status(RpcExceptionCode());
1055 }
1056 RpcEndExcept;
1057
1058 return Status;
1059 }
1060
1061
1062 /*
1063 * @implemented
1064 */
1065 NTSTATUS
1066 WINAPI
1067 LsaLookupSids(IN LSA_HANDLE PolicyHandle,
1068 IN ULONG Count,
1069 IN PSID *Sids,
1070 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
1071 OUT PLSA_TRANSLATED_NAME *Names)
1072 {
1073 LSAPR_SID_ENUM_BUFFER SidEnumBuffer;
1074 LSAPR_TRANSLATED_NAMES TranslatedNames;
1075 ULONG MappedCount = 0;
1076 NTSTATUS Status;
1077
1078 TRACE("LsaLookupSids(%p %lu %p %p %p)\n",
1079 PolicyHandle, Count, Sids, ReferencedDomains, Names);
1080
1081 if (Count == 0)
1082 return STATUS_INVALID_PARAMETER;
1083
1084 SidEnumBuffer.Entries = Count;
1085 SidEnumBuffer.SidInfo = (PLSAPR_SID_INFORMATION)Sids;
1086
1087 RpcTryExcept
1088 {
1089 *ReferencedDomains = NULL;
1090 *Names = NULL;
1091
1092 TranslatedNames.Entries = 0;
1093 TranslatedNames.Names = NULL;
1094
1095 Status = LsarLookupSids((LSAPR_HANDLE)PolicyHandle,
1096 &SidEnumBuffer,
1097 (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
1098 &TranslatedNames,
1099 LsapLookupWksta,
1100 &MappedCount);
1101
1102 *Names = (PLSA_TRANSLATED_NAME)TranslatedNames.Names;
1103 }
1104 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1105 {
1106 if (TranslatedNames.Names != NULL)
1107 {
1108 MIDL_user_free(TranslatedNames.Names);
1109 }
1110
1111 Status = I_RpcMapWin32Status(RpcExceptionCode());
1112 }
1113 RpcEndExcept;
1114
1115 return Status;
1116 }
1117
1118
1119 /******************************************************************************
1120 * LsaNtStatusToWinError
1121 *
1122 * PARAMS
1123 * Status [I]
1124 *
1125 * @implemented
1126 */
1127 ULONG
1128 WINAPI
1129 LsaNtStatusToWinError(IN NTSTATUS Status)
1130 {
1131 TRACE("LsaNtStatusToWinError(0x%lx)\n", Status);
1132 return RtlNtStatusToDosError(Status);
1133 }
1134
1135
1136 /*
1137 * @implemented
1138 */
1139 NTSTATUS
1140 WINAPI
1141 LsaOpenAccount(IN LSA_HANDLE PolicyHandle,
1142 IN PSID AccountSid,
1143 IN ACCESS_MASK DesiredAccess,
1144 OUT PLSA_HANDLE AccountHandle)
1145 {
1146 NTSTATUS Status;
1147
1148 TRACE("LsaOpenAccount(%p %p 0x%08lx %p)\n",
1149 PolicyHandle, AccountSid, DesiredAccess, AccountHandle);
1150
1151 RpcTryExcept
1152 {
1153 Status = LsarOpenAccount((LSAPR_HANDLE)PolicyHandle,
1154 AccountSid,
1155 DesiredAccess,
1156 AccountHandle);
1157 }
1158 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1159 {
1160 Status = I_RpcMapWin32Status(RpcExceptionCode());
1161 }
1162 RpcEndExcept;
1163
1164 return Status;
1165 }
1166
1167
1168 /******************************************************************************
1169 * LsaOpenPolicy
1170 *
1171 * PARAMS
1172 * x1 []
1173 * x2 []
1174 * x3 []
1175 * x4 []
1176 *
1177 * @implemented
1178 */
1179 NTSTATUS
1180 WINAPI
1181 LsaOpenPolicy(IN PLSA_UNICODE_STRING SystemName OPTIONAL,
1182 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
1183 IN ACCESS_MASK DesiredAccess,
1184 OUT PLSA_HANDLE PolicyHandle)
1185 {
1186 NTSTATUS Status;
1187
1188 TRACE("LsaOpenPolicy(%s %p 0x%08lx %p)\n",
1189 SystemName ? debugstr_w(SystemName->Buffer) : "(null)",
1190 ObjectAttributes, DesiredAccess, PolicyHandle);
1191
1192 /* FIXME: RPC should take care of this */
1193 if (!LsapIsLocalComputer(SystemName))
1194 return RPC_NT_SERVER_UNAVAILABLE;
1195
1196 RpcTryExcept
1197 {
1198 *PolicyHandle = NULL;
1199
1200 Status = LsarOpenPolicy(SystemName ? SystemName->Buffer : NULL,
1201 (PLSAPR_OBJECT_ATTRIBUTES)ObjectAttributes,
1202 DesiredAccess,
1203 PolicyHandle);
1204 }
1205 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1206 {
1207 Status = I_RpcMapWin32Status(RpcExceptionCode());
1208 }
1209 RpcEndExcept;
1210
1211 TRACE("LsaOpenPolicy() done (Status: 0x%08lx)\n", Status);
1212
1213 return Status;
1214 }
1215
1216
1217 /*
1218 * @implemented
1219 */
1220 NTSTATUS
1221 WINAPI
1222 LsaOpenPolicySce(IN PLSA_UNICODE_STRING SystemName OPTIONAL,
1223 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
1224 IN ACCESS_MASK DesiredAccess,
1225 OUT PLSA_HANDLE PolicyHandle)
1226 {
1227 NTSTATUS Status;
1228
1229 TRACE("LsaOpenPolicySce(%s %p 0x%08lx %p)\n",
1230 SystemName ? debugstr_w(SystemName->Buffer) : "(null)",
1231 ObjectAttributes, DesiredAccess, PolicyHandle);
1232
1233 /* FIXME: RPC should take care of this */
1234 if (!LsapIsLocalComputer(SystemName))
1235 return RPC_NT_SERVER_UNAVAILABLE;
1236
1237 RpcTryExcept
1238 {
1239 *PolicyHandle = NULL;
1240
1241 Status = LsarOpenPolicySce(SystemName ? SystemName->Buffer : NULL,
1242 (PLSAPR_OBJECT_ATTRIBUTES)ObjectAttributes,
1243 DesiredAccess,
1244 PolicyHandle);
1245 }
1246 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1247 {
1248 Status = I_RpcMapWin32Status(RpcExceptionCode());
1249 }
1250 RpcEndExcept;
1251
1252 TRACE("LsaOpenPolicySce() done (Status: 0x%08lx)\n", Status);
1253
1254 return Status;
1255 }
1256
1257
1258 /*
1259 * @implemented
1260 */
1261 NTSTATUS
1262 WINAPI
1263 LsaOpenSecret(IN LSA_HANDLE PolicyHandle,
1264 IN PLSA_UNICODE_STRING SecretName,
1265 IN ACCESS_MASK DesiredAccess,
1266 OUT PLSA_HANDLE SecretHandle)
1267 {
1268 NTSTATUS Status;
1269
1270 TRACE("LsaOpenSecret(%p %p 0x%08lx %p)\n",
1271 PolicyHandle, SecretName, DesiredAccess, SecretHandle);
1272
1273 RpcTryExcept
1274 {
1275 *SecretHandle = NULL;
1276
1277 Status = LsarOpenSecret((LSAPR_HANDLE)PolicyHandle,
1278 (PRPC_UNICODE_STRING)SecretName,
1279 DesiredAccess,
1280 SecretHandle);
1281 }
1282 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1283 {
1284 Status = I_RpcMapWin32Status(RpcExceptionCode());
1285 }
1286 RpcEndExcept;
1287
1288 TRACE("LsaOpenSecret() done (Status: 0x%08lx)\n", Status);
1289
1290 return Status;
1291 }
1292
1293
1294 /*
1295 * @implemented
1296 */
1297 NTSTATUS
1298 WINAPI
1299 LsaOpenTrustedDomain(IN LSA_HANDLE PolicyHandle,
1300 IN PSID TrustedDomainSid,
1301 IN ACCESS_MASK DesiredAccess,
1302 OUT PLSA_HANDLE TrustedDomainHandle)
1303 {
1304 NTSTATUS Status;
1305
1306 TRACE("LsaOpenTrustedDomain(%p %p 0x%08lx %p)\n",
1307 PolicyHandle, TrustedDomainSid, DesiredAccess, TrustedDomainHandle);
1308
1309 RpcTryExcept
1310 {
1311 Status = LsarOpenTrustedDomain((LSAPR_HANDLE)PolicyHandle,
1312 (PRPC_SID)TrustedDomainSid,
1313 DesiredAccess,
1314 (PLSAPR_HANDLE)TrustedDomainHandle);
1315 }
1316 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1317 {
1318 Status = I_RpcMapWin32Status(RpcExceptionCode());
1319 }
1320 RpcEndExcept;
1321
1322 return Status;
1323 }
1324
1325
1326 /*
1327 * @implemented
1328 */
1329 NTSTATUS
1330 WINAPI
1331 LsaOpenTrustedDomainByName(IN LSA_HANDLE PolicyHandle,
1332 IN PLSA_UNICODE_STRING TrustedDomainName,
1333 IN ACCESS_MASK DesiredAccess,
1334 OUT PLSA_HANDLE TrustedDomainHandle)
1335 {
1336 NTSTATUS Status;
1337
1338 TRACE("LsaOpenTrustedDomainByName(%p %p 0x%08lx %p)\n",
1339 PolicyHandle, TrustedDomainName, DesiredAccess, TrustedDomainHandle);
1340
1341 RpcTryExcept
1342 {
1343 Status = LsarOpenTrustedDomainByName((LSAPR_HANDLE)PolicyHandle,
1344 (PRPC_UNICODE_STRING)TrustedDomainName,
1345 DesiredAccess,
1346 TrustedDomainHandle);
1347 }
1348 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1349 {
1350 Status = I_RpcMapWin32Status(RpcExceptionCode());
1351 }
1352 RpcEndExcept;
1353
1354 return Status;
1355 }
1356
1357
1358 /*
1359 * @implemented
1360 */
1361 NTSTATUS
1362 WINAPI
1363 LsaQueryDomainInformationPolicy(IN LSA_HANDLE PolicyHandle,
1364 IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
1365 OUT PVOID *Buffer)
1366 {
1367 PLSAPR_POLICY_DOMAIN_INFORMATION PolicyInformation = NULL;
1368 NTSTATUS Status;
1369
1370 TRACE("LsaQueryDomainInformationPolicy(%p %lu %p)\n",
1371 PolicyHandle, InformationClass, Buffer);
1372
1373 RpcTryExcept
1374 {
1375 Status = LsarQueryDomainInformationPolicy((LSAPR_HANDLE)PolicyHandle,
1376 InformationClass,
1377 &PolicyInformation);
1378
1379 *Buffer = PolicyInformation;
1380 }
1381 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1382 {
1383 if (PolicyInformation != NULL)
1384 MIDL_user_free(PolicyInformation);
1385
1386 Status = I_RpcMapWin32Status(RpcExceptionCode());
1387 }
1388 RpcEndExcept;
1389
1390 return Status;
1391 }
1392
1393
1394 /*
1395 * @implemented
1396 */
1397 NTSTATUS
1398 WINAPI
1399 LsaQueryForestTrustInformation(IN LSA_HANDLE PolicyHandle,
1400 IN PLSA_UNICODE_STRING TrustedDomainName,
1401 OUT PLSA_FOREST_TRUST_INFORMATION *ForestTrustInfo)
1402 {
1403 NTSTATUS Status;
1404
1405 TRACE("LsaQueryForestTrustInformation(%p %p %p)\n",
1406 PolicyHandle, TrustedDomainName, ForestTrustInfo);
1407
1408 RpcTryExcept
1409 {
1410 Status = LsarQueryForestTrustInformation((LSAPR_HANDLE)PolicyHandle,
1411 TrustedDomainName,
1412 ForestTrustDomainInfo,
1413 ForestTrustInfo);
1414 }
1415 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1416 {
1417 Status = I_RpcMapWin32Status(RpcExceptionCode());
1418 }
1419 RpcEndExcept;
1420
1421 return Status;
1422 }
1423
1424
1425 /*
1426 * @implemented
1427 */
1428 NTSTATUS
1429 WINAPI
1430 LsaQueryInfoTrustedDomain(IN LSA_HANDLE TrustedDomainHandle,
1431 IN TRUSTED_INFORMATION_CLASS InformationClass,
1432 OUT PVOID *Buffer)
1433 {
1434 PLSAPR_TRUSTED_DOMAIN_INFO TrustedDomainInformation = NULL;
1435 NTSTATUS Status;
1436
1437 TRACE("LsaQueryInfoTrustedDomain(%p %d %p) stub\n",
1438 TrustedDomainHandle, InformationClass, Buffer);
1439
1440 if (InformationClass == TrustedDomainAuthInformationInternal ||
1441 InformationClass == TrustedDomainFullInformationInternal)
1442 return STATUS_INVALID_INFO_CLASS;
1443
1444 RpcTryExcept
1445 {
1446 Status = LsarQueryInfoTrustedDomain((LSAPR_HANDLE)TrustedDomainHandle,
1447 InformationClass,
1448 &TrustedDomainInformation);
1449 *Buffer = TrustedDomainInformation;
1450 }
1451 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1452 {
1453 if (TrustedDomainInformation != NULL)
1454 MIDL_user_free(TrustedDomainInformation);
1455
1456 Status = I_RpcMapWin32Status(RpcExceptionCode());
1457 }
1458 RpcEndExcept;
1459
1460 TRACE("Done (Status: 0x%08x)\n", Status);
1461
1462 return Status;
1463 }
1464
1465
1466 /*
1467 * @implemented
1468 */
1469 NTSTATUS
1470 WINAPI
1471 LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle,
1472 IN POLICY_INFORMATION_CLASS InformationClass,
1473 OUT PVOID *Buffer)
1474 {
1475 PLSAPR_POLICY_INFORMATION PolicyInformation = NULL;
1476 NTSTATUS Status;
1477
1478 TRACE("LsaQueryInformationPolicy(%p %d %p)\n",
1479 PolicyHandle, InformationClass, Buffer);
1480
1481 RpcTryExcept
1482 {
1483 Status = LsarQueryInformationPolicy((LSAPR_HANDLE)PolicyHandle,
1484 InformationClass,
1485 &PolicyInformation);
1486 *Buffer = PolicyInformation;
1487 }
1488 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1489 {
1490 if (PolicyInformation != NULL)
1491 MIDL_user_free(PolicyInformation);
1492
1493 Status = I_RpcMapWin32Status(RpcExceptionCode());
1494 }
1495 RpcEndExcept;
1496
1497 TRACE("Done (Status: 0x%08x)\n", Status);
1498
1499 return Status;
1500 }
1501
1502
1503 /*
1504 * @implemented
1505 */
1506 NTSTATUS
1507 WINAPI
1508 LsaQuerySecret(IN LSA_HANDLE SecretHandle,
1509 OUT PLSA_UNICODE_STRING *CurrentValue OPTIONAL,
1510 OUT PLARGE_INTEGER CurrentValueSetTime OPTIONAL,
1511 OUT PLSA_UNICODE_STRING *OldValue OPTIONAL,
1512 OUT PLARGE_INTEGER OldValueSetTime OPTIONAL)
1513 {
1514 PLSAPR_CR_CIPHER_VALUE EncryptedCurrentValue = NULL;
1515 PLSAPR_CR_CIPHER_VALUE EncryptedOldValue = NULL;
1516 PLSA_UNICODE_STRING DecryptedCurrentValue = NULL;
1517 PLSA_UNICODE_STRING DecryptedOldValue = NULL;
1518 SIZE_T BufferSize;
1519 NTSTATUS Status;
1520
1521 TRACE("LsaQuerySecret(%p %p %p %p %p)\n",
1522 SecretHandle, CurrentValue, CurrentValueSetTime,
1523 OldValue, OldValueSetTime);
1524
1525 RpcTryExcept
1526 {
1527 Status = LsarQuerySecret((PLSAPR_HANDLE)SecretHandle,
1528 &EncryptedCurrentValue,
1529 CurrentValueSetTime,
1530 &EncryptedOldValue,
1531 OldValueSetTime);
1532 }
1533 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1534 {
1535 Status = I_RpcMapWin32Status(RpcExceptionCode());
1536 }
1537 RpcEndExcept;
1538
1539 if (!NT_SUCCESS(Status))
1540 goto done;
1541
1542 /* Decrypt the current value */
1543 if (CurrentValue != NULL)
1544 {
1545 if (EncryptedCurrentValue == NULL)
1546 {
1547 *CurrentValue = NULL;
1548 }
1549 else
1550 {
1551 /* FIXME: Decrypt the current value */
1552 BufferSize = sizeof(LSA_UNICODE_STRING) + EncryptedCurrentValue->MaximumLength;
1553 DecryptedCurrentValue = midl_user_allocate(BufferSize);
1554 if (DecryptedCurrentValue == NULL)
1555 {
1556 Status = STATUS_INSUFFICIENT_RESOURCES;
1557 goto done;
1558 }
1559
1560 DecryptedCurrentValue->Length = (USHORT)EncryptedCurrentValue->Length;
1561 DecryptedCurrentValue->MaximumLength = (USHORT)EncryptedCurrentValue->MaximumLength;
1562 DecryptedCurrentValue->Buffer = (PWSTR)(DecryptedCurrentValue + 1);
1563 RtlCopyMemory(DecryptedCurrentValue->Buffer,
1564 EncryptedCurrentValue->Buffer,
1565 EncryptedCurrentValue->Length);
1566
1567 *CurrentValue = DecryptedCurrentValue;
1568 }
1569 }
1570
1571 /* Decrypt the old value */
1572 if (OldValue != NULL)
1573 {
1574 if (EncryptedOldValue == NULL)
1575 {
1576 *OldValue = NULL;
1577 }
1578 else
1579 {
1580 /* FIXME: Decrypt the old value */
1581 BufferSize = sizeof(LSA_UNICODE_STRING) + EncryptedOldValue->MaximumLength;
1582 DecryptedOldValue = midl_user_allocate(BufferSize);
1583 if (DecryptedOldValue == NULL)
1584 {
1585 Status = STATUS_INSUFFICIENT_RESOURCES;
1586 goto done;
1587 }
1588
1589 DecryptedOldValue->Length = (USHORT)EncryptedOldValue->Length;
1590 DecryptedOldValue->MaximumLength = (USHORT)EncryptedOldValue->MaximumLength;
1591 DecryptedOldValue->Buffer = (PWSTR)(DecryptedOldValue + 1);
1592 RtlCopyMemory(DecryptedOldValue->Buffer,
1593 EncryptedOldValue->Buffer,
1594 EncryptedOldValue->Length);
1595
1596 *OldValue = DecryptedOldValue;
1597 }
1598 }
1599
1600 done:
1601 if (!NT_SUCCESS(Status))
1602 {
1603 if (DecryptedCurrentValue != NULL)
1604 midl_user_free(DecryptedCurrentValue);
1605
1606 if (DecryptedOldValue != NULL)
1607 midl_user_free(DecryptedOldValue);
1608
1609 if (CurrentValue != NULL)
1610 *CurrentValue = NULL;
1611
1612 if (OldValue != NULL)
1613 *OldValue = NULL;
1614 }
1615
1616 if (EncryptedCurrentValue != NULL)
1617 midl_user_free(EncryptedCurrentValue);
1618
1619 if (EncryptedOldValue != NULL)
1620 midl_user_free(EncryptedOldValue);
1621
1622 return Status;
1623 }
1624
1625
1626 /*
1627 * @implemented
1628 */
1629 NTSTATUS
1630 WINAPI
1631 LsaQuerySecurityObject(IN LSA_HANDLE ObjectHandle,
1632 IN SECURITY_INFORMATION SecurityInformation,
1633 OUT PSECURITY_DESCRIPTOR *SecurityDescriptor)
1634 {
1635 LSAPR_SR_SECURITY_DESCRIPTOR SdBuffer;
1636 PLSAPR_SR_SECURITY_DESCRIPTOR SdPointer;
1637 NTSTATUS Status;
1638
1639 TRACE("LsaQuerySecurityObject(%p %lx %p)\n",
1640 ObjectHandle, SecurityInformation, SecurityDescriptor);
1641
1642 SdBuffer.Length = 0;
1643 SdBuffer.SecurityDescriptor = NULL;
1644
1645 SdPointer = &SdBuffer;
1646
1647 RpcTryExcept
1648 {
1649 Status = LsarQuerySecurityObject((LSAPR_HANDLE)ObjectHandle,
1650 SecurityInformation,
1651 &SdPointer);
1652 if (NT_SUCCESS(Status))
1653 {
1654 *SecurityDescriptor = SdBuffer.SecurityDescriptor;
1655 }
1656 else
1657 {
1658 *SecurityDescriptor = NULL;
1659 }
1660 }
1661 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1662 {
1663 Status = I_RpcMapWin32Status(RpcExceptionCode());
1664 }
1665 RpcEndExcept;
1666
1667 return Status;
1668 }
1669
1670
1671 /*
1672 * @implemented
1673 */
1674 NTSTATUS
1675 WINAPI
1676 LsaQueryTrustedDomainInfo(IN LSA_HANDLE PolicyHandle,
1677 IN PSID TrustedDomainSid,
1678 IN TRUSTED_INFORMATION_CLASS InformationClass,
1679 OUT PVOID *Buffer)
1680 {
1681 NTSTATUS Status;
1682
1683 TRACE("LsaQueryTrustedDomainInfo(%p %p %d %p) stub\n",
1684 PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
1685
1686 if (InformationClass == TrustedDomainAuthInformationInternal ||
1687 InformationClass == TrustedDomainFullInformationInternal)
1688 return STATUS_INVALID_INFO_CLASS;
1689
1690 RpcTryExcept
1691 {
1692 Status = LsarQueryTrustedDomainInfo((LSAPR_HANDLE)PolicyHandle,
1693 (PRPC_SID)TrustedDomainSid,
1694 InformationClass,
1695 (PLSAPR_TRUSTED_DOMAIN_INFO *)Buffer);
1696 }
1697 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1698 {
1699 Status = I_RpcMapWin32Status(RpcExceptionCode());
1700 }
1701 RpcEndExcept;
1702
1703 return Status;
1704 }
1705
1706
1707 /*
1708 * @implemented
1709 */
1710 NTSTATUS
1711 WINAPI
1712 LsaQueryTrustedDomainInfoByName(IN LSA_HANDLE PolicyHandle,
1713 IN PLSA_UNICODE_STRING TrustedDomainName,
1714 IN TRUSTED_INFORMATION_CLASS InformationClass,
1715 OUT PVOID *Buffer)
1716 {
1717 NTSTATUS Status;
1718
1719 TRACE("LsaQueryTrustedDomainInfoByName(%p %p %d %p)\n",
1720 PolicyHandle, TrustedDomainName, InformationClass, Buffer);
1721
1722 if (InformationClass == TrustedDomainAuthInformationInternal ||
1723 InformationClass == TrustedDomainFullInformationInternal)
1724 return STATUS_INVALID_INFO_CLASS;
1725
1726 RpcTryExcept
1727 {
1728 Status = LsarQueryTrustedDomainInfoByName((LSAPR_HANDLE)PolicyHandle,
1729 (PRPC_UNICODE_STRING)TrustedDomainName,
1730 InformationClass,
1731 (PLSAPR_TRUSTED_DOMAIN_INFO *)Buffer);
1732 }
1733 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1734 {
1735 Status = I_RpcMapWin32Status(RpcExceptionCode());
1736 }
1737 RpcEndExcept;
1738
1739 return Status;
1740 }
1741
1742
1743 /*
1744 * @implemented
1745 */
1746 NTSTATUS
1747 WINAPI
1748 LsaRemoveAccountRights(IN LSA_HANDLE PolicyHandle,
1749 IN PSID AccountSid,
1750 IN BOOLEAN AllRights,
1751 IN PLSA_UNICODE_STRING UserRights,
1752 IN ULONG CountOfRights)
1753 {
1754 NTSTATUS Status;
1755 LSAPR_USER_RIGHT_SET UserRightSet;
1756
1757 TRACE("LsaRemoveAccountRights(%p %p %d %p %lu)\n",
1758 PolicyHandle, AccountSid, AllRights, UserRights, CountOfRights);
1759
1760 UserRightSet.Entries = CountOfRights;
1761 UserRightSet.UserRights = (PRPC_UNICODE_STRING)UserRights;
1762
1763 RpcTryExcept
1764 {
1765 Status = LsarRemoveAccountRights((LSAPR_HANDLE)PolicyHandle,
1766 (PRPC_SID)AccountSid,
1767 AllRights,
1768 &UserRightSet);
1769 }
1770 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1771 {
1772 Status = I_RpcMapWin32Status(RpcExceptionCode());
1773 }
1774 RpcEndExcept;
1775
1776 return Status;
1777 }
1778
1779
1780 /*
1781 * @implemented
1782 */
1783 NTSTATUS
1784 WINAPI
1785 LsaRemovePrivilegesFromAccount(IN LSA_HANDLE AccountHandle,
1786 IN BOOLEAN AllPrivileges,
1787 IN PPRIVILEGE_SET Privileges OPTIONAL)
1788 {
1789 NTSTATUS Status;
1790
1791 RpcTryExcept
1792 {
1793 Status = LsarRemovePrivilegesFromAccount((LSAPR_HANDLE)AccountHandle,
1794 AllPrivileges,
1795 (PLSAPR_PRIVILEGE_SET)Privileges);
1796 }
1797 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1798 {
1799 Status = I_RpcMapWin32Status(RpcExceptionCode());
1800 }
1801 RpcEndExcept;
1802
1803 return Status;
1804 }
1805
1806
1807 /*
1808 * @implemented
1809 */
1810 NTSTATUS
1811 WINAPI
1812 LsaRetrievePrivateData(IN LSA_HANDLE PolicyHandle,
1813 IN PLSA_UNICODE_STRING KeyName,
1814 OUT PLSA_UNICODE_STRING *PrivateData)
1815 {
1816 PLSAPR_CR_CIPHER_VALUE EncryptedData = NULL;
1817 PLSA_UNICODE_STRING DecryptedData = NULL;
1818 SIZE_T BufferSize;
1819 NTSTATUS Status;
1820
1821 TRACE("LsaRetrievePrivateData(%p %p %p)\n",
1822 PolicyHandle, KeyName, PrivateData);
1823
1824 RpcTryExcept
1825 {
1826 Status = LsarRetrievePrivateData((LSAPR_HANDLE)PolicyHandle,
1827 (PRPC_UNICODE_STRING)KeyName,
1828 &EncryptedData);
1829 }
1830 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1831 {
1832 Status = I_RpcMapWin32Status(RpcExceptionCode());
1833 }
1834 RpcEndExcept;
1835
1836 if (EncryptedData == NULL)
1837 {
1838 *PrivateData = NULL;
1839 }
1840 else
1841 {
1842 BufferSize = sizeof(LSA_UNICODE_STRING) + EncryptedData->MaximumLength;
1843 DecryptedData = midl_user_allocate(BufferSize);
1844 if (DecryptedData == NULL)
1845 {
1846 Status = STATUS_INSUFFICIENT_RESOURCES;
1847 goto done;
1848 }
1849
1850 DecryptedData->Length = (USHORT)EncryptedData->Length;
1851 DecryptedData->MaximumLength = (USHORT)EncryptedData->MaximumLength;
1852 DecryptedData->Buffer = (PWSTR)(DecryptedData + 1);
1853 RtlCopyMemory(DecryptedData->Buffer,
1854 EncryptedData->Buffer,
1855 EncryptedData->Length);
1856
1857 *PrivateData = DecryptedData;
1858 }
1859
1860 done:
1861 if (!NT_SUCCESS(Status))
1862 {
1863 if (DecryptedData != NULL)
1864 midl_user_free(DecryptedData);
1865
1866 *PrivateData = NULL;
1867 }
1868
1869 if (EncryptedData != NULL)
1870 midl_user_free(EncryptedData);
1871
1872 return Status;
1873 }
1874
1875
1876 /*
1877 * @implemented
1878 */
1879 NTSTATUS
1880 WINAPI
1881 LsaSetDomainInformationPolicy(IN LSA_HANDLE PolicyHandle,
1882 IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
1883 IN PVOID Buffer OPTIONAL)
1884 {
1885 NTSTATUS Status;
1886
1887 TRACE("LsaSetDomainInformationPolicy(%p %d %p)\n",
1888 PolicyHandle, InformationClass, Buffer);
1889
1890 RpcTryExcept
1891 {
1892 Status = LsarSetDomainInformationPolicy((LSAPR_HANDLE)PolicyHandle,
1893 InformationClass,
1894 (PLSAPR_POLICY_DOMAIN_INFORMATION)Buffer);
1895 }
1896 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1897 {
1898 Status = I_RpcMapWin32Status(RpcExceptionCode());
1899 }
1900 RpcEndExcept;
1901
1902 return Status;
1903 }
1904
1905
1906 /*
1907 * @implemented
1908 */
1909 NTSTATUS
1910 WINAPI
1911 LsaSetForestTrustInformation(IN LSA_HANDLE PolicyHandle,
1912 IN PLSA_UNICODE_STRING TrustedDomainName,
1913 IN PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo,
1914 IN BOOLEAN CheckOnly,
1915 OUT PLSA_FOREST_TRUST_COLLISION_INFORMATION *CollisionInfo)
1916 {
1917 NTSTATUS Status;
1918
1919 TRACE("LsaSetForestTrustInformation(%p %p %p %d %p)\n",
1920 PolicyHandle, TrustedDomainName, ForestTrustInfo, CheckOnly, CollisionInfo);
1921
1922 RpcTryExcept
1923 {
1924 Status = LsarSetForestTrustInformation((LSAPR_HANDLE)PolicyHandle,
1925 TrustedDomainName,
1926 ForestTrustDomainInfo,
1927 ForestTrustInfo,
1928 CheckOnly,
1929 CollisionInfo);
1930 }
1931 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1932 {
1933 Status = I_RpcMapWin32Status(RpcExceptionCode());
1934 }
1935 RpcEndExcept;
1936
1937 return Status;
1938 }
1939
1940
1941 /*
1942 * @implemented
1943 */
1944 NTSTATUS
1945 WINAPI
1946 LsaSetInformationPolicy(IN LSA_HANDLE PolicyHandle,
1947 IN POLICY_INFORMATION_CLASS InformationClass,
1948 IN PVOID Buffer)
1949 {
1950 NTSTATUS Status;
1951
1952 TRACE("LsaSetInformationPolicy(%p %d %p)\n",
1953 PolicyHandle, InformationClass, Buffer);
1954
1955 RpcTryExcept
1956 {
1957 Status = LsarSetInformationPolicy((LSAPR_HANDLE)PolicyHandle,
1958 InformationClass,
1959 (PLSAPR_POLICY_INFORMATION)Buffer);
1960 }
1961 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1962 {
1963 Status = I_RpcMapWin32Status(RpcExceptionCode());
1964 }
1965 RpcEndExcept;
1966
1967 return Status;
1968 }
1969
1970
1971 /*
1972 * @unimplemented
1973 */
1974 NTSTATUS
1975 WINAPI
1976 LsaSetInformationTrustedDomain(IN LSA_HANDLE TrustedDomainHandle,
1977 IN TRUSTED_INFORMATION_CLASS InformationClass,
1978 IN PVOID Buffer)
1979 {
1980 FIXME("LsaSetInformationTrustedDomain(%p %d %p)\n",
1981 TrustedDomainHandle, InformationClass, Buffer);
1982 return STATUS_NOT_IMPLEMENTED;
1983 }
1984
1985
1986 /*
1987 * @implemented
1988 */
1989 NTSTATUS
1990 WINAPI
1991 LsaSetQuotasForAccount(IN LSA_HANDLE AccountHandle,
1992 IN PQUOTA_LIMITS QuotaLimits)
1993 {
1994 NTSTATUS Status;
1995
1996 TRACE("LsaSetQuotasForAccount(%p %p)\n",
1997 AccountHandle, QuotaLimits);
1998
1999 RpcTryExcept
2000 {
2001 Status = LsarSetQuotasForAccount((LSAPR_HANDLE)AccountHandle,
2002 QuotaLimits);
2003 }
2004 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2005 {
2006 Status = I_RpcMapWin32Status(RpcExceptionCode());
2007 }
2008 RpcEndExcept;
2009
2010 return Status;
2011 }
2012
2013
2014 /*
2015 * @implemented
2016 */
2017 NTSTATUS
2018 WINAPI
2019 LsaSetSecret(IN LSA_HANDLE SecretHandle,
2020 IN PLSA_UNICODE_STRING CurrentValue OPTIONAL,
2021 IN PLSA_UNICODE_STRING OldValue OPTIONAL)
2022 {
2023 PLSAPR_CR_CIPHER_VALUE EncryptedCurrentValue = NULL;
2024 PLSAPR_CR_CIPHER_VALUE EncryptedOldValue = NULL;
2025 SIZE_T BufferSize;
2026 NTSTATUS Status;
2027
2028 TRACE("LsaSetSecret(%p %p %p)\n",
2029 SecretHandle, EncryptedCurrentValue, EncryptedOldValue);
2030
2031 if (CurrentValue != NULL)
2032 {
2033 BufferSize = sizeof(LSAPR_CR_CIPHER_VALUE) + CurrentValue->MaximumLength;
2034 EncryptedCurrentValue = midl_user_allocate(BufferSize);
2035 if (EncryptedCurrentValue == NULL)
2036 {
2037 Status = STATUS_INSUFFICIENT_RESOURCES;
2038 goto done;
2039 }
2040
2041 EncryptedCurrentValue->Length = CurrentValue->Length;
2042 EncryptedCurrentValue->MaximumLength = CurrentValue->MaximumLength;
2043 EncryptedCurrentValue->Buffer = (BYTE *)(EncryptedCurrentValue + 1);
2044 if (EncryptedCurrentValue->Buffer != NULL)
2045 memcpy(EncryptedCurrentValue->Buffer, CurrentValue->Buffer, CurrentValue->Length);
2046 }
2047
2048 if (OldValue != NULL)
2049 {
2050 BufferSize = sizeof(LSAPR_CR_CIPHER_VALUE) + OldValue->MaximumLength;
2051 EncryptedOldValue = midl_user_allocate(BufferSize);
2052 if (EncryptedOldValue == NULL)
2053 {
2054 Status = STATUS_INSUFFICIENT_RESOURCES;
2055 goto done;
2056 }
2057
2058 EncryptedOldValue->Length = OldValue->Length;
2059 EncryptedOldValue->MaximumLength = OldValue->MaximumLength;
2060 EncryptedOldValue->Buffer = (BYTE*)(EncryptedOldValue + 1);
2061 if (EncryptedOldValue->Buffer != NULL)
2062 memcpy(EncryptedOldValue->Buffer, OldValue->Buffer, OldValue->Length);
2063 }
2064
2065 RpcTryExcept
2066 {
2067 Status = LsarSetSecret((LSAPR_HANDLE)SecretHandle,
2068 EncryptedCurrentValue,
2069 EncryptedOldValue);
2070 }
2071 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2072 {
2073 Status = I_RpcMapWin32Status(RpcExceptionCode());
2074 }
2075 RpcEndExcept;
2076
2077 done:
2078 if (EncryptedCurrentValue != NULL)
2079 midl_user_free(EncryptedCurrentValue);
2080
2081 if (EncryptedOldValue != NULL)
2082 midl_user_free(EncryptedOldValue);
2083
2084 return Status;
2085 }
2086
2087
2088 /*
2089 * @implemented
2090 */
2091 NTSTATUS
2092 WINAPI
2093 LsaSetSecurityObject(IN LSA_HANDLE ObjectHandle,
2094 IN SECURITY_INFORMATION SecurityInformation,
2095 IN PSECURITY_DESCRIPTOR SecurityDescriptor)
2096 {
2097 LSAPR_SR_SECURITY_DESCRIPTOR SdBuffer = {0, NULL};
2098 ULONG SdLength = 0;
2099 NTSTATUS Status;
2100
2101 TRACE("LsaSetSecurityObject(%p %lx %p)\n",
2102 ObjectHandle, SecurityInformation, SecurityDescriptor);
2103
2104 Status = RtlMakeSelfRelativeSD(SecurityDescriptor,
2105 NULL,
2106 &SdLength);
2107 if (Status != STATUS_BUFFER_TOO_SMALL)
2108 return STATUS_INVALID_PARAMETER;
2109
2110 SdBuffer.SecurityDescriptor = MIDL_user_allocate(SdLength);
2111 if (SdBuffer.SecurityDescriptor == NULL)
2112 return STATUS_INSUFFICIENT_RESOURCES;
2113
2114 Status = RtlMakeSelfRelativeSD(SecurityDescriptor,
2115 (PSECURITY_DESCRIPTOR)SdBuffer.SecurityDescriptor,
2116 &SdLength);
2117 if (!NT_SUCCESS(Status))
2118 goto done;
2119
2120 SdBuffer.Length = SdLength;
2121
2122 RpcTryExcept
2123 {
2124 Status = LsarSetSecurityObject((LSAPR_HANDLE)ObjectHandle,
2125 SecurityInformation,
2126 &SdBuffer);
2127 }
2128 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2129 {
2130 Status = I_RpcMapWin32Status(RpcExceptionCode());
2131 }
2132 RpcEndExcept;
2133
2134 done:
2135 if (SdBuffer.SecurityDescriptor != NULL)
2136 MIDL_user_free(SdBuffer.SecurityDescriptor);
2137
2138 return Status;
2139 }
2140
2141
2142 /*
2143 * @implemented
2144 */
2145 NTSTATUS
2146 WINAPI
2147 LsaSetSystemAccessAccount(IN LSA_HANDLE AccountHandle,
2148 IN ULONG SystemAccess)
2149 {
2150 NTSTATUS Status;
2151
2152 TRACE("LsaSetSystemAccessAccount(%p 0x%lx)\n",
2153 AccountHandle, SystemAccess);
2154
2155 RpcTryExcept
2156 {
2157 Status = LsarSetSystemAccessAccount((LSAPR_HANDLE)AccountHandle,
2158 SystemAccess);
2159 }
2160 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2161 {
2162 Status = I_RpcMapWin32Status(RpcExceptionCode());
2163 }
2164 RpcEndExcept;
2165
2166 return Status;
2167 }
2168
2169
2170 /*
2171 * @unimplemented
2172 */
2173 NTSTATUS
2174 WINAPI
2175 LsaSetTrustedDomainInfoByName(IN LSA_HANDLE PolicyHandle,
2176 IN PLSA_UNICODE_STRING TrustedDomainName,
2177 IN TRUSTED_INFORMATION_CLASS InformationClass,
2178 IN PVOID Buffer)
2179 {
2180 FIXME("LsaSetTrustedDomainInfoByName(%p %p %d %p) stub\n",
2181 PolicyHandle, TrustedDomainName, InformationClass, Buffer);
2182 return STATUS_SUCCESS;
2183 }
2184
2185
2186 /*
2187 * @unimplemented
2188 */
2189 NTSTATUS
2190 WINAPI
2191 LsaSetTrustedDomainInformation(IN LSA_HANDLE PolicyHandle,
2192 IN PSID TrustedDomainSid,
2193 IN TRUSTED_INFORMATION_CLASS InformationClass,
2194 IN PVOID Buffer)
2195 {
2196 FIXME("LsaSetTrustedDomainInformation(%p %p %d %p) stub\n",
2197 PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
2198 return STATUS_SUCCESS;
2199 }
2200
2201
2202 /*
2203 * @implemented
2204 */
2205 NTSTATUS
2206 WINAPI
2207 LsaStorePrivateData(IN LSA_HANDLE PolicyHandle,
2208 IN PLSA_UNICODE_STRING KeyName,
2209 IN PLSA_UNICODE_STRING PrivateData OPTIONAL)
2210 {
2211 PLSAPR_CR_CIPHER_VALUE EncryptedData = NULL;
2212 SIZE_T BufferSize;
2213 NTSTATUS Status;
2214
2215 TRACE("LsaStorePrivateData(%p %p %p)\n",
2216 PolicyHandle, KeyName, PrivateData);
2217
2218 if (PrivateData != NULL)
2219 {
2220 BufferSize = sizeof(LSAPR_CR_CIPHER_VALUE) + PrivateData->MaximumLength;
2221 EncryptedData = midl_user_allocate(BufferSize);
2222 if (EncryptedData == NULL)
2223 {
2224 Status = STATUS_INSUFFICIENT_RESOURCES;
2225 goto done;
2226 }
2227
2228 EncryptedData->Length = PrivateData->Length;
2229 EncryptedData->MaximumLength = PrivateData->MaximumLength;
2230 EncryptedData->Buffer = (BYTE *)(EncryptedData + 1);
2231 if (EncryptedData->Buffer != NULL)
2232 RtlCopyMemory(EncryptedData->Buffer,
2233 PrivateData->Buffer,
2234 PrivateData->Length);
2235 }
2236
2237 RpcTryExcept
2238 {
2239 Status = LsarStorePrivateData((LSAPR_HANDLE)PolicyHandle,
2240 (PRPC_UNICODE_STRING)KeyName,
2241 EncryptedData);
2242 }
2243 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2244 {
2245 Status = I_RpcMapWin32Status(RpcExceptionCode());
2246 }
2247 RpcEndExcept;
2248
2249 done:
2250 if (EncryptedData != NULL)
2251 midl_user_free(EncryptedData);
2252
2253 return Status;
2254 }
2255
2256 /* EOF */