2c8de6087efcdb1746f246283a09828fc3648b21
[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 * @unimplemented
1427 */
1428 NTSTATUS
1429 WINAPI
1430 LsaQueryInfoTrustedDomain(IN LSA_HANDLE TrustedDomainHandle,
1431 IN TRUSTED_INFORMATION_CLASS InformationClass,
1432 OUT PVOID *Buffer)
1433 {
1434 FIXME("LsaQueryInfoTrustedDomain(%p %d %p) stub\n",
1435 TrustedDomainHandle, InformationClass, Buffer);
1436 return STATUS_NOT_IMPLEMENTED;
1437 }
1438
1439
1440 /*
1441 * @implemented
1442 */
1443 NTSTATUS
1444 WINAPI
1445 LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle,
1446 IN POLICY_INFORMATION_CLASS InformationClass,
1447 OUT PVOID *Buffer)
1448 {
1449 PLSAPR_POLICY_INFORMATION PolicyInformation = NULL;
1450 NTSTATUS Status;
1451
1452 TRACE("LsaQueryInformationPolicy(%p %d %p)\n",
1453 PolicyHandle, InformationClass, Buffer);
1454
1455 RpcTryExcept
1456 {
1457 Status = LsarQueryInformationPolicy((LSAPR_HANDLE)PolicyHandle,
1458 InformationClass,
1459 &PolicyInformation);
1460 *Buffer = PolicyInformation;
1461 }
1462 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1463 {
1464 if (PolicyInformation != NULL)
1465 MIDL_user_free(PolicyInformation);
1466
1467 Status = I_RpcMapWin32Status(RpcExceptionCode());
1468 }
1469 RpcEndExcept;
1470
1471 TRACE("Done (Status: 0x%08x)\n", Status);
1472
1473 return Status;
1474 }
1475
1476
1477 /*
1478 * @implemented
1479 */
1480 NTSTATUS
1481 WINAPI
1482 LsaQuerySecret(IN LSA_HANDLE SecretHandle,
1483 OUT PLSA_UNICODE_STRING *CurrentValue OPTIONAL,
1484 OUT PLARGE_INTEGER CurrentValueSetTime OPTIONAL,
1485 OUT PLSA_UNICODE_STRING *OldValue OPTIONAL,
1486 OUT PLARGE_INTEGER OldValueSetTime OPTIONAL)
1487 {
1488 PLSAPR_CR_CIPHER_VALUE EncryptedCurrentValue = NULL;
1489 PLSAPR_CR_CIPHER_VALUE EncryptedOldValue = NULL;
1490 PLSA_UNICODE_STRING DecryptedCurrentValue = NULL;
1491 PLSA_UNICODE_STRING DecryptedOldValue = NULL;
1492 SIZE_T BufferSize;
1493 NTSTATUS Status;
1494
1495 TRACE("LsaQuerySecret(%p %p %p %p %p)\n",
1496 SecretHandle, CurrentValue, CurrentValueSetTime,
1497 OldValue, OldValueSetTime);
1498
1499 RpcTryExcept
1500 {
1501 Status = LsarQuerySecret((PLSAPR_HANDLE)SecretHandle,
1502 &EncryptedCurrentValue,
1503 CurrentValueSetTime,
1504 &EncryptedOldValue,
1505 OldValueSetTime);
1506 }
1507 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1508 {
1509 Status = I_RpcMapWin32Status(RpcExceptionCode());
1510 }
1511 RpcEndExcept;
1512
1513 if (!NT_SUCCESS(Status))
1514 goto done;
1515
1516 /* Decrypt the current value */
1517 if (CurrentValue != NULL)
1518 {
1519 if (EncryptedCurrentValue == NULL)
1520 {
1521 *CurrentValue = NULL;
1522 }
1523 else
1524 {
1525 /* FIXME: Decrypt the current value */
1526 BufferSize = sizeof(LSA_UNICODE_STRING) + EncryptedCurrentValue->MaximumLength;
1527 DecryptedCurrentValue = midl_user_allocate(BufferSize);
1528 if (DecryptedCurrentValue == NULL)
1529 {
1530 Status = STATUS_INSUFFICIENT_RESOURCES;
1531 goto done;
1532 }
1533
1534 DecryptedCurrentValue->Length = (USHORT)EncryptedCurrentValue->Length;
1535 DecryptedCurrentValue->MaximumLength = (USHORT)EncryptedCurrentValue->MaximumLength;
1536 DecryptedCurrentValue->Buffer = (PWSTR)(DecryptedCurrentValue + 1);
1537 RtlCopyMemory(DecryptedCurrentValue->Buffer,
1538 EncryptedCurrentValue->Buffer,
1539 EncryptedCurrentValue->Length);
1540
1541 *CurrentValue = DecryptedCurrentValue;
1542 }
1543 }
1544
1545 /* Decrypt the old value */
1546 if (OldValue != NULL)
1547 {
1548 if (EncryptedOldValue == NULL)
1549 {
1550 *OldValue = NULL;
1551 }
1552 else
1553 {
1554 /* FIXME: Decrypt the old value */
1555 BufferSize = sizeof(LSA_UNICODE_STRING) + EncryptedOldValue->MaximumLength;
1556 DecryptedOldValue = midl_user_allocate(BufferSize);
1557 if (DecryptedOldValue == NULL)
1558 {
1559 Status = STATUS_INSUFFICIENT_RESOURCES;
1560 goto done;
1561 }
1562
1563 DecryptedOldValue->Length = (USHORT)EncryptedOldValue->Length;
1564 DecryptedOldValue->MaximumLength = (USHORT)EncryptedOldValue->MaximumLength;
1565 DecryptedOldValue->Buffer = (PWSTR)(DecryptedOldValue + 1);
1566 RtlCopyMemory(DecryptedOldValue->Buffer,
1567 EncryptedOldValue->Buffer,
1568 EncryptedOldValue->Length);
1569
1570 *OldValue = DecryptedOldValue;
1571 }
1572 }
1573
1574 done:
1575 if (!NT_SUCCESS(Status))
1576 {
1577 if (DecryptedCurrentValue != NULL)
1578 midl_user_free(DecryptedCurrentValue);
1579
1580 if (DecryptedOldValue != NULL)
1581 midl_user_free(DecryptedOldValue);
1582
1583 if (CurrentValue != NULL)
1584 *CurrentValue = NULL;
1585
1586 if (OldValue != NULL)
1587 *OldValue = NULL;
1588 }
1589
1590 if (EncryptedCurrentValue != NULL)
1591 midl_user_free(EncryptedCurrentValue);
1592
1593 if (EncryptedOldValue != NULL)
1594 midl_user_free(EncryptedOldValue);
1595
1596 return Status;
1597 }
1598
1599
1600 /*
1601 * @implemented
1602 */
1603 NTSTATUS
1604 WINAPI
1605 LsaQuerySecurityObject(IN LSA_HANDLE ObjectHandle,
1606 IN SECURITY_INFORMATION SecurityInformation,
1607 OUT PSECURITY_DESCRIPTOR *SecurityDescriptor)
1608 {
1609 LSAPR_SR_SECURITY_DESCRIPTOR SdBuffer;
1610 PLSAPR_SR_SECURITY_DESCRIPTOR SdPointer;
1611 NTSTATUS Status;
1612
1613 TRACE("LsaQuerySecurityObject(%p %lx %p)\n",
1614 ObjectHandle, SecurityInformation, SecurityDescriptor);
1615
1616 SdBuffer.Length = 0;
1617 SdBuffer.SecurityDescriptor = NULL;
1618
1619 SdPointer = &SdBuffer;
1620
1621 RpcTryExcept
1622 {
1623 Status = LsarQuerySecurityObject((LSAPR_HANDLE)ObjectHandle,
1624 SecurityInformation,
1625 &SdPointer);
1626 if (NT_SUCCESS(Status))
1627 {
1628 *SecurityDescriptor = SdBuffer.SecurityDescriptor;
1629 }
1630 else
1631 {
1632 *SecurityDescriptor = NULL;
1633 }
1634 }
1635 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1636 {
1637 Status = I_RpcMapWin32Status(RpcExceptionCode());
1638 }
1639 RpcEndExcept;
1640
1641 return Status;
1642 }
1643
1644
1645 /*
1646 * @unimplemented
1647 */
1648 NTSTATUS
1649 WINAPI
1650 LsaQueryTrustedDomainInfo(IN LSA_HANDLE PolicyHandle,
1651 IN PSID TrustedDomainSid,
1652 IN TRUSTED_INFORMATION_CLASS InformationClass,
1653 OUT PVOID *Buffer)
1654 {
1655 FIXME("LsaQueryTrustedDomainInfo(%p %p %d %p) stub\n",
1656 PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
1657 return STATUS_OBJECT_NAME_NOT_FOUND;
1658 }
1659
1660
1661 /*
1662 * @implemented
1663 */
1664 NTSTATUS
1665 WINAPI
1666 LsaQueryTrustedDomainInfoByName(IN LSA_HANDLE PolicyHandle,
1667 IN PLSA_UNICODE_STRING TrustedDomainName,
1668 IN TRUSTED_INFORMATION_CLASS InformationClass,
1669 OUT PVOID *Buffer)
1670 {
1671 NTSTATUS Status;
1672
1673 TRACE("LsaQueryTrustedDomainInfoByName(%p %p %d %p)\n",
1674 PolicyHandle, TrustedDomainName, InformationClass, Buffer);
1675
1676 if (InformationClass == TrustedDomainAuthInformationInternal ||
1677 InformationClass == TrustedDomainFullInformationInternal)
1678 return STATUS_INVALID_INFO_CLASS;
1679
1680 RpcTryExcept
1681 {
1682 Status = LsarQueryTrustedDomainInfoByName((LSAPR_HANDLE)PolicyHandle,
1683 (PRPC_UNICODE_STRING)TrustedDomainName,
1684 InformationClass,
1685 (PLSAPR_TRUSTED_DOMAIN_INFO *)Buffer);
1686 }
1687 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1688 {
1689 Status = I_RpcMapWin32Status(RpcExceptionCode());
1690 }
1691 RpcEndExcept;
1692
1693 return Status;
1694 }
1695
1696
1697 /*
1698 * @implemented
1699 */
1700 NTSTATUS
1701 WINAPI
1702 LsaRemoveAccountRights(IN LSA_HANDLE PolicyHandle,
1703 IN PSID AccountSid,
1704 IN BOOLEAN AllRights,
1705 IN PLSA_UNICODE_STRING UserRights,
1706 IN ULONG CountOfRights)
1707 {
1708 NTSTATUS Status;
1709 LSAPR_USER_RIGHT_SET UserRightSet;
1710
1711 TRACE("LsaRemoveAccountRights(%p %p %d %p %lu)\n",
1712 PolicyHandle, AccountSid, AllRights, UserRights, CountOfRights);
1713
1714 UserRightSet.Entries = CountOfRights;
1715 UserRightSet.UserRights = (PRPC_UNICODE_STRING)UserRights;
1716
1717 RpcTryExcept
1718 {
1719 Status = LsarRemoveAccountRights((LSAPR_HANDLE)PolicyHandle,
1720 (PRPC_SID)AccountSid,
1721 AllRights,
1722 &UserRightSet);
1723 }
1724 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1725 {
1726 Status = I_RpcMapWin32Status(RpcExceptionCode());
1727 }
1728 RpcEndExcept;
1729
1730 return Status;
1731 }
1732
1733
1734 /*
1735 * @implemented
1736 */
1737 NTSTATUS
1738 WINAPI
1739 LsaRemovePrivilegesFromAccount(IN LSA_HANDLE AccountHandle,
1740 IN BOOLEAN AllPrivileges,
1741 IN PPRIVILEGE_SET Privileges OPTIONAL)
1742 {
1743 NTSTATUS Status;
1744
1745 RpcTryExcept
1746 {
1747 Status = LsarRemovePrivilegesFromAccount((LSAPR_HANDLE)AccountHandle,
1748 AllPrivileges,
1749 (PLSAPR_PRIVILEGE_SET)Privileges);
1750 }
1751 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1752 {
1753 Status = I_RpcMapWin32Status(RpcExceptionCode());
1754 }
1755 RpcEndExcept;
1756
1757 return Status;
1758 }
1759
1760
1761 /*
1762 * @implemented
1763 */
1764 NTSTATUS
1765 WINAPI
1766 LsaRetrievePrivateData(IN LSA_HANDLE PolicyHandle,
1767 IN PLSA_UNICODE_STRING KeyName,
1768 OUT PLSA_UNICODE_STRING *PrivateData)
1769 {
1770 PLSAPR_CR_CIPHER_VALUE EncryptedData = NULL;
1771 PLSA_UNICODE_STRING DecryptedData = NULL;
1772 SIZE_T BufferSize;
1773 NTSTATUS Status;
1774
1775 TRACE("LsaRetrievePrivateData(%p %p %p)\n",
1776 PolicyHandle, KeyName, PrivateData);
1777
1778 RpcTryExcept
1779 {
1780 Status = LsarRetrievePrivateData((LSAPR_HANDLE)PolicyHandle,
1781 (PRPC_UNICODE_STRING)KeyName,
1782 &EncryptedData);
1783 }
1784 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1785 {
1786 Status = I_RpcMapWin32Status(RpcExceptionCode());
1787 }
1788 RpcEndExcept;
1789
1790 if (EncryptedData == NULL)
1791 {
1792 *PrivateData = NULL;
1793 }
1794 else
1795 {
1796 BufferSize = sizeof(LSA_UNICODE_STRING) + EncryptedData->MaximumLength;
1797 DecryptedData = midl_user_allocate(BufferSize);
1798 if (DecryptedData == NULL)
1799 {
1800 Status = STATUS_INSUFFICIENT_RESOURCES;
1801 goto done;
1802 }
1803
1804 DecryptedData->Length = (USHORT)EncryptedData->Length;
1805 DecryptedData->MaximumLength = (USHORT)EncryptedData->MaximumLength;
1806 DecryptedData->Buffer = (PWSTR)(DecryptedData + 1);
1807 RtlCopyMemory(DecryptedData->Buffer,
1808 EncryptedData->Buffer,
1809 EncryptedData->Length);
1810
1811 *PrivateData = DecryptedData;
1812 }
1813
1814 done:
1815 if (!NT_SUCCESS(Status))
1816 {
1817 if (DecryptedData != NULL)
1818 midl_user_free(DecryptedData);
1819
1820 *PrivateData = NULL;
1821 }
1822
1823 if (EncryptedData != NULL)
1824 midl_user_free(EncryptedData);
1825
1826 return Status;
1827 }
1828
1829
1830 /*
1831 * @implemented
1832 */
1833 NTSTATUS
1834 WINAPI
1835 LsaSetDomainInformationPolicy(IN LSA_HANDLE PolicyHandle,
1836 IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
1837 IN PVOID Buffer OPTIONAL)
1838 {
1839 NTSTATUS Status;
1840
1841 TRACE("LsaSetDomainInformationPolicy(%p %d %p)\n",
1842 PolicyHandle, InformationClass, Buffer);
1843
1844 RpcTryExcept
1845 {
1846 Status = LsarSetDomainInformationPolicy((LSAPR_HANDLE)PolicyHandle,
1847 InformationClass,
1848 (PLSAPR_POLICY_DOMAIN_INFORMATION)Buffer);
1849 }
1850 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1851 {
1852 Status = I_RpcMapWin32Status(RpcExceptionCode());
1853 }
1854 RpcEndExcept;
1855
1856 return Status;
1857 }
1858
1859
1860 /*
1861 * @implemented
1862 */
1863 NTSTATUS
1864 WINAPI
1865 LsaSetForestTrustInformation(IN LSA_HANDLE PolicyHandle,
1866 IN PLSA_UNICODE_STRING TrustedDomainName,
1867 IN PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo,
1868 IN BOOLEAN CheckOnly,
1869 OUT PLSA_FOREST_TRUST_COLLISION_INFORMATION *CollisionInfo)
1870 {
1871 NTSTATUS Status;
1872
1873 TRACE("LsaSetForestTrustInformation(%p %p %p %d %p)\n",
1874 PolicyHandle, TrustedDomainName, ForestTrustInfo, CheckOnly, CollisionInfo);
1875
1876 RpcTryExcept
1877 {
1878 Status = LsarSetForestTrustInformation((LSAPR_HANDLE)PolicyHandle,
1879 TrustedDomainName,
1880 ForestTrustDomainInfo,
1881 ForestTrustInfo,
1882 CheckOnly,
1883 CollisionInfo);
1884 }
1885 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1886 {
1887 Status = I_RpcMapWin32Status(RpcExceptionCode());
1888 }
1889 RpcEndExcept;
1890
1891 return Status;
1892 }
1893
1894
1895 /*
1896 * @implemented
1897 */
1898 NTSTATUS
1899 WINAPI
1900 LsaSetInformationPolicy(IN LSA_HANDLE PolicyHandle,
1901 IN POLICY_INFORMATION_CLASS InformationClass,
1902 IN PVOID Buffer)
1903 {
1904 NTSTATUS Status;
1905
1906 TRACE("LsaSetInformationPolicy(%p %d %p)\n",
1907 PolicyHandle, InformationClass, Buffer);
1908
1909 RpcTryExcept
1910 {
1911 Status = LsarSetInformationPolicy((LSAPR_HANDLE)PolicyHandle,
1912 InformationClass,
1913 (PLSAPR_POLICY_INFORMATION)Buffer);
1914 }
1915 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1916 {
1917 Status = I_RpcMapWin32Status(RpcExceptionCode());
1918 }
1919 RpcEndExcept;
1920
1921 return Status;
1922 }
1923
1924
1925 /*
1926 * @unimplemented
1927 */
1928 NTSTATUS
1929 WINAPI
1930 LsaSetInformationTrustedDomain(IN LSA_HANDLE TrustedDomainHandle,
1931 IN TRUSTED_INFORMATION_CLASS InformationClass,
1932 IN PVOID Buffer)
1933 {
1934 FIXME("LsaSetInformationTrustedDomain(%p %d %p)\n",
1935 TrustedDomainHandle, InformationClass, Buffer);
1936 return STATUS_NOT_IMPLEMENTED;
1937 }
1938
1939
1940 /*
1941 * @implemented
1942 */
1943 NTSTATUS
1944 WINAPI
1945 LsaSetQuotasForAccount(IN LSA_HANDLE AccountHandle,
1946 IN PQUOTA_LIMITS QuotaLimits)
1947 {
1948 NTSTATUS Status;
1949
1950 TRACE("LsaSetQuotasForAccount(%p %p)\n",
1951 AccountHandle, QuotaLimits);
1952
1953 RpcTryExcept
1954 {
1955 Status = LsarSetQuotasForAccount((LSAPR_HANDLE)AccountHandle,
1956 QuotaLimits);
1957 }
1958 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1959 {
1960 Status = I_RpcMapWin32Status(RpcExceptionCode());
1961 }
1962 RpcEndExcept;
1963
1964 return Status;
1965 }
1966
1967
1968 /*
1969 * @implemented
1970 */
1971 NTSTATUS
1972 WINAPI
1973 LsaSetSecret(IN LSA_HANDLE SecretHandle,
1974 IN PLSA_UNICODE_STRING CurrentValue OPTIONAL,
1975 IN PLSA_UNICODE_STRING OldValue OPTIONAL)
1976 {
1977 PLSAPR_CR_CIPHER_VALUE EncryptedCurrentValue = NULL;
1978 PLSAPR_CR_CIPHER_VALUE EncryptedOldValue = NULL;
1979 SIZE_T BufferSize;
1980 NTSTATUS Status;
1981
1982 TRACE("LsaSetSecret(%p %p %p)\n",
1983 SecretHandle, EncryptedCurrentValue, EncryptedOldValue);
1984
1985 if (CurrentValue != NULL)
1986 {
1987 BufferSize = sizeof(LSAPR_CR_CIPHER_VALUE) + CurrentValue->MaximumLength;
1988 EncryptedCurrentValue = midl_user_allocate(BufferSize);
1989 if (EncryptedCurrentValue == NULL)
1990 {
1991 Status = STATUS_INSUFFICIENT_RESOURCES;
1992 goto done;
1993 }
1994
1995 EncryptedCurrentValue->Length = CurrentValue->Length;
1996 EncryptedCurrentValue->MaximumLength = CurrentValue->MaximumLength;
1997 EncryptedCurrentValue->Buffer = (BYTE *)(EncryptedCurrentValue + 1);
1998 if (EncryptedCurrentValue->Buffer != NULL)
1999 memcpy(EncryptedCurrentValue->Buffer, CurrentValue->Buffer, CurrentValue->Length);
2000 }
2001
2002 if (OldValue != NULL)
2003 {
2004 BufferSize = sizeof(LSAPR_CR_CIPHER_VALUE) + OldValue->MaximumLength;
2005 EncryptedOldValue = midl_user_allocate(BufferSize);
2006 if (EncryptedOldValue == NULL)
2007 {
2008 Status = STATUS_INSUFFICIENT_RESOURCES;
2009 goto done;
2010 }
2011
2012 EncryptedOldValue->Length = OldValue->Length;
2013 EncryptedOldValue->MaximumLength = OldValue->MaximumLength;
2014 EncryptedOldValue->Buffer = (BYTE*)(EncryptedOldValue + 1);
2015 if (EncryptedOldValue->Buffer != NULL)
2016 memcpy(EncryptedOldValue->Buffer, OldValue->Buffer, OldValue->Length);
2017 }
2018
2019 RpcTryExcept
2020 {
2021 Status = LsarSetSecret((LSAPR_HANDLE)SecretHandle,
2022 EncryptedCurrentValue,
2023 EncryptedOldValue);
2024 }
2025 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2026 {
2027 Status = I_RpcMapWin32Status(RpcExceptionCode());
2028 }
2029 RpcEndExcept;
2030
2031 done:
2032 if (EncryptedCurrentValue != NULL)
2033 midl_user_free(EncryptedCurrentValue);
2034
2035 if (EncryptedOldValue != NULL)
2036 midl_user_free(EncryptedOldValue);
2037
2038 return Status;
2039 }
2040
2041
2042 /*
2043 * @implemented
2044 */
2045 NTSTATUS
2046 WINAPI
2047 LsaSetSecurityObject(IN LSA_HANDLE ObjectHandle,
2048 IN SECURITY_INFORMATION SecurityInformation,
2049 IN PSECURITY_DESCRIPTOR SecurityDescriptor)
2050 {
2051 LSAPR_SR_SECURITY_DESCRIPTOR SdBuffer = {0, NULL};
2052 ULONG SdLength = 0;
2053 NTSTATUS Status;
2054
2055 TRACE("LsaSetSecurityObject(%p %lx %p)\n",
2056 ObjectHandle, SecurityInformation, SecurityDescriptor);
2057
2058 Status = RtlMakeSelfRelativeSD(SecurityDescriptor,
2059 NULL,
2060 &SdLength);
2061 if (Status != STATUS_BUFFER_TOO_SMALL)
2062 return STATUS_INVALID_PARAMETER;
2063
2064 SdBuffer.SecurityDescriptor = MIDL_user_allocate(SdLength);
2065 if (SdBuffer.SecurityDescriptor == NULL)
2066 return STATUS_INSUFFICIENT_RESOURCES;
2067
2068 Status = RtlMakeSelfRelativeSD(SecurityDescriptor,
2069 (PSECURITY_DESCRIPTOR)SdBuffer.SecurityDescriptor,
2070 &SdLength);
2071 if (!NT_SUCCESS(Status))
2072 goto done;
2073
2074 SdBuffer.Length = SdLength;
2075
2076 RpcTryExcept
2077 {
2078 Status = LsarSetSecurityObject((LSAPR_HANDLE)ObjectHandle,
2079 SecurityInformation,
2080 &SdBuffer);
2081 }
2082 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2083 {
2084 Status = I_RpcMapWin32Status(RpcExceptionCode());
2085 }
2086 RpcEndExcept;
2087
2088 done:
2089 if (SdBuffer.SecurityDescriptor != NULL)
2090 MIDL_user_free(SdBuffer.SecurityDescriptor);
2091
2092 return Status;
2093 }
2094
2095
2096 /*
2097 * @implemented
2098 */
2099 NTSTATUS
2100 WINAPI
2101 LsaSetSystemAccessAccount(IN LSA_HANDLE AccountHandle,
2102 IN ULONG SystemAccess)
2103 {
2104 NTSTATUS Status;
2105
2106 TRACE("LsaSetSystemAccessAccount(%p 0x%lx)\n",
2107 AccountHandle, SystemAccess);
2108
2109 RpcTryExcept
2110 {
2111 Status = LsarSetSystemAccessAccount((LSAPR_HANDLE)AccountHandle,
2112 SystemAccess);
2113 }
2114 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2115 {
2116 Status = I_RpcMapWin32Status(RpcExceptionCode());
2117 }
2118 RpcEndExcept;
2119
2120 return Status;
2121 }
2122
2123
2124 /*
2125 * @unimplemented
2126 */
2127 NTSTATUS
2128 WINAPI
2129 LsaSetTrustedDomainInfoByName(IN LSA_HANDLE PolicyHandle,
2130 IN PLSA_UNICODE_STRING TrustedDomainName,
2131 IN TRUSTED_INFORMATION_CLASS InformationClass,
2132 IN PVOID Buffer)
2133 {
2134 FIXME("LsaSetTrustedDomainInfoByName(%p %p %d %p) stub\n",
2135 PolicyHandle, TrustedDomainName, InformationClass, Buffer);
2136 return STATUS_SUCCESS;
2137 }
2138
2139
2140 /*
2141 * @unimplemented
2142 */
2143 NTSTATUS
2144 WINAPI
2145 LsaSetTrustedDomainInformation(IN LSA_HANDLE PolicyHandle,
2146 IN PSID TrustedDomainSid,
2147 IN TRUSTED_INFORMATION_CLASS InformationClass,
2148 IN PVOID Buffer)
2149 {
2150 FIXME("LsaSetTrustedDomainInformation(%p %p %d %p) stub\n",
2151 PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
2152 return STATUS_SUCCESS;
2153 }
2154
2155
2156 /*
2157 * @implemented
2158 */
2159 NTSTATUS
2160 WINAPI
2161 LsaStorePrivateData(IN LSA_HANDLE PolicyHandle,
2162 IN PLSA_UNICODE_STRING KeyName,
2163 IN PLSA_UNICODE_STRING PrivateData OPTIONAL)
2164 {
2165 PLSAPR_CR_CIPHER_VALUE EncryptedData = NULL;
2166 SIZE_T BufferSize;
2167 NTSTATUS Status;
2168
2169 TRACE("LsaStorePrivateData(%p %p %p)\n",
2170 PolicyHandle, KeyName, PrivateData);
2171
2172 if (PrivateData != NULL)
2173 {
2174 BufferSize = sizeof(LSAPR_CR_CIPHER_VALUE) + PrivateData->MaximumLength;
2175 EncryptedData = midl_user_allocate(BufferSize);
2176 if (EncryptedData == NULL)
2177 {
2178 Status = STATUS_INSUFFICIENT_RESOURCES;
2179 goto done;
2180 }
2181
2182 EncryptedData->Length = PrivateData->Length;
2183 EncryptedData->MaximumLength = PrivateData->MaximumLength;
2184 EncryptedData->Buffer = (BYTE *)(EncryptedData + 1);
2185 if (EncryptedData->Buffer != NULL)
2186 RtlCopyMemory(EncryptedData->Buffer,
2187 PrivateData->Buffer,
2188 PrivateData->Length);
2189 }
2190
2191 RpcTryExcept
2192 {
2193 Status = LsarStorePrivateData((LSAPR_HANDLE)PolicyHandle,
2194 (PRPC_UNICODE_STRING)KeyName,
2195 EncryptedData);
2196 }
2197 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
2198 {
2199 Status = I_RpcMapWin32Status(RpcExceptionCode());
2200 }
2201 RpcEndExcept;
2202
2203 done:
2204 if (EncryptedData != NULL)
2205 midl_user_free(EncryptedData);
2206
2207 return Status;
2208 }
2209
2210 /* EOF */