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