[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
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 NTAPI
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 FIXME("LsaCreateTrustedDomainEx(%p %p %p 0x%08lx %p) stub\n",
320 PolicyHandle, TrustedDomainInformation, AuthenticationInformation,
321 DesiredAccess, TrustedDomainHandle);
322 return STATUS_SUCCESS;
323 }
324
325
326 /*
327 * @implemented
328 */
329 NTSTATUS
330 WINAPI
331 LsaDelete(IN LSA_HANDLE ObjectHandle)
332 {
333 NTSTATUS Status;
334
335 TRACE("LsaDelete(%p)\n", ObjectHandle);
336
337 RpcTryExcept
338 {
339 Status = LsarDelete((LSAPR_HANDLE)ObjectHandle);
340 }
341 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
342 {
343 Status = I_RpcMapWin32Status(RpcExceptionCode());
344 }
345 RpcEndExcept;
346
347 return Status;
348 }
349
350
351 /*
352 * @implemented
353 */
354 NTSTATUS
355 WINAPI
356 LsaDeleteTrustedDomain(IN LSA_HANDLE PolicyHandle,
357 IN PSID TrustedDomainSid)
358 {
359 NTSTATUS Status;
360
361 TRACE("LsaDeleteTrustedDomain(%p %p)\n",
362 PolicyHandle, TrustedDomainSid);
363
364 RpcTryExcept
365 {
366 Status = LsarDeleteTrustedDomain((LSAPR_HANDLE)PolicyHandle,
367 TrustedDomainSid);
368 }
369 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
370 {
371 Status = I_RpcMapWin32Status(RpcExceptionCode());
372 }
373 RpcEndExcept;
374
375 return Status;
376 }
377
378
379 /*
380 * @implemented
381 */
382 NTSTATUS
383 WINAPI
384 LsaEnumerateAccountRights(IN LSA_HANDLE PolicyHandle,
385 IN PSID AccountSid,
386 OUT PLSA_UNICODE_STRING *UserRights,
387 OUT PULONG CountOfRights)
388 {
389 LSAPR_USER_RIGHT_SET UserRightsSet;
390 NTSTATUS Status;
391
392 TRACE("LsaEnumerateAccountRights(%p %p %p %p)\n",
393 PolicyHandle, AccountSid, UserRights, CountOfRights);
394
395 UserRightsSet.Entries = 0;
396 UserRightsSet.UserRights = NULL;
397
398 RpcTryExcept
399 {
400 Status = LsarEnmuerateAccountRights((LSAPR_HANDLE)PolicyHandle,
401 AccountSid,
402 &UserRightsSet);
403
404 *CountOfRights = UserRightsSet.Entries;
405 *UserRights = (PUNICODE_STRING)UserRightsSet.UserRights;
406 }
407 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
408 {
409 Status = I_RpcMapWin32Status(RpcExceptionCode());
410
411 if (UserRightsSet.UserRights != NULL)
412 {
413 MIDL_user_free(UserRightsSet.UserRights);
414 }
415 }
416 RpcEndExcept;
417
418 return Status;
419 }
420
421
422 /*
423 * @unimplemented
424 */
425 NTSTATUS
426 WINAPI
427 LsaEnumerateAccountsWithUserRight(IN LSA_HANDLE PolicyHandle,
428 IN PLSA_UNICODE_STRING UserRight OPTIONAL,
429 OUT PVOID *Buffer,
430 OUT PULONG CountReturned)
431 {
432 FIXME("LsaEnumerateAccountsWithUserRight(%p %p %p %p) stub\n",
433 PolicyHandle, UserRight, Buffer, CountReturned);
434 return STATUS_NO_MORE_ENTRIES;
435 }
436
437
438 /*
439 * @implemented
440 */
441 NTSTATUS
442 WINAPI
443 LsaEnumeratePrivilegesOfAccount(IN LSA_HANDLE AccountHandle,
444 OUT PPRIVILEGE_SET *Privileges)
445 {
446 NTSTATUS Status;
447
448 TRACE("LsaEnumeratePrivilegesOfAccount(%p %p)\n",
449 AccountHandle, Privileges);
450
451 RpcTryExcept
452 {
453 Status = LsarEnumeratePrivilegesAccount((LSAPR_HANDLE)AccountHandle,
454 (LSAPR_PRIVILEGE_SET **)Privileges);
455 }
456 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
457 {
458 Status = I_RpcMapWin32Status(RpcExceptionCode());
459 }
460 RpcEndExcept;
461
462 return Status;
463 }
464
465
466 /*
467 * @unimplemented
468 */
469 NTSTATUS
470 WINAPI
471 LsaEnumerateTrustedDomains(IN LSA_HANDLE PolicyHandle,
472 IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
473 OUT PVOID *Buffer,
474 IN ULONG PreferedMaximumLength,
475 OUT PULONG CountReturned)
476 {
477 FIXME("LsaEnumerateTrustedDomains(%p %p %p %lu %p) stub\n",
478 PolicyHandle, EnumerationContext, Buffer,
479 PreferedMaximumLength, CountReturned);
480
481 if (CountReturned) *CountReturned = 0;
482 return STATUS_SUCCESS;
483 }
484
485 /*
486 * @unimplemented
487 */
488 NTSTATUS
489 WINAPI
490 LsaEnumerateTrustedDomainsEx(IN LSA_HANDLE PolicyHandle,
491 IN OUT PLSA_ENUMERATION_HANDLE EnumerationContext,
492 OUT PVOID *Buffer,
493 IN ULONG PreferedMaximumLength,
494 OUT PULONG CountReturned)
495 {
496 FIXME("LsaEnumerateTrustedDomainsEx(%p %p %p %lu %p) stub\n",
497 PolicyHandle, EnumerationContext, Buffer,
498 PreferedMaximumLength, CountReturned);
499
500 if (CountReturned) *CountReturned = 0;
501 return STATUS_SUCCESS;
502 }
503
504
505 /*
506 * @implemented
507 */
508 NTSTATUS
509 WINAPI
510 LsaFreeMemory(IN PVOID Buffer)
511 {
512 TRACE("LsaFreeMemory(%p)\n", Buffer);
513 return RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
514 }
515
516
517 /*
518 * @implemented
519 */
520 NTSTATUS
521 WINAPI
522 LsaGetSystemAccessAccount(IN LSA_HANDLE AccountHandle,
523 OUT PULONG SystemAccess)
524 {
525 NTSTATUS Status;
526
527 TRACE("LsaGetSystemAccessAccount(%p %p)\n",
528 AccountHandle, SystemAccess);
529
530 RpcTryExcept
531 {
532 Status = LsarGetSystemAccessAccount((LSAPR_HANDLE)AccountHandle,
533 (ACCESS_MASK *)SystemAccess);
534 }
535 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
536 {
537 Status = I_RpcMapWin32Status(RpcExceptionCode());
538 }
539 RpcEndExcept;
540
541 return Status;
542 }
543
544
545 /*
546 * @unimplemented
547 */
548 NTSTATUS
549 WINAPI
550 LsaGetUserName(OUT PUNICODE_STRING *UserName,
551 OUT PUNICODE_STRING *DomainName OPTIONAL)
552 {
553 PRPC_UNICODE_STRING UserNameString = NULL;
554 PRPC_UNICODE_STRING DomainNameString = NULL;
555 NTSTATUS Status;
556
557 TRACE("LsaGetUserName(%p %p)\n",
558 UserName, DomainName);
559
560 RpcTryExcept
561 {
562 Status = LsarGetUserName(NULL,
563 &UserNameString,
564 (DomainName != NULL) ? &DomainNameString : NULL);
565
566 *UserName = (PUNICODE_STRING)UserNameString;
567
568 if (DomainName != NULL)
569 *DomainName = (PUNICODE_STRING)DomainNameString;
570 }
571 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
572 {
573 if (UserNameString != NULL)
574 MIDL_user_free(UserNameString);
575
576 if (DomainNameString != NULL)
577 MIDL_user_free(DomainNameString);
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 LsaLookupNames(IN LSA_HANDLE PolicyHandle,
593 IN ULONG Count,
594 IN PLSA_UNICODE_STRING Names,
595 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
596 OUT PLSA_TRANSLATED_SID *Sids)
597 {
598 LSAPR_TRANSLATED_SIDS TranslatedSids = {0, NULL};
599 ULONG MappedCount = 0;
600 NTSTATUS Status;
601
602 TRACE("LsaLookupNames(%p %lu %p %p %p)\n",
603 PolicyHandle, Count, Names, ReferencedDomains, Sids);
604
605 if (ReferencedDomains == NULL || Sids == NULL)
606 return STATUS_INVALID_PARAMETER;
607
608 RpcTryExcept
609 {
610 *ReferencedDomains = NULL;
611 *Sids = NULL;
612
613 TranslatedSids.Entries = Count;
614
615 Status = LsarLookupNames((LSAPR_HANDLE)PolicyHandle,
616 Count,
617 (PRPC_UNICODE_STRING)Names,
618 (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
619 &TranslatedSids,
620 LsapLookupWksta,
621 &MappedCount);
622
623 *Sids = (PLSA_TRANSLATED_SID)TranslatedSids.Sids;
624 }
625 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
626 {
627 if (TranslatedSids.Sids != NULL)
628 MIDL_user_free(TranslatedSids.Sids);
629
630 Status = I_RpcMapWin32Status(RpcExceptionCode());
631 }
632 RpcEndExcept;
633
634 return Status;
635 }
636
637
638 /*
639 * @implemented
640 */
641 NTSTATUS
642 WINAPI
643 LsaLookupNames2(IN LSA_HANDLE PolicyHandle,
644 IN ULONG Flags,
645 IN ULONG Count,
646 IN PLSA_UNICODE_STRING Names,
647 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
648 OUT PLSA_TRANSLATED_SID2 *Sids)
649 {
650 LSAPR_TRANSLATED_SIDS_EX2 TranslatedSids = {0, NULL};
651 ULONG MappedCount = 0;
652 NTSTATUS Status;
653
654 TRACE("LsaLookupNames2(%p 0x%08x %lu %p %p %p)\n",
655 PolicyHandle, Flags, Count, Names, ReferencedDomains, Sids);
656
657 if (ReferencedDomains == NULL || Sids == NULL)
658 return STATUS_INVALID_PARAMETER;
659
660 RpcTryExcept
661 {
662 *ReferencedDomains = NULL;
663 *Sids = NULL;
664
665 TranslatedSids.Entries = Count;
666
667 Status = LsarLookupNames3((LSAPR_HANDLE)PolicyHandle,
668 Count,
669 (PRPC_UNICODE_STRING)Names,
670 (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
671 &TranslatedSids,
672 LsapLookupWksta,
673 &MappedCount,
674 Flags,
675 2);
676
677 *Sids = (PLSA_TRANSLATED_SID2)TranslatedSids.Sids;
678 }
679 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
680 {
681 if (TranslatedSids.Sids != NULL)
682 MIDL_user_free(TranslatedSids.Sids);
683
684 Status = I_RpcMapWin32Status(RpcExceptionCode());
685 }
686 RpcEndExcept;
687
688 return Status;
689 }
690
691
692 /*
693 * @implemented
694 */
695 NTSTATUS
696 WINAPI
697 LsaLookupPrivilegeName(IN LSA_HANDLE PolicyHandle,
698 IN PLUID Value,
699 OUT PUNICODE_STRING *Name)
700 {
701 PRPC_UNICODE_STRING NameBuffer = NULL;
702 NTSTATUS Status;
703
704 TRACE("LsaLookupPrivilegeName(%p %p %p)\n",
705 PolicyHandle, Value, Name);
706
707 RpcTryExcept
708 {
709 Status = LsarLookupPrivilegeName(PolicyHandle,
710 Value,
711 &NameBuffer);
712
713 *Name = (PUNICODE_STRING)NameBuffer;
714 }
715 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
716 {
717 if (NameBuffer != NULL)
718 MIDL_user_free(NameBuffer);
719
720 Status = I_RpcMapWin32Status(RpcExceptionCode());
721 }
722 RpcEndExcept;
723
724 return Status;
725 }
726
727
728 /*
729 * @implemented
730 */
731 NTSTATUS
732 WINAPI
733 LsaLookupPrivilegeValue(IN LSA_HANDLE PolicyHandle,
734 IN PLSA_UNICODE_STRING Name,
735 OUT PLUID Value)
736 {
737 LUID Luid;
738 NTSTATUS Status;
739
740 TRACE("LsaLookupPrivilegeValue(%p %p %p)\n",
741 PolicyHandle, Name, Value);
742
743 RpcTryExcept
744 {
745 Status = LsarLookupPrivilegeValue(PolicyHandle,
746 (PRPC_UNICODE_STRING)Name,
747 &Luid);
748 if (Status == STATUS_SUCCESS)
749 *Value = Luid;
750 }
751 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
752 {
753 Status = I_RpcMapWin32Status(RpcExceptionCode());
754 }
755 RpcEndExcept;
756
757 return Status;
758 }
759
760
761 /*
762 * @implemented
763 */
764 NTSTATUS
765 WINAPI
766 LsaLookupSids(IN LSA_HANDLE PolicyHandle,
767 IN ULONG Count,
768 IN PSID *Sids,
769 OUT PLSA_REFERENCED_DOMAIN_LIST *ReferencedDomains,
770 OUT PLSA_TRANSLATED_NAME *Names)
771 {
772 LSAPR_SID_ENUM_BUFFER SidEnumBuffer;
773 LSAPR_TRANSLATED_NAMES TranslatedNames;
774 ULONG MappedCount = 0;
775 NTSTATUS Status;
776
777 TRACE("LsaLookupSids(%p %lu %p %p %p)\n",
778 PolicyHandle, Count, Sids, ReferencedDomains, Names);
779
780 if (Count == 0)
781 return STATUS_INVALID_PARAMETER;
782
783 SidEnumBuffer.Entries = Count;
784 SidEnumBuffer.SidInfo = (PLSAPR_SID_INFORMATION)Sids;
785
786 RpcTryExcept
787 {
788 *ReferencedDomains = NULL;
789 *Names = NULL;
790
791 TranslatedNames.Entries = 0;
792 TranslatedNames.Names = NULL;
793
794 Status = LsarLookupSids((LSAPR_HANDLE)PolicyHandle,
795 &SidEnumBuffer,
796 (PLSAPR_REFERENCED_DOMAIN_LIST *)ReferencedDomains,
797 &TranslatedNames,
798 LsapLookupWksta,
799 &MappedCount);
800
801 *Names = (PLSA_TRANSLATED_NAME)TranslatedNames.Names;
802 }
803 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
804 {
805 if (TranslatedNames.Names != NULL)
806 {
807 MIDL_user_free(TranslatedNames.Names);
808 }
809
810 Status = I_RpcMapWin32Status(RpcExceptionCode());
811 }
812 RpcEndExcept;
813
814 return Status;
815 }
816
817
818 /******************************************************************************
819 * LsaNtStatusToWinError
820 *
821 * PARAMS
822 * Status [I]
823 *
824 * @implemented
825 */
826 ULONG
827 WINAPI
828 LsaNtStatusToWinError(IN NTSTATUS Status)
829 {
830 TRACE("LsaNtStatusToWinError(0x%lx)\n", Status);
831 return RtlNtStatusToDosError(Status);
832 }
833
834
835 /*
836 * @implemented
837 */
838 NTSTATUS
839 WINAPI
840 LsaOpenAccount(IN LSA_HANDLE PolicyHandle,
841 IN PSID AccountSid,
842 IN ACCESS_MASK DesiredAccess,
843 OUT PLSA_HANDLE AccountHandle)
844 {
845 NTSTATUS Status;
846
847 TRACE("LsaOpenAccount(%p %p 0x%08lx %p)\n",
848 PolicyHandle, AccountSid, DesiredAccess, AccountHandle);
849
850 RpcTryExcept
851 {
852 Status = LsarOpenAccount((LSAPR_HANDLE)PolicyHandle,
853 AccountSid,
854 DesiredAccess,
855 AccountHandle);
856 }
857 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
858 {
859 Status = I_RpcMapWin32Status(RpcExceptionCode());
860 }
861 RpcEndExcept;
862
863 return Status;
864 }
865
866
867 /******************************************************************************
868 * LsaOpenPolicy
869 *
870 * PARAMS
871 * x1 []
872 * x2 []
873 * x3 []
874 * x4 []
875 *
876 * @implemented
877 */
878 NTSTATUS
879 WINAPI
880 LsaOpenPolicy(IN PLSA_UNICODE_STRING SystemName OPTIONAL,
881 IN PLSA_OBJECT_ATTRIBUTES ObjectAttributes,
882 IN ACCESS_MASK DesiredAccess,
883 OUT PLSA_HANDLE PolicyHandle)
884 {
885 NTSTATUS Status;
886
887 TRACE("LsaOpenPolicy(%s %p 0x%08lx %p)\n",
888 SystemName ? debugstr_w(SystemName->Buffer) : "(null)",
889 ObjectAttributes, DesiredAccess, PolicyHandle);
890
891 /* FIXME: RPC should take care of this */
892 if (!LsapIsLocalComputer(SystemName))
893 return RPC_NT_SERVER_UNAVAILABLE;
894
895 RpcTryExcept
896 {
897 *PolicyHandle = NULL;
898
899 Status = LsarOpenPolicy(SystemName ? SystemName->Buffer : NULL,
900 (PLSAPR_OBJECT_ATTRIBUTES)ObjectAttributes,
901 DesiredAccess,
902 PolicyHandle);
903 }
904 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
905 {
906 Status = I_RpcMapWin32Status(RpcExceptionCode());
907 }
908 RpcEndExcept;
909
910 TRACE("LsaOpenPolicy() done (Status: 0x%08lx)\n", Status);
911
912 return Status;
913 }
914
915
916 NTSTATUS
917 WINAPI
918 LsaOpenSecret(IN LSA_HANDLE PolicyHandle,
919 IN PLSA_UNICODE_STRING SecretName,
920 IN ACCESS_MASK DesiredAccess,
921 OUT PLSA_HANDLE SecretHandle)
922 {
923 NTSTATUS Status;
924
925 TRACE("LsaOpenSecret(%p %p 0x%08lx %p)\n",
926 PolicyHandle, SecretName, DesiredAccess, SecretHandle);
927
928 RpcTryExcept
929 {
930 *SecretHandle = NULL;
931
932 Status = LsarOpenSecret((LSAPR_HANDLE)PolicyHandle,
933 (PRPC_UNICODE_STRING)SecretName,
934 DesiredAccess,
935 SecretHandle);
936 }
937 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
938 {
939 Status = I_RpcMapWin32Status(RpcExceptionCode());
940 }
941 RpcEndExcept;
942
943 TRACE("LsaOpenSecret() done (Status: 0x%08lx)\n", Status);
944
945 return Status;
946 }
947
948
949 /*
950 * @implemented
951 */
952 NTSTATUS
953 WINAPI
954 LsaOpenTrustedDomain(IN LSA_HANDLE PolicyHandle,
955 IN PSID TrustedDomainSid,
956 IN ACCESS_MASK DesiredAccess,
957 OUT PLSA_HANDLE TrustedDomainHandle)
958 {
959 NTSTATUS Status;
960
961 TRACE("LsaOpenTrustedDomain(%p %p 0x%08lx %p)\n",
962 PolicyHandle, TrustedDomainSid, DesiredAccess, TrustedDomainHandle);
963
964 RpcTryExcept
965 {
966 Status = LsarOpenTrustedDomain((LSAPR_HANDLE)PolicyHandle,
967 (PRPC_SID)TrustedDomainSid,
968 DesiredAccess,
969 (PLSAPR_HANDLE)TrustedDomainHandle);
970 }
971 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
972 {
973 Status = I_RpcMapWin32Status(RpcExceptionCode());
974 }
975 RpcEndExcept;
976
977 return Status;
978 }
979
980
981 /*
982 * @implemented
983 */
984 NTSTATUS
985 WINAPI
986 LsaOpenTrustedDomainByName(IN LSA_HANDLE PolicyHandle,
987 IN PLSA_UNICODE_STRING TrustedDomainName,
988 IN ACCESS_MASK DesiredAccess,
989 OUT PLSA_HANDLE TrustedDomainHandle)
990 {
991 NTSTATUS Status;
992
993 TRACE("LsaOpenTrustedDomainByName(%p %p 0x%08lx %p)\n",
994 PolicyHandle, TrustedDomainName, DesiredAccess, TrustedDomainHandle);
995
996 RpcTryExcept
997 {
998 Status = LsarOpenTrustedDomainByName((LSAPR_HANDLE)PolicyHandle,
999 (PRPC_UNICODE_STRING)TrustedDomainName,
1000 DesiredAccess,
1001 TrustedDomainHandle);
1002 }
1003 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1004 {
1005 Status = I_RpcMapWin32Status(RpcExceptionCode());
1006 }
1007 RpcEndExcept;
1008
1009 return Status;
1010 }
1011
1012
1013 /*
1014 * @unimplemented
1015 */
1016 NTSTATUS
1017 WINAPI
1018 LsaQueryDomainInformationPolicy(IN LSA_HANDLE PolicyHandle,
1019 IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
1020 OUT PVOID *Buffer)
1021 {
1022 FIXME("LsaQueryDomainInformationPolicy(%p %lu %p) stub\n",
1023 PolicyHandle, InformationClass, Buffer);
1024 return STATUS_NOT_IMPLEMENTED;
1025 }
1026
1027
1028 /*
1029 * @unimplemented
1030 */
1031 NTSTATUS
1032 WINAPI
1033 LsaQueryForestTrustInformation(IN LSA_HANDLE PolicyHandle,
1034 IN PLSA_UNICODE_STRING TrustedDomainName,
1035 OUT PLSA_FOREST_TRUST_INFORMATION *ForestTrustInfo)
1036 {
1037 FIXME("LsaQueryForestTrustInformation(%p %p %p) stub\n",
1038 PolicyHandle, TrustedDomainName, ForestTrustInfo);
1039 return STATUS_NOT_IMPLEMENTED;
1040 }
1041
1042
1043 /*
1044 * @unimplemented
1045 */
1046 NTSTATUS
1047 WINAPI
1048 LsaQueryInfoTrustedDomain(IN LSA_HANDLE TrustedDomainHandle,
1049 IN TRUSTED_INFORMATION_CLASS InformationClass,
1050 OUT PVOID *Buffer)
1051 {
1052 FIXME("LsaQueryInfoTrustedDomain(%p %d %p) stub\n",
1053 TrustedDomainHandle, InformationClass, Buffer);
1054 return STATUS_NOT_IMPLEMENTED;
1055 }
1056
1057
1058 /*
1059 * @implemented
1060 */
1061 NTSTATUS
1062 WINAPI
1063 LsaQueryInformationPolicy(IN LSA_HANDLE PolicyHandle,
1064 IN POLICY_INFORMATION_CLASS InformationClass,
1065 OUT PVOID *Buffer)
1066 {
1067 PLSAPR_POLICY_INFORMATION PolicyInformation = NULL;
1068 NTSTATUS Status;
1069
1070 TRACE("LsaQueryInformationPolicy(%p %d %p)\n",
1071 PolicyHandle, InformationClass, Buffer);
1072
1073 RpcTryExcept
1074 {
1075 Status = LsarQueryInformationPolicy((LSAPR_HANDLE)PolicyHandle,
1076 InformationClass,
1077 &PolicyInformation);
1078 *Buffer = PolicyInformation;
1079 }
1080 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1081 {
1082 if (PolicyInformation != NULL)
1083 MIDL_user_free(PolicyInformation);
1084
1085 Status = I_RpcMapWin32Status(RpcExceptionCode());
1086 }
1087 RpcEndExcept;
1088
1089 TRACE("Done (Status: 0x%08x)\n", Status);
1090
1091 return Status;
1092 }
1093
1094
1095 /*
1096 * @unimplemented
1097 */
1098 NTSTATUS
1099 WINAPI
1100 LsaQuerySecret(IN LSA_HANDLE SecretHandle,
1101 OUT PLSA_UNICODE_STRING *CurrentValue OPTIONAL,
1102 OUT PLARGE_INTEGER CurrentValueSetTime OPTIONAL,
1103 OUT PLSA_UNICODE_STRING *OldValue OPTIONAL,
1104 OUT PLARGE_INTEGER OldValueSetTime OPTIONAL)
1105 {
1106 PLSAPR_CR_CIPHER_VALUE EncryptedCurrentValue = NULL;
1107 PLSAPR_CR_CIPHER_VALUE EncryptedOldValue = NULL;
1108 PLSA_UNICODE_STRING DecryptedCurrentValue = NULL;
1109 PLSA_UNICODE_STRING DecryptedOldValue = NULL;
1110 SIZE_T BufferSize;
1111 NTSTATUS Status;
1112
1113 TRACE("LsaQuerySecret(%p %p %p %p %p)\n",
1114 SecretHandle, CurrentValue, CurrentValueSetTime,
1115 OldValue, OldValueSetTime);
1116
1117 RpcTryExcept
1118 {
1119 Status = LsarQuerySecret((PLSAPR_HANDLE)SecretHandle,
1120 &EncryptedCurrentValue,
1121 CurrentValueSetTime,
1122 &EncryptedOldValue,
1123 OldValueSetTime);
1124 }
1125 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1126 {
1127 Status = I_RpcMapWin32Status(RpcExceptionCode());
1128 }
1129 RpcEndExcept;
1130
1131 if (!NT_SUCCESS(Status))
1132 goto done;
1133
1134 /* Decrypt the current value */
1135 if (CurrentValue != NULL)
1136 {
1137 if (EncryptedCurrentValue == NULL)
1138 {
1139 *CurrentValue = NULL;
1140 }
1141 else
1142 {
1143 /* FIXME: Decrypt the current value */
1144 BufferSize = sizeof(LSA_UNICODE_STRING) + EncryptedCurrentValue->MaximumLength;
1145 DecryptedCurrentValue = midl_user_allocate(BufferSize);
1146 if (DecryptedCurrentValue == NULL)
1147 {
1148 Status = STATUS_INSUFFICIENT_RESOURCES;
1149 goto done;
1150 }
1151
1152 DecryptedCurrentValue->Length = (USHORT)EncryptedCurrentValue->Length;
1153 DecryptedCurrentValue->MaximumLength = (USHORT)EncryptedCurrentValue->MaximumLength;
1154 DecryptedCurrentValue->Buffer = (PWSTR)(DecryptedCurrentValue + 1);
1155 RtlCopyMemory(DecryptedCurrentValue->Buffer,
1156 EncryptedCurrentValue->Buffer,
1157 EncryptedCurrentValue->Length);
1158
1159 *CurrentValue = DecryptedCurrentValue;
1160 }
1161 }
1162
1163 /* Decrypt the old value */
1164 if (OldValue != NULL)
1165 {
1166 if (EncryptedOldValue == NULL)
1167 {
1168 *OldValue = NULL;
1169 }
1170 else
1171 {
1172 /* FIXME: Decrypt the old value */
1173 BufferSize = sizeof(LSA_UNICODE_STRING) + EncryptedOldValue->MaximumLength;
1174 DecryptedOldValue = midl_user_allocate(BufferSize);
1175 if (DecryptedOldValue == NULL)
1176 {
1177 Status = STATUS_INSUFFICIENT_RESOURCES;
1178 goto done;
1179 }
1180
1181 DecryptedOldValue->Length = (USHORT)EncryptedOldValue->Length;
1182 DecryptedOldValue->MaximumLength = (USHORT)EncryptedOldValue->MaximumLength;
1183 DecryptedOldValue->Buffer = (PWSTR)(DecryptedOldValue + 1);
1184 RtlCopyMemory(DecryptedOldValue->Buffer,
1185 EncryptedOldValue->Buffer,
1186 EncryptedOldValue->Length);
1187
1188 *OldValue = DecryptedOldValue;
1189 }
1190 }
1191
1192 done:
1193 if (!NT_SUCCESS(Status))
1194 {
1195 if (DecryptedCurrentValue != NULL)
1196 midl_user_free(DecryptedCurrentValue);
1197
1198 if (DecryptedOldValue != NULL)
1199 midl_user_free(DecryptedOldValue);
1200
1201 if (CurrentValue != NULL)
1202 *CurrentValue = NULL;
1203
1204 if (OldValue != NULL)
1205 *OldValue = NULL;
1206 }
1207
1208 if (EncryptedCurrentValue != NULL)
1209 midl_user_free(EncryptedCurrentValue);
1210
1211 if (EncryptedOldValue != NULL)
1212 midl_user_free(EncryptedOldValue);
1213
1214 return Status;
1215 }
1216
1217
1218 /*
1219 * @unimplemented
1220 */
1221 NTSTATUS
1222 WINAPI
1223 LsaQueryTrustedDomainInfo(IN LSA_HANDLE PolicyHandle,
1224 IN PSID TrustedDomainSid,
1225 IN TRUSTED_INFORMATION_CLASS InformationClass,
1226 OUT PVOID *Buffer)
1227 {
1228 FIXME("LsaQueryTrustedDomainInfo(%p %p %d %p) stub\n",
1229 PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
1230 return STATUS_OBJECT_NAME_NOT_FOUND;
1231 }
1232
1233
1234 /*
1235 * @implemented
1236 */
1237 NTSTATUS
1238 WINAPI
1239 LsaQueryTrustedDomainInfoByName(IN LSA_HANDLE PolicyHandle,
1240 IN PLSA_UNICODE_STRING TrustedDomainName,
1241 IN TRUSTED_INFORMATION_CLASS InformationClass,
1242 OUT PVOID *Buffer)
1243 {
1244 NTSTATUS Status;
1245
1246 TRACE("LsaQueryTrustedDomainInfoByName(%p %p %d %p)\n",
1247 PolicyHandle, TrustedDomainName, InformationClass, Buffer);
1248
1249 if (InformationClass == TrustedDomainAuthInformationInternal ||
1250 InformationClass == TrustedDomainFullInformationInternal)
1251 return STATUS_INVALID_INFO_CLASS;
1252
1253 RpcTryExcept
1254 {
1255 Status = LsarQueryTrustedDomainInfoByName((LSAPR_HANDLE)PolicyHandle,
1256 (PRPC_UNICODE_STRING)TrustedDomainName,
1257 InformationClass,
1258 (unsigned long *)Buffer); // Shuld be: (PLSAPR_POLICY_INFORMATION *)Buffer
1259 }
1260 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1261 {
1262 Status = I_RpcMapWin32Status(RpcExceptionCode());
1263 }
1264 RpcEndExcept;
1265
1266 return Status;
1267 }
1268
1269
1270 /*
1271 * @unimplemented
1272 */
1273 NTSTATUS
1274 WINAPI
1275 LsaRegisterPolicyChangeNotification(IN POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
1276 IN HANDLE NotificationEventHandle)
1277 {
1278 FIXME("LsaRegisterPolicyChangeNotification(%d %p) stub\n",
1279 InformationClass, NotificationEventHandle);
1280 return STATUS_UNSUCCESSFUL;
1281 }
1282
1283
1284 /*
1285 * @implemented
1286 */
1287 NTSTATUS
1288 WINAPI
1289 LsaRemoveAccountRights(IN LSA_HANDLE PolicyHandle,
1290 IN PSID AccountSid,
1291 IN BOOLEAN AllRights,
1292 IN PLSA_UNICODE_STRING UserRights,
1293 IN ULONG CountOfRights)
1294 {
1295 LSAPR_USER_RIGHT_SET UserRightSet;
1296
1297 TRACE("LsaRemoveAccountRights(%p %p %d %p %lu)\n",
1298 PolicyHandle, AccountSid, AllRights, UserRights, CountOfRights);
1299
1300 UserRightSet.Entries = CountOfRights;
1301 UserRightSet.UserRights = (PRPC_UNICODE_STRING)UserRights;
1302
1303 RpcTryExcept
1304 {
1305 LsarRemoveAccountRights((LSAPR_HANDLE)PolicyHandle,
1306 (PRPC_SID)AccountSid,
1307 AllRights,
1308 &UserRightSet);
1309 }
1310 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1311 {
1312 I_RpcMapWin32Status(RpcExceptionCode());
1313 }
1314 RpcEndExcept;
1315
1316 return STATUS_SUCCESS;
1317 }
1318
1319
1320 /*
1321 * @unimplemented
1322 */
1323 NTSTATUS
1324 WINAPI
1325 LsaRetrievePrivateData(IN LSA_HANDLE PolicyHandle,
1326 IN PLSA_UNICODE_STRING KeyName,
1327 OUT PLSA_UNICODE_STRING *PrivateData)
1328 {
1329 FIXME("LsaRetrievePrivateData(%p %p %p) stub\n",
1330 PolicyHandle, KeyName, PrivateData);
1331 return STATUS_OBJECT_NAME_NOT_FOUND;
1332 }
1333
1334
1335 /*
1336 * @unimplemented
1337 */
1338 NTSTATUS
1339 WINAPI
1340 LsaSetDomainInformationPolicy(IN LSA_HANDLE PolicyHandle,
1341 IN POLICY_DOMAIN_INFORMATION_CLASS InformationClass,
1342 IN PVOID Buffer OPTIONAL)
1343 {
1344 FIXME("LsaSetDomainInformationPolicy(%p %d %p) stub\n",
1345 PolicyHandle, InformationClass, Buffer);
1346 return STATUS_UNSUCCESSFUL;
1347 }
1348
1349
1350 /*
1351 * @unimplemented
1352 */
1353 NTSTATUS
1354 WINAPI
1355 LsaSetForestTrustInformation(IN LSA_HANDLE PolicyHandle,
1356 IN PLSA_UNICODE_STRING TrustedDomainName,
1357 IN PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo,
1358 IN BOOL CheckOnly,
1359 OUT PLSA_FOREST_TRUST_COLLISION_INFORMATION *CollisionInfo)
1360 {
1361 FIXME("LsaSetForestTrustInformation(%p %p %p %d %p) stub\n",
1362 PolicyHandle, TrustedDomainName, ForestTrustInfo, CheckOnly, CollisionInfo);
1363 return STATUS_NOT_IMPLEMENTED;
1364 }
1365
1366
1367 /*
1368 * @implemented
1369 */
1370 NTSTATUS
1371 WINAPI
1372 LsaSetInformationPolicy(IN LSA_HANDLE PolicyHandle,
1373 IN POLICY_INFORMATION_CLASS InformationClass,
1374 IN PVOID Buffer)
1375 {
1376 NTSTATUS Status;
1377
1378 TRACE("LsaSetInformationPolicy(%p %d %p)\n",
1379 PolicyHandle, InformationClass, Buffer);
1380
1381 RpcTryExcept
1382 {
1383 Status = LsarSetInformationPolicy((LSAPR_HANDLE)PolicyHandle,
1384 InformationClass,
1385 (PLSAPR_POLICY_INFORMATION)Buffer);
1386 }
1387 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1388 {
1389 Status = I_RpcMapWin32Status(RpcExceptionCode());
1390 }
1391 RpcEndExcept;
1392
1393 return Status;
1394 }
1395
1396
1397 /*
1398 * @implemented
1399 */
1400 NTSTATUS
1401 WINAPI
1402 LsaSetSecret(IN LSA_HANDLE SecretHandle,
1403 IN PLSA_UNICODE_STRING CurrentValue OPTIONAL,
1404 IN PLSA_UNICODE_STRING OldValue OPTIONAL)
1405 {
1406 PLSAPR_CR_CIPHER_VALUE EncryptedCurrentValue = NULL;
1407 PLSAPR_CR_CIPHER_VALUE EncryptedOldValue = NULL;
1408 SIZE_T BufferSize;
1409 NTSTATUS Status;
1410
1411 TRACE("LsaSetSecret(%p %p %p)\n",
1412 SecretHandle, EncryptedCurrentValue, EncryptedOldValue);
1413
1414 if (CurrentValue != NULL)
1415 {
1416 BufferSize = sizeof(LSAPR_CR_CIPHER_VALUE) + CurrentValue->MaximumLength;
1417 EncryptedCurrentValue = midl_user_allocate(BufferSize);
1418 if (EncryptedCurrentValue == NULL)
1419 {
1420 Status = STATUS_INSUFFICIENT_RESOURCES;
1421 goto done;
1422 }
1423
1424 EncryptedCurrentValue->Length = CurrentValue->Length;
1425 EncryptedCurrentValue->MaximumLength = CurrentValue->MaximumLength;
1426 EncryptedCurrentValue->Buffer = (BYTE *)(EncryptedCurrentValue + 1);
1427 if (EncryptedCurrentValue->Buffer != NULL)
1428 memcpy(EncryptedCurrentValue->Buffer, CurrentValue->Buffer, CurrentValue->Length);
1429 }
1430
1431 if (OldValue != NULL)
1432 {
1433 BufferSize = sizeof(LSAPR_CR_CIPHER_VALUE) + OldValue->MaximumLength;
1434 EncryptedOldValue = midl_user_allocate(BufferSize);
1435 if (EncryptedOldValue == NULL)
1436 {
1437 Status = STATUS_INSUFFICIENT_RESOURCES;
1438 goto done;
1439 }
1440
1441 EncryptedOldValue->Length = OldValue->Length;
1442 EncryptedOldValue->MaximumLength = OldValue->MaximumLength;
1443 EncryptedOldValue->Buffer = (BYTE*)(EncryptedOldValue + 1);
1444 if (EncryptedOldValue->Buffer != NULL)
1445 memcpy(EncryptedOldValue->Buffer, OldValue->Buffer, OldValue->Length);
1446 }
1447
1448 RpcTryExcept
1449 {
1450 Status = LsarSetSecret((LSAPR_HANDLE)SecretHandle,
1451 EncryptedCurrentValue,
1452 EncryptedOldValue);
1453 }
1454 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1455 {
1456 Status = I_RpcMapWin32Status(RpcExceptionCode());
1457 }
1458 RpcEndExcept;
1459
1460 done:
1461 if (EncryptedCurrentValue != NULL)
1462 midl_user_free(EncryptedCurrentValue);
1463
1464 if (EncryptedOldValue != NULL)
1465 midl_user_free(EncryptedOldValue);
1466
1467 return Status;
1468 }
1469
1470
1471 /*
1472 * @implemented
1473 */
1474 NTSTATUS
1475 WINAPI
1476 LsaSetSystemAccessAccount(IN LSA_HANDLE AccountHandle,
1477 IN ULONG SystemAccess)
1478 {
1479 NTSTATUS Status;
1480
1481 TRACE("LsaSetSystemAccessAccount(%p 0x%lx)\n",
1482 AccountHandle, SystemAccess);
1483
1484 RpcTryExcept
1485 {
1486 Status = LsarSetSystemAccessAccount((LSAPR_HANDLE)AccountHandle,
1487 SystemAccess);
1488 }
1489 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1490 {
1491 Status = I_RpcMapWin32Status(RpcExceptionCode());
1492 }
1493 RpcEndExcept;
1494
1495 return Status;
1496 }
1497
1498
1499 /*
1500 * @unimplemented
1501 */
1502 NTSTATUS
1503 WINAPI
1504 LsaSetTrustedDomainInfoByName(IN LSA_HANDLE PolicyHandle,
1505 IN PLSA_UNICODE_STRING TrustedDomainName,
1506 IN TRUSTED_INFORMATION_CLASS InformationClass,
1507 IN PVOID Buffer)
1508 {
1509 FIXME("LsaSetTrustedDomainInfoByName(%p %p %d %p) stub\n",
1510 PolicyHandle, TrustedDomainName, InformationClass, Buffer);
1511 return STATUS_SUCCESS;
1512 }
1513
1514
1515 /*
1516 * @unimplemented
1517 */
1518 NTSTATUS
1519 WINAPI
1520 LsaSetTrustedDomainInformation(IN LSA_HANDLE PolicyHandle,
1521 IN PSID TrustedDomainSid,
1522 IN TRUSTED_INFORMATION_CLASS InformationClass,
1523 IN PVOID Buffer)
1524 {
1525 FIXME("LsaSetTrustedDomainInformation(%p %p %d %p) stub\n",
1526 PolicyHandle, TrustedDomainSid, InformationClass, Buffer);
1527 return STATUS_SUCCESS;
1528 }
1529
1530
1531 /*
1532 * @unimplemented
1533 */
1534 NTSTATUS
1535 WINAPI
1536 LsaStorePrivateData(IN LSA_HANDLE PolicyHandle,
1537 IN PLSA_UNICODE_STRING KeyName,
1538 IN PLSA_UNICODE_STRING PrivateData OPTIONAL)
1539 {
1540 FIXME("LsaStorePrivateData(%p %p %p) stub\n",
1541 PolicyHandle, KeyName, PrivateData);
1542 return STATUS_OBJECT_NAME_NOT_FOUND;
1543 }
1544
1545
1546 /*
1547 * @unimplemented
1548 */
1549 NTSTATUS
1550 WINAPI
1551 LsaUnregisterPolicyChangeNotification(IN POLICY_NOTIFICATION_INFORMATION_CLASS InformationClass,
1552 IN HANDLE NotificationEventHandle)
1553 {
1554 FIXME("(%d %p) stub\n",
1555 InformationClass, NotificationEventHandle);
1556 return STATUS_SUCCESS;
1557 }
1558
1559 /* EOF */