[ADVAPI32]
[reactos.git] / reactos / dll / win32 / advapi32 / sec / lsa.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: dll/win32/advapi32/sec/lsa.c
5 * PURPOSE: Local security authority functions
6 * PROGRAMMER: Emanuele Aliberti
7 * UPDATE HISTORY:
8 * 19990322 EA created
9 * 19990515 EA stubs
10 * 20030202 KJK compressed stubs
11 *
12 */
13 #include <advapi32.h>
14 WINE_DEFAULT_DEBUG_CHANNEL(advapi);
15
16
17 static BOOL LsapIsLocalComputer(PLSA_UNICODE_STRING ServerName)
18 {
19 DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
20 BOOL Result;
21 LPWSTR buf;
22
23 if (ServerName == NULL || ServerName->Length == 0 || ServerName->Buffer == NULL)
24 return TRUE;
25
26 buf = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR));
27 Result = GetComputerNameW(buf, &dwSize);
28 if (Result && (ServerName->Buffer[0] == '\\') && (ServerName->Buffer[1] == '\\'))
29 ServerName += 2;
30 Result = Result && !lstrcmpW(ServerName->Buffer, buf);
31 HeapFree(GetProcessHeap(), 0, buf);
32
33 return Result;
34 }
35
36
37 handle_t __RPC_USER
38 PLSAPR_SERVER_NAME_bind(PLSAPR_SERVER_NAME pszSystemName)
39 {
40 handle_t hBinding = NULL;
41 LPWSTR pszStringBinding;
42 RPC_STATUS status;
43
44 TRACE("PLSAPR_SERVER_NAME_bind() called\n");
45
46 status = RpcStringBindingComposeW(NULL,
47 L"ncacn_np",
48 pszSystemName,
49 L"\\pipe\\lsarpc",
50 NULL,
51 &pszStringBinding);
52 if (status)
53 {
54 TRACE("RpcStringBindingCompose returned 0x%x\n", status);
55 return NULL;
56 }
57
58 /* Set the binding handle that will be used to bind to the server. */
59 status = RpcBindingFromStringBindingW(pszStringBinding,
60 &hBinding);
61 if (status)
62 {
63 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status);
64 }
65
66 status = RpcStringFreeW(&pszStringBinding);
67 if (status)
68 {
69 TRACE("RpcStringFree returned 0x%x\n", status);
70 }
71
72 return hBinding;
73 }
74
75
76 void __RPC_USER
77 PLSAPR_SERVER_NAME_unbind(PLSAPR_SERVER_NAME pszSystemName,
78 handle_t hBinding)
79 {
80 RPC_STATUS status;
81
82 TRACE("PLSAPR_SERVER_NAME_unbind() called\n");
83
84 status = RpcBindingFree(&hBinding);
85 if (status)
86 {
87 TRACE("RpcBindingFree returned 0x%x\n", status);
88 }
89 }
90
91
92 /*
93 * @implemented
94 */
95 NTSTATUS
96 WINAPI
97 LsaClose(IN LSA_HANDLE ObjectHandle)
98 {
99 NTSTATUS Status;
100
101 TRACE("LsaClose(0x%p) called\n", ObjectHandle);
102
103 RpcTryExcept
104 {
105 Status = LsarClose((PLSAPR_HANDLE)&ObjectHandle);
106 }
107 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
108 {
109 Status = I_RpcMapWin32Status(RpcExceptionCode());
110 }
111 RpcEndExcept;
112
113 return Status;
114 }
115
116
117 /*
118 * @implemented
119 */
120 NTSTATUS
121 WINAPI
122 LsaDelete(IN LSA_HANDLE ObjectHandle)
123 {
124 NTSTATUS Status;
125
126 TRACE("LsaDelete(0x%p) called\n", ObjectHandle);
127
128 RpcTryExcept
129 {
130 Status = LsarDelete((LSAPR_HANDLE)ObjectHandle);
131 }
132 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
133 {
134 Status = I_RpcMapWin32Status(RpcExceptionCode());
135 }
136 RpcEndExcept;
137
138 return Status;
139 }
140
141
142 /*
143 * @implemented
144 */
145 NTSTATUS
146 WINAPI
147 LsaAddAccountRights(IN LSA_HANDLE PolicyHandle,
148 IN PSID AccountSid,
149 IN PLSA_UNICODE_STRING UserRights,
150 IN ULONG CountOfRights)
151 {
152 LSAPR_USER_RIGHT_SET UserRightSet;
153 NTSTATUS Status;
154
155 TRACE("(%p,%p,%p,0x%08x) stub\n", PolicyHandle, AccountSid, UserRights, CountOfRights);
156
157 UserRightSet.Entries = CountOfRights;
158 UserRightSet.UserRights = (PRPC_UNICODE_STRING)UserRights;
159
160 RpcTryExcept
161 {
162 Status = LsarAddAccountRights((LSAPR_HANDLE)PolicyHandle,
163 (PRPC_SID)AccountSid,
164 &UserRightSet);
165
166 }
167 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
168 {
169 Status = I_RpcMapWin32Status(RpcExceptionCode());
170 }
171 RpcEndExcept;
172
173 return Status;
174 }
175
176
177 /*
178 * @implemented
179 */
180 NTSTATUS
181 WINAPI
182 LsaAddPrivilegesToAccount(IN LSA_HANDLE AccountHandle,
183 IN PPRIVILEGE_SET PrivilegeSet)
184 {
185 NTSTATUS Status;
186
187 TRACE("(%p,%p) stub\n", AccountHandle, PrivilegeSet);
188
189 RpcTryExcept
190 {
191 Status = LsarAddPrivilegesToAccount((LSAPR_HANDLE)AccountHandle,
192 (PLSAPR_PRIVILEGE_SET)PrivilegeSet);
193 }
194 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
195 {
196 Status = I_RpcMapWin32Status(RpcExceptionCode());
197 }
198 RpcEndExcept;
199
200 return Status;
201 }
202
203
204 /*
205 * @implemented
206 */
207 NTSTATUS
208 WINAPI
209 LsaCreateAccount(IN LSA_HANDLE PolicyHandle,
210 IN PSID AccountSid,
211 IN ACCESS_MASK DesiredAccess,
212 OUT PLSA_HANDLE AccountHandle)
213 {
214 NTSTATUS Status;
215
216 TRACE("(%p,%p,0x%08x,%p)\n", PolicyHandle, AccountSid, DesiredAccess, AccountHandle);
217
218 RpcTryExcept
219 {
220 Status = LsarCreateAccount((LSAPR_HANDLE)PolicyHandle,
221 AccountSid,
222 DesiredAccess,
223 AccountHandle);
224 }
225 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
226 {
227 Status = I_RpcMapWin32Status(RpcExceptionCode());
228 }
229 RpcEndExcept;
230
231 return Status;
232 }
233
234
235 /*
236 * @implemented
237 */
238 NTSTATUS
239 WINAPI
240 LsaCreateTrustedDomain(IN LSA_HANDLE PolicyHandle,
241 IN PLSA_TRUST_INFORMATION TrustedDomainInformation,
242 IN ACCESS_MASK DesiredAccess,
243 OUT PLSA_HANDLE TrustedDomainHandle)
244 {
245 NTSTATUS Status;
246
247 TRACE("(%p,%p,0x%08x,%p)\n", PolicyHandle, TrustedDomainInformation,
248 DesiredAccess, TrustedDomainHandle);
249
250 RpcTryExcept
251 {
252 Status = LsarCreateTrustedDomain((LSAPR_HANDLE)PolicyHandle,
253 (PLSAPR_TRUST_INFORMATION)TrustedDomainInformation,
254 DesiredAccess,
255 (PLSAPR_HANDLE)TrustedDomainHandle);
256 }
257 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
258 {
259 Status = I_RpcMapWin32Status(RpcExceptionCode());
260 }
261 RpcEndExcept;
262
263 return Status;
264 }
265
266
267 /*
268 * @unimplemented
269 */
270 NTSTATUS
271 WINAPI
272 LsaCreateTrustedDomainEx(
273 LSA_HANDLE PolicyHandle,
274 PTRUSTED_DOMAIN_INFORMATION_EX TrustedDomainInformation,
275 PTRUSTED_DOMAIN_AUTH_INFORMATION AuthenticationInformation,
276 ACCESS_MASK DesiredAccess,
277 PLSA_HANDLE TrustedDomainHandle)
278 {
279 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", PolicyHandle, TrustedDomainInformation, AuthenticationInformation,
280 DesiredAccess, TrustedDomainHandle);
281 return STATUS_SUCCESS;
282 }
283
284
285 /*
286 * @implemented
287 */
288 NTSTATUS
289 WINAPI
290 LsaDeleteTrustedDomain(IN LSA_HANDLE PolicyHandle,
291 IN PSID TrustedDomainSid)
292 {
293 NTSTATUS Status;
294
295 TRACE("(%p,%p)\n", PolicyHandle, TrustedDomainSid);
296
297 RpcTryExcept
298 {
299 Status = LsarDeleteTrustedDomain((LSAPR_HANDLE)PolicyHandle,
300 TrustedDomainSid);
301 }
302 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
303 {
304 Status = I_RpcMapWin32Status(RpcExceptionCode());
305 }
306 RpcEndExcept;
307
308 return Status;
309 }
310
311
312 /*
313 * @implemented
314 */
315 NTSTATUS
316 WINAPI
317 LsaEnumerateAccountRights(IN LSA_HANDLE PolicyHandle,
318 IN PSID AccountSid,
319 OUT PLSA_UNICODE_STRING *UserRights,
320 OUT PULONG CountOfRights)
321 {
322 LSAPR_USER_RIGHT_SET UserRightsSet;
323 NTSTATUS Status;
324
325 TRACE("(%p,%p,%p,%p) stub\n", PolicyHandle, AccountSid, UserRights, CountOfRights);
326
327 UserRightsSet.Entries = 0;
328 UserRightsSet.UserRights = NULL;
329
330 RpcTryExcept
331 {
332 Status = LsarEnmuerateAccountRights((LSAPR_HANDLE)PolicyHandle,
333 AccountSid,
334 &UserRightsSet);
335
336 *CountOfRights = UserRightsSet.Entries;
337 *UserRights = (PUNICODE_STRING)UserRightsSet.UserRights;
338 }
339 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
340 {
341 Status = I_RpcMapWin32Status(RpcExceptionCode());
342
343 if (UserRightsSet.UserRights != NULL)
344 {
345 MIDL_user_free(UserRightsSet.UserRights);
346 }
347 }
348 RpcEndExcept;
349
350 return Status;
351 }
352
353
354 /*
355 * @unimplemented
356 */
357 NTSTATUS
358 WINAPI
359 LsaEnumerateAccountsWithUserRight(
360 LSA_HANDLE PolicyHandle,
361 OPTIONAL PLSA_UNICODE_STRING UserRights,
362 PVOID *EnumerationBuffer,
363 PULONG CountReturned)
364 {
365 FIXME("(%p,%p,%p,%p) stub\n", PolicyHandle, UserRights, EnumerationBuffer, CountReturned);
366 return STATUS_NO_MORE_ENTRIES;
367 }
368
369
370 /*
371 * @implemented
372 */
373 NTSTATUS
374 WINAPI
375 LsaEnumeratePrivilegesOfAccount(IN LSA_HANDLE AccountHandle,
376 OUT PPRIVILEGE_SET *Privileges)
377 {
378 NTSTATUS Status;
379
380 TRACE("(%p,%p) stub\n", AccountHandle, Privileges);
381
382 RpcTryExcept
383 {
384 Status = LsarEnumeratePrivilegesAccount((LSAPR_HANDLE)AccountHandle,
385 (LSAPR_PRIVILEGE_SET **)Privileges);
386 }
387 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
388 {
389 Status = I_RpcMapWin32Status(RpcExceptionCode());
390 }
391 RpcEndExcept;
392
393 return Status;
394 }
395
396
397 /*
398 * @unimplemented
399 */
400 NTSTATUS
401 WINAPI
402 LsaEnumerateTrustedDomains(
403 LSA_HANDLE PolicyHandle,
404 PLSA_ENUMERATION_HANDLE EnumerationContext,
405 PVOID *Buffer,
406 ULONG PreferedMaximumLength,
407 PULONG CountReturned)
408 {
409 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", PolicyHandle, EnumerationContext,
410 Buffer, PreferedMaximumLength, CountReturned);
411
412 if (CountReturned) *CountReturned = 0;
413 return STATUS_SUCCESS;
414 }
415
416 /*
417 * @unimplemented
418 */
419 NTSTATUS
420 WINAPI
421 LsaEnumerateTrustedDomainsEx(
422 LSA_HANDLE PolicyHandle,
423 PLSA_ENUMERATION_HANDLE EnumerationContext,
424 PVOID *Buffer,
425 ULONG PreferedMaximumLength,
426 PULONG CountReturned)
427 {
428 FIXME("(%p,%p,%p,0x%08x,%p) stub\n", PolicyHandle, EnumerationContext, Buffer,
429 PreferedMaximumLength, CountReturned);
430 if (CountReturned) *CountReturned = 0;
431 return STATUS_SUCCESS;
432 }
433
434
435 /*
436 * @implemented
437 */
438 NTSTATUS
439 WINAPI
440 LsaFreeMemory(IN PVOID Buffer)
441 {
442 TRACE("(%p)\n", Buffer);
443 return RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
444 }
445
446
447 /*
448 * @implemented
449 */
450 NTSTATUS
451 WINAPI
452 LsaLookupNames(IN LSA_HANDLE PolicyHandle,
453 IN ULONG Count,
454 IN PLSA_UNICODE_STRING Names,
455 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
456 OUT PLSA_TRANSLATED_SID *Sids)
457 {
458 LSAPR_TRANSLATED_SIDS TranslatedSids = {0, NULL};
459 ULONG MappedCount = 0;
460 NTSTATUS Status;
461
462 TRACE("(%p,0x%08x,%p,%p,%p)\n", PolicyHandle, Count, Names,
463 ReferencedDomains, Sids);
464
465 if (ReferencedDomains == NULL || Sids == NULL)
466 return STATUS_INVALID_PARAMETER;
467
468 RpcTryExcept
469 {
470 *ReferencedDomains = NULL;
471 *Sids = NULL;
472
473 TranslatedSids.Entries = Count;
474
475 Status = LsarLookupNames((LSAPR_HANDLE)PolicyHandle,
476 Count,
477 (PRPC_UNICODE_STRING)Names,
478 (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
479 &TranslatedSids,
480 LsapLookupWksta,
481 &MappedCount);
482
483 *Sids = (PLSA_TRANSLATED_SID)TranslatedSids.Sids;
484 }
485 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
486 {
487 if (TranslatedSids.Sids != NULL)
488 MIDL_user_free(TranslatedSids.Sids);
489
490 Status = I_RpcMapWin32Status(RpcExceptionCode());
491 }
492 RpcEndExcept;
493
494 return Status;
495 }
496
497
498 /*
499 * @implemented
500 */
501 NTSTATUS
502 WINAPI
503 LsaLookupNames2(IN LSA_HANDLE PolicyHandle,
504 IN ULONG Flags,
505 IN ULONG Count,
506 IN PLSA_UNICODE_STRING Names,
507 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
508 OUT PLSA_TRANSLATED_SID2 *Sids)
509 {
510 LSAPR_TRANSLATED_SIDS_EX2 TranslatedSids = {0, NULL};
511 ULONG MappedCount = 0;
512 NTSTATUS Status;
513
514 TRACE("(%p,0x%08x,0x%08x,%p,%p,%p) stub\n", PolicyHandle, Flags,
515 Count, Names, ReferencedDomains, Sids);
516
517 if (ReferencedDomains == NULL || Sids == NULL)
518 return STATUS_INVALID_PARAMETER;
519
520 RpcTryExcept
521 {
522 *ReferencedDomains = NULL;
523 *Sids = NULL;
524
525 TranslatedSids.Entries = Count;
526
527 Status = LsarLookupNames3((LSAPR_HANDLE)PolicyHandle,
528 Count,
529 (PRPC_UNICODE_STRING)Names,
530 (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
531 &TranslatedSids,
532 LsapLookupWksta,
533 &MappedCount,
534 Flags,
535 2);
536
537 *Sids = (PLSA_TRANSLATED_SID2)TranslatedSids.Sids;
538 }
539 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
540 {
541 if (TranslatedSids.Sids != NULL)
542 MIDL_user_free(TranslatedSids.Sids);
543
544 Status = I_RpcMapWin32Status(RpcExceptionCode());
545 }
546 RpcEndExcept;
547
548 return Status;
549 }
550
551
552 /*
553 * @implemented
554 */
555 NTSTATUS
556 WINAPI
557 LsaLookupPrivilegeName(IN LSA_HANDLE PolicyHandle,
558 IN PLUID Value,
559 OUT PUNICODE_STRING *Name)
560 {
561 PRPC_UNICODE_STRING NameBuffer = NULL;
562 NTSTATUS Status;
563
564 TRACE("(%p,%p,%p)\n", PolicyHandle, Value, Name);
565
566 RpcTryExcept
567 {
568 Status = LsarLookupPrivilegeName(PolicyHandle,
569 Value,
570 &NameBuffer);
571
572 *Name = (PUNICODE_STRING)NameBuffer;
573 }
574 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
575 {
576 if (NameBuffer != NULL)
577 MIDL_user_free(NameBuffer);
578
579 Status = I_RpcMapWin32Status(RpcExceptionCode());
580 }
581 RpcEndExcept;
582
583 return Status;
584 }
585
586
587 /*
588 * @implemented
589 */
590 NTSTATUS
591 WINAPI
592 LsaLookupPrivilegeValue(IN LSA_HANDLE PolicyHandle,
593 IN PLSA_UNICODE_STRING Name,
594 OUT PLUID Value)
595 {
596 LUID Luid;
597 NTSTATUS Status;
598
599 TRACE("(%p,%p,%p)\n", PolicyHandle, Name, Value);
600
601 RpcTryExcept
602 {
603 Status = LsarLookupPrivilegeValue(PolicyHandle,
604 (PRPC_UNICODE_STRING)Name,
605 &Luid);
606 if (Status == STATUS_SUCCESS)
607 *Value = Luid;
608 }
609 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
610 {
611 Status = I_RpcMapWin32Status(RpcExceptionCode());
612 }
613 RpcEndExcept;
614
615 return Status;
616 }
617
618
619 /*
620 * @implemented
621 */
622 NTSTATUS
623 WINAPI
624 LsaLookupSids(IN LSA_HANDLE PolicyHandle,
625 IN ULONG Count,
626 IN PSID *Sids,
627 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
628 OUT PLSA_TRANSLATED_NAME *Names)
629 {
630 LSAPR_SID_ENUM_BUFFER SidEnumBuffer;
631 LSAPR_TRANSLATED_NAMES TranslatedNames;
632 ULONG MappedCount = 0;
633 NTSTATUS Status;
634
635 TRACE("(%p,%u,%p,%p,%p)\n", PolicyHandle, Count, Sids,
636 ReferencedDomains, Names);
637
638 if (Count == 0)
639 return STATUS_INVALID_PARAMETER;
640
641 SidEnumBuffer.Entries = Count;
642 SidEnumBuffer.SidInfo = (PLSAPR_SID_INFORMATION)Sids;
643
644 RpcTryExcept
645 {
646 *ReferencedDomains = NULL;
647 *Names = NULL;
648
649 TranslatedNames.Entries = 0;
650 TranslatedNames.Names = NULL;
651
652 Status = LsarLookupSids((LSAPR_HANDLE)PolicyHandle,
653 &SidEnumBuffer,
654 (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
655 &TranslatedNames,
656 LsapLookupWksta,
657 &MappedCount);
658
659 *Names = (PLSA_TRANSLATED_NAME)TranslatedNames.Names;
660 }
661 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
662 {
663 if (TranslatedNames.Names != NULL)
664 {
665 MIDL_user_free(TranslatedNames.Names);
666 }
667
668 Status = I_RpcMapWin32Status(RpcExceptionCode());
669 }
670 RpcEndExcept;
671
672 return Status;
673 }
674
675
676 /******************************************************************************
677 * LsaNtStatusToWinError
678 *
679 * PARAMS
680 * Status [I]
681 *
682 * @implemented
683 */
684 ULONG
685 WINAPI
686 LsaNtStatusToWinError(IN NTSTATUS Status)
687 {
688 TRACE("(%lx)\n", Status);
689 return RtlNtStatusToDosError(Status);
690 }
691
692
693 /*
694 * @implemented
695 */
696 NTSTATUS
697 WINAPI
698 LsaOpenAccount(IN LSA_HANDLE PolicyHandle,
699 IN PSID AccountSid,
700 IN ACCESS_MASK DesiredAccess,
701 OUT PLSA_HANDLE AccountHandle)
702 {
703 NTSTATUS Status;
704
705 TRACE("(%p,%p,0x%08lx,%p)\n", PolicyHandle, AccountSid, DesiredAccess, AccountHandle);
706
707 RpcTryExcept
708 {
709 Status = LsarOpenAccount((LSAPR_HANDLE)PolicyHandle,
710 AccountSid,
711 DesiredAccess,
712 AccountHandle);
713 }
714 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
715 {
716 Status = I_RpcMapWin32Status(RpcExceptionCode());
717 }
718 RpcEndExcept;
719
720 return Status;
721 }
722
723
724 /******************************************************************************
725 * LsaOpenPolicy
726 *
727 * PARAMS
728 * x1 []
729 * x2 []
730 * x3 []
731 * x4 []
732 *
733 * @implemented
734 */
735 NTSTATUS
736 WINAPI
737 LsaOpenPolicy(IN PLSA_UNICODE_STRING SystemName,
738 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
739 IN ACCESS_MASK DesiredAccess,
740 OUT PLSA_HANDLE PolicyHandle)
741 {
742 NTSTATUS Status;
743
744 TRACE("LsaOpenPolicy (%s,%p,0x%08x,%p)\n",
745 SystemName ? debugstr_w(SystemName->Buffer) : "(null)",
746 ObjectAttributes, DesiredAccess, PolicyHandle);
747
748 /* FIXME: RPC should take care of this */
749 if (!LsapIsLocalComputer(SystemName))
750 return RPC_NT_SERVER_UNAVAILABLE;
751
752 RpcTryExcept
753 {
754 *PolicyHandle = NULL;
755
756 Status = LsarOpenPolicy(SystemName ? SystemName->Buffer : NULL,
757 (PLSAPR_OBJECT_ATTRIBUTES)ObjectAttributes,
758 DesiredAccess,
759 PolicyHandle);
760 }
761 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
762 {
763 Status = I_RpcMapWin32Status(RpcExceptionCode());
764 }
765 RpcEndExcept;
766
767 TRACE("LsaOpenPolicy() done (Status: 0x%08lx)\n", Status);
768
769 return Status;
770 }
771
772
773 /*
774 * @implemented
775 */
776 NTSTATUS
777 WINAPI
778 LsaOpenTrustedDomainByName(IN LSA_HANDLE PolicyHandle,
779 IN PLSA_UNICODE_STRING TrustedDomainName,
780 IN ACCESS_MASK DesiredAccess,
781 OUT PLSA_HANDLE TrustedDomainHandle)
782 {
783 NTSTATUS Status;
784
785 TRACE("(%p,%p,0x%08x,%p)\n", PolicyHandle, TrustedDomainName,
786 DesiredAccess, TrustedDomainHandle);
787
788 RpcTryExcept
789 {
790 Status = LsarOpenTrustedDomainByName((LSAPR_HANDLE)PolicyHandle,
791 (PRPC_UNICODE_STRING)TrustedDomainName,
792 DesiredAccess,
793 TrustedDomainHandle);
794 }
795 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
796 {
797 Status = I_RpcMapWin32Status(RpcExceptionCode());
798 }
799 RpcEndExcept;
800
801 return Status;
802 }
803
804
805 /*
806 * @unimplemented
807 */
808 NTSTATUS
809 WINAPI
810 LsaQueryDomainInformationPolicy(
811 LSA_HANDLE PolicyHandle,
812 POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
813 PVOID *Buffer)
814 {
815 FIXME("(%p,0x%08x,%p)\n", PolicyHandle, InformationClass, Buffer);
816 return STATUS_NOT_IMPLEMENTED;
817 }
818
819
820 /*
821 * @unimplemented
822 */
823 NTSTATUS
824 WINAPI
825 LsaQueryForestTrustInformation(
826 LSA_HANDLE PolicyHandle,
827 PLSA_UNICODE_STRING TrustedDomainName,
828 PLSA_FOREST_TRUST_INFORMATION * ForestTrustInfo)
829 {
830 FIXME("(%p,%p,%p) stub\n", PolicyHandle, TrustedDomainName, ForestTrustInfo);
831 return STATUS_NOT_IMPLEMENTED;
832 }
833
834
835 /*
836 * @implemented
837 */
838 NTSTATUS
839 WINAPI
840 LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle,
841 IN POLICY_INFORMATION_CLASS InformationClass,
842 OUT PVOID *Buffer)
843 {
844 PLSAPR_POLICY_INFORMATION PolicyInformation = NULL;
845 NTSTATUS Status;
846
847 TRACE("(%p,0x%08x,%p)\n", PolicyHandle, InformationClass, Buffer);
848
849 RpcTryExcept
850 {
851 Status = LsarQueryInformationPolicy((LSAPR_HANDLE)PolicyHandle,
852 InformationClass,
853 &PolicyInformation);
854 *Buffer = PolicyInformation;
855 }
856 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
857 {
858 if (PolicyInformation != NULL)
859 MIDL_user_free(PolicyInformation);
860
861 Status = I_RpcMapWin32Status(RpcExceptionCode());
862 }
863 RpcEndExcept;
864
865 TRACE("Done (Status: 0x%08x)\n", Status);
866
867 return Status;
868 }
869
870
871 /*
872 * @unimplemented
873 */
874 NTSTATUS
875 WINAPI
876 LsaQueryTrustedDomainInfo(
877 LSA_HANDLE PolicyHandle,
878 PSID TrustedDomainSid,
879 TRUSTED_INFORMATION_CLASS InformationClass,
880 PVOID *Buffer)
881 {
882 FIXME("(%p,%p,%d,%p) stub\n", PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
883 return STATUS_OBJECT_NAME_NOT_FOUND;
884 }
885
886
887 /*
888 * @implemented
889 */
890 NTSTATUS
891 WINAPI
892 LsaQueryTrustedDomainInfoByName(IN LSA_HANDLE PolicyHandle,
893 IN PLSA_UNICODE_STRING TrustedDomainName,
894 IN TRUSTED_INFORMATION_CLASS InformationClass,
895 OUT PVOID *Buffer)
896 {
897 NTSTATUS Status;
898
899 TRACE("(%p,%p,%d,%p)\n", PolicyHandle, TrustedDomainName, InformationClass, Buffer);
900
901 if (InformationClass == TrustedDomainAuthInformationInternal ||
902 InformationClass == TrustedDomainFullInformationInternal)
903 return STATUS_INVALID_INFO_CLASS;
904
905 RpcTryExcept
906 {
907 Status = LsarQueryTrustedDomainInfoByName((LSAPR_HANDLE)PolicyHandle,
908 (PRPC_UNICODE_STRING)TrustedDomainName,
909 InformationClass,
910 (unsigned long *)Buffer); // Shuld be: (PLSAPR_POLICY_INFORMATION *)Buffer
911 }
912 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
913 {
914 Status = I_RpcMapWin32Status(RpcExceptionCode());
915 }
916 RpcEndExcept;
917
918 return Status;
919 }
920
921
922 /*
923 * @implemented
924 */
925 NTSTATUS
926 WINAPI
927 LsaRemoveAccountRights(IN LSA_HANDLE PolicyHandle,
928 IN PSID AccountSid,
929 IN BOOLEAN AllRights,
930 IN PLSA_UNICODE_STRING UserRights,
931 IN ULONG CountOfRights)
932 {
933 LSAPR_USER_RIGHT_SET UserRightSet;
934
935 TRACE("(%p,%p,%d,%p,0x%08x) stub\n", PolicyHandle, AccountSid, AllRights, UserRights, CountOfRights);
936
937 UserRightSet.Entries = CountOfRights;
938 UserRightSet.UserRights = (PRPC_UNICODE_STRING)UserRights;
939
940 RpcTryExcept
941 {
942 LsarRemoveAccountRights((LSAPR_HANDLE)PolicyHandle,
943 (PRPC_SID)AccountSid,
944 AllRights,
945 &UserRightSet);
946 }
947 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
948 {
949 I_RpcMapWin32Status(RpcExceptionCode());
950 }
951 RpcEndExcept;
952
953 return STATUS_SUCCESS;
954 }
955
956
957 /*
958 * @unimplemented
959 */
960 NTSTATUS
961 WINAPI
962 LsaRetrievePrivateData(
963 LSA_HANDLE PolicyHandle,
964 PLSA_UNICODE_STRING KeyName,
965 PLSA_UNICODE_STRING *PrivateData)
966 {
967 FIXME("(%p,%p,%p) stub\n", PolicyHandle, KeyName, PrivateData);
968 return STATUS_OBJECT_NAME_NOT_FOUND;
969 }
970
971 /*
972 * @unimplemented
973 */
974 NTSTATUS
975 WINAPI
976 LsaSetDomainInformationPolicy(
977 LSA_HANDLE PolicyHandle,
978 POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
979 PVOID Buffer)
980 {
981 FIXME("(%p,0x%08x,%p) stub\n", PolicyHandle, InformationClass, Buffer);
982 return STATUS_UNSUCCESSFUL;
983 }
984
985
986 /*
987 * @implemented
988 */
989 NTSTATUS
990 WINAPI
991 LsaSetInformationPolicy(IN LSA_HANDLE PolicyHandle,
992 IN POLICY_INFORMATION_CLASS InformationClass,
993 IN PVOID Buffer)
994 {
995 NTSTATUS Status;
996
997 TRACE("(%p,0x%08x,%p)\n", PolicyHandle, InformationClass, Buffer);
998
999 RpcTryExcept
1000 {
1001 Status = LsarSetInformationPolicy((LSAPR_HANDLE)PolicyHandle,
1002 InformationClass,
1003 (PLSAPR_POLICY_INFORMATION)Buffer);
1004 }
1005 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1006 {
1007 Status = I_RpcMapWin32Status(RpcExceptionCode());
1008 }
1009 RpcEndExcept;
1010
1011 return Status;
1012 }
1013
1014
1015 /*
1016 * @unimplemented
1017 */
1018 NTSTATUS WINAPI LsaSetSecret(
1019 IN LSA_HANDLE SecretHandle,
1020 IN PLSA_UNICODE_STRING EncryptedCurrentValue,
1021 IN PLSA_UNICODE_STRING EncryptedOldValue)
1022 {
1023 FIXME("(%p,%p,%p) stub\n", SecretHandle, EncryptedCurrentValue,
1024 EncryptedOldValue);
1025 return STATUS_SUCCESS;
1026 }
1027
1028 /*
1029 * @unimplemented
1030 */
1031 NTSTATUS
1032 WINAPI
1033 LsaSetForestTrustInformation(
1034 LSA_HANDLE PolicyHandle,
1035 PLSA_UNICODE_STRING TrustedDomainName,
1036 PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo,
1037 BOOL CheckOnly,
1038 PLSA_FOREST_TRUST_COLLISION_INFORMATION *CollisionInfo)
1039 {
1040 FIXME("(%p,%p,%p,%d,%p) stub\n", PolicyHandle, TrustedDomainName, ForestTrustInfo, CheckOnly, CollisionInfo);
1041 return STATUS_NOT_IMPLEMENTED;
1042 }
1043
1044 /*
1045 * @unimplemented
1046 */
1047 NTSTATUS
1048 WINAPI
1049 LsaSetTrustedDomainInfoByName(
1050 LSA_HANDLE PolicyHandle,
1051 PLSA_UNICODE_STRING TrustedDomainName,
1052 TRUSTED_INFORMATION_CLASS InformationClass,
1053 PVOID Buffer)
1054 {
1055 FIXME("(%p,%p,%d,%p) stub\n", PolicyHandle, TrustedDomainName, InformationClass, Buffer);
1056 return STATUS_SUCCESS;
1057 }
1058
1059 /*
1060 * @unimplemented
1061 */
1062 NTSTATUS WINAPI LsaRegisterPolicyChangeNotification(
1063 POLICY_NOTIFICATION_INFORMATION_CLASS class,
1064 HANDLE event)
1065 {
1066 FIXME("(%d,%p) stub\n", class, event);
1067 return STATUS_UNSUCCESSFUL;
1068 }
1069
1070 /*
1071 * @unimplemented
1072 */
1073 NTSTATUS
1074 WINAPI
1075 LsaSetTrustedDomainInformation(
1076 LSA_HANDLE PolicyHandle,
1077 PSID TrustedDomainSid,
1078 TRUSTED_INFORMATION_CLASS InformationClass,
1079 PVOID Buffer)
1080 {
1081 FIXME("(%p,%p,%d,%p) stub\n", PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
1082 return STATUS_SUCCESS;
1083 }
1084
1085 /*
1086 * @unimplemented
1087 */
1088 NTSTATUS
1089 WINAPI
1090 LsaStorePrivateData(
1091 LSA_HANDLE PolicyHandle,
1092 PLSA_UNICODE_STRING KeyName,
1093 PLSA_UNICODE_STRING PrivateData)
1094 {
1095 FIXME("(%p,%p,%p) stub\n", PolicyHandle, KeyName, PrivateData);
1096 return STATUS_OBJECT_NAME_NOT_FOUND;
1097 }
1098
1099 /*
1100 * @unimplemented
1101 */
1102 NTSTATUS WINAPI LsaUnregisterPolicyChangeNotification(
1103 POLICY_NOTIFICATION_INFORMATION_CLASS class,
1104 HANDLE event)
1105 {
1106 FIXME("(%d,%p) stub\n", class, event);
1107 return STATUS_SUCCESS;
1108 }
1109
1110 /*
1111 * @unimplemented
1112 */
1113 NTSTATUS
1114 WINAPI
1115 LsaGetUserName(
1116 PUNICODE_STRING *UserName,
1117 PUNICODE_STRING *DomainName)
1118 {
1119 FIXME("(%p,%p) stub\n", UserName, DomainName);
1120 return STATUS_NOT_IMPLEMENTED;
1121 }
1122
1123 /*
1124 * @unimplemented
1125 */
1126 NTSTATUS
1127 WINAPI
1128 LsaQueryInfoTrustedDomain (DWORD Unknonw0,
1129 DWORD Unknonw1,
1130 DWORD Unknonw2)
1131 {
1132 FIXME("(%d,%d,%d) stub\n", Unknonw0, Unknonw1, Unknonw2);
1133 return STATUS_NOT_IMPLEMENTED;
1134 }
1135
1136
1137 /* EOF */