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