[LSASRV]
[reactos.git] / reactos / dll / win32 / lsasrv / lsarpc.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: Local Security Authority (LSA) Server
4 * FILE: reactos/dll/win32/lsasrv/lsarpc.h
5 * PURPOSE: RPC interface functions
6 *
7 * PROGRAMMERS: Eric Kohl
8 */
9
10 /* INCLUDES ****************************************************************/
11
12 #include "lsasrv.h"
13
14 WINE_DEFAULT_DEBUG_CHANNEL(lsasrv);
15
16
17 /* GLOBALS *****************************************************************/
18
19 static RTL_CRITICAL_SECTION PolicyHandleTableLock;
20
21
22 /* FUNCTIONS ***************************************************************/
23
24 VOID
25 LsarStartRpcServer(VOID)
26 {
27 RPC_STATUS Status;
28
29 RtlInitializeCriticalSection(&PolicyHandleTableLock);
30
31 TRACE("LsarStartRpcServer() called\n");
32
33 Status = RpcServerUseProtseqEpW(L"ncacn_np",
34 10,
35 L"\\pipe\\lsarpc",
36 NULL);
37 if (Status != RPC_S_OK)
38 {
39 WARN("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
40 return;
41 }
42
43 Status = RpcServerRegisterIf(lsarpc_v0_0_s_ifspec,
44 NULL,
45 NULL);
46 if (Status != RPC_S_OK)
47 {
48 WARN("RpcServerRegisterIf() failed (Status %lx)\n", Status);
49 return;
50 }
51
52 Status = RpcServerListen(1, 20, TRUE);
53 if (Status != RPC_S_OK)
54 {
55 WARN("RpcServerListen() failed (Status %lx)\n", Status);
56 return;
57 }
58
59 TRACE("LsarStartRpcServer() done\n");
60 }
61
62
63 void __RPC_USER LSAPR_HANDLE_rundown(LSAPR_HANDLE hHandle)
64 {
65
66 }
67
68
69 /* Function 0 */
70 NTSTATUS WINAPI LsarClose(
71 LSAPR_HANDLE *ObjectHandle)
72 {
73 PLSA_DB_OBJECT DbObject;
74 NTSTATUS Status = STATUS_SUCCESS;
75
76 TRACE("0x%p\n", ObjectHandle);
77
78 // RtlEnterCriticalSection(&PolicyHandleTableLock);
79
80 Status = LsapValidateDbObject(*ObjectHandle,
81 LsaDbIgnoreObject,
82 0,
83 &DbObject);
84 if (Status == STATUS_SUCCESS)
85 {
86 Status = LsapCloseDbObject(DbObject);
87 *ObjectHandle = NULL;
88 }
89
90 // RtlLeaveCriticalSection(&PolicyHandleTableLock);
91
92 return Status;
93 }
94
95
96 /* Function 1 */
97 NTSTATUS WINAPI LsarDelete(
98 LSAPR_HANDLE ObjectHandle)
99 {
100 /* Deprecated */
101 return STATUS_NOT_SUPPORTED;
102 }
103
104
105 /* Function 2 */
106 NTSTATUS WINAPI LsarEnumeratePrivileges(
107 LSAPR_HANDLE PolicyHandle,
108 DWORD *EnumerationContext,
109 PLSAPR_PRIVILEGE_ENUM_BUFFER EnumerationBuffer,
110 DWORD PreferedMaximumLength)
111 {
112 PLSA_DB_OBJECT PolicyObject;
113 NTSTATUS Status;
114
115 TRACE("LsarEnumeratePrivileges(%p %p %p %lu)\n",
116 PolicyHandle, EnumerationContext, EnumerationBuffer,
117 PreferedMaximumLength);
118
119 Status = LsapValidateDbObject(PolicyHandle,
120 LsaDbPolicyObject,
121 POLICY_VIEW_LOCAL_INFORMATION,
122 &PolicyObject);
123 if (!NT_SUCCESS(Status))
124 return Status;
125
126 if (EnumerationContext == NULL)
127 return STATUS_INVALID_PARAMETER;
128
129 return LsarpEnumeratePrivileges(EnumerationContext,
130 EnumerationBuffer,
131 PreferedMaximumLength);
132 }
133
134
135 /* Function 3 */
136 NTSTATUS WINAPI LsarQuerySecurityObject(
137 LSAPR_HANDLE ObjectHandle,
138 SECURITY_INFORMATION SecurityInformation,
139 PLSAPR_SR_SECURITY_DESCRIPTOR *SecurityDescriptor)
140 {
141 PLSA_DB_OBJECT DbObject = NULL;
142 PSECURITY_DESCRIPTOR RelativeSd = NULL;
143 PLSAPR_SR_SECURITY_DESCRIPTOR SdData = NULL;
144 ACCESS_MASK DesiredAccess = 0;
145 ULONG RelativeSdSize = 0;
146 NTSTATUS Status;
147
148 if (SecurityDescriptor == NULL)
149 return STATUS_INVALID_PARAMETER;
150
151 if ((SecurityInformation & OWNER_SECURITY_INFORMATION) ||
152 (SecurityInformation & GROUP_SECURITY_INFORMATION) ||
153 (SecurityInformation & DACL_SECURITY_INFORMATION))
154 DesiredAccess |= READ_CONTROL;
155
156 if (SecurityInformation & SACL_SECURITY_INFORMATION)
157 DesiredAccess |= ACCESS_SYSTEM_SECURITY;
158
159 /* Validate the ObjectHandle */
160 Status = LsapValidateDbObject(ObjectHandle,
161 LsaDbIgnoreObject,
162 DesiredAccess,
163 &DbObject);
164 if (!NT_SUCCESS(Status))
165 return Status;
166
167 /* Get the size of the SD */
168 Status = LsapGetObjectAttribute(DbObject,
169 L"SecDesc",
170 NULL,
171 &RelativeSdSize);
172 if (!NT_SUCCESS(Status))
173 return Status;
174
175 /* Allocate a buffer for the SD */
176 RelativeSd = MIDL_user_allocate(RelativeSdSize);
177 if (RelativeSd == NULL)
178 return STATUS_INSUFFICIENT_RESOURCES;
179
180 /* Get the SD */
181 Status = LsapGetObjectAttribute(DbObject,
182 L"SecDesc",
183 RelativeSd,
184 &RelativeSdSize);
185 if (!NT_SUCCESS(Status))
186 goto done;
187
188 /*
189 * FIXME: Invalidate the SD information that was not requested.
190 * (see SecurityInformation)
191 */
192
193 /* Allocate the SD data buffer */
194 SdData = MIDL_user_allocate(sizeof(LSAPR_SR_SECURITY_DESCRIPTOR));
195 if (SdData == NULL)
196 {
197 Status = STATUS_INSUFFICIENT_RESOURCES;
198 goto done;
199 }
200
201 /* Fill the SD data buffer and return it to the caller */
202 SdData->Length = RelativeSdSize;
203 SdData->SecurityDescriptor = (PBYTE)RelativeSd;
204
205 *SecurityDescriptor = SdData;
206
207 done:
208 if (!NT_SUCCESS(Status))
209 {
210 if (RelativeSd != NULL)
211 MIDL_user_free(RelativeSd);
212 }
213
214 return Status;
215 }
216
217
218 /* Function 4 */
219 NTSTATUS WINAPI LsarSetSecurityObject(
220 LSAPR_HANDLE ObjectHandle,
221 SECURITY_INFORMATION SecurityInformation,
222 PLSAPR_SR_SECURITY_DESCRIPTOR SecurityDescriptor)
223 {
224 UNIMPLEMENTED;
225 return STATUS_NOT_IMPLEMENTED;
226 }
227
228
229 /* Function 5 */
230 NTSTATUS WINAPI LsarChangePassword(
231 handle_t IDL_handle,
232 PRPC_UNICODE_STRING String1,
233 PRPC_UNICODE_STRING String2,
234 PRPC_UNICODE_STRING String3,
235 PRPC_UNICODE_STRING String4,
236 PRPC_UNICODE_STRING String5)
237 {
238 /* Deprecated */
239 return STATUS_NOT_IMPLEMENTED;
240 }
241
242
243 /* Function 6 */
244 NTSTATUS WINAPI LsarOpenPolicy(
245 LPWSTR SystemName,
246 PLSAPR_OBJECT_ATTRIBUTES ObjectAttributes,
247 ACCESS_MASK DesiredAccess,
248 LSAPR_HANDLE *PolicyHandle)
249 {
250 PLSA_DB_OBJECT PolicyObject;
251 NTSTATUS Status;
252
253 TRACE("LsarOpenPolicy called!\n");
254
255 RtlEnterCriticalSection(&PolicyHandleTableLock);
256
257 Status = LsapOpenDbObject(NULL,
258 NULL,
259 L"Policy",
260 LsaDbPolicyObject,
261 DesiredAccess,
262 &PolicyObject);
263
264 RtlLeaveCriticalSection(&PolicyHandleTableLock);
265
266 if (NT_SUCCESS(Status))
267 *PolicyHandle = (LSAPR_HANDLE)PolicyObject;
268
269 TRACE("LsarOpenPolicy done!\n");
270
271 return Status;
272 }
273
274
275 /* Function 7 */
276 NTSTATUS WINAPI LsarQueryInformationPolicy(
277 LSAPR_HANDLE PolicyHandle,
278 POLICY_INFORMATION_CLASS InformationClass,
279 PLSAPR_POLICY_INFORMATION *PolicyInformation)
280 {
281 PLSA_DB_OBJECT DbObject;
282 ACCESS_MASK DesiredAccess = 0;
283 NTSTATUS Status;
284
285 TRACE("LsarQueryInformationPolicy(%p,0x%08x,%p)\n",
286 PolicyHandle, InformationClass, PolicyInformation);
287
288 if (PolicyInformation)
289 {
290 TRACE("*PolicyInformation %p\n", *PolicyInformation);
291 }
292
293 switch (InformationClass)
294 {
295 case PolicyAuditLogInformation:
296 case PolicyAuditEventsInformation:
297 case PolicyAuditFullQueryInformation:
298 DesiredAccess = POLICY_VIEW_AUDIT_INFORMATION;
299 break;
300
301 case PolicyPrimaryDomainInformation:
302 case PolicyAccountDomainInformation:
303 case PolicyLsaServerRoleInformation:
304 case PolicyReplicaSourceInformation:
305 case PolicyDefaultQuotaInformation:
306 case PolicyModificationInformation:
307 case PolicyDnsDomainInformation:
308 case PolicyDnsDomainInformationInt:
309 case PolicyLocalAccountDomainInformation:
310 DesiredAccess = POLICY_VIEW_LOCAL_INFORMATION;
311 break;
312
313 case PolicyPdAccountInformation:
314 DesiredAccess = POLICY_GET_PRIVATE_INFORMATION;
315 break;
316
317 default:
318 ERR("Invalid InformationClass!\n");
319 return STATUS_INVALID_PARAMETER;
320 }
321
322 Status = LsapValidateDbObject(PolicyHandle,
323 LsaDbPolicyObject,
324 DesiredAccess,
325 &DbObject);
326 if (!NT_SUCCESS(Status))
327 return Status;
328
329 switch (InformationClass)
330 {
331 case PolicyAuditLogInformation: /* 1 */
332 Status = LsarQueryAuditLog(PolicyHandle,
333 PolicyInformation);
334 break;
335
336 case PolicyAuditEventsInformation: /* 2 */
337 Status = LsarQueryAuditEvents(PolicyHandle,
338 PolicyInformation);
339 break;
340
341 case PolicyPrimaryDomainInformation: /* 3 */
342 Status = LsarQueryPrimaryDomain(PolicyHandle,
343 PolicyInformation);
344 break;
345
346 case PolicyPdAccountInformation: /* 4 */
347 Status = LsarQueryPdAccount(PolicyHandle,
348 PolicyInformation);
349 break;
350
351 case PolicyAccountDomainInformation: /* 5 */
352 Status = LsarQueryAccountDomain(PolicyHandle,
353 PolicyInformation);
354 break;
355
356 case PolicyLsaServerRoleInformation: /* 6 */
357 Status = LsarQueryServerRole(PolicyHandle,
358 PolicyInformation);
359 break;
360
361 case PolicyReplicaSourceInformation: /* 7 */
362 Status = LsarQueryReplicaSource(PolicyHandle,
363 PolicyInformation);
364 break;
365
366 case PolicyDefaultQuotaInformation: /* 8 */
367 Status = LsarQueryDefaultQuota(PolicyHandle,
368 PolicyInformation);
369 break;
370
371 case PolicyModificationInformation: /* 9 */
372 Status = LsarQueryModification(PolicyHandle,
373 PolicyInformation);
374 break;
375
376 case PolicyAuditFullQueryInformation: /* 11 (0xB) */
377 Status = LsarQueryAuditFull(PolicyHandle,
378 PolicyInformation);
379 break;
380
381 case PolicyDnsDomainInformation: /* 12 (0xC) */
382 Status = LsarQueryDnsDomain(PolicyHandle,
383 PolicyInformation);
384 break;
385
386 case PolicyDnsDomainInformationInt: /* 13 (0xD) */
387 Status = LsarQueryDnsDomainInt(PolicyHandle,
388 PolicyInformation);
389 break;
390
391 case PolicyLocalAccountDomainInformation: /* 14 (0xE) */
392 Status = LsarQueryLocalAccountDomain(PolicyHandle,
393 PolicyInformation);
394 break;
395
396 default:
397 ERR("Invalid InformationClass!\n");
398 Status = STATUS_INVALID_PARAMETER;
399 }
400
401 return Status;
402 }
403
404
405 /* Function 8 */
406 NTSTATUS WINAPI LsarSetInformationPolicy(
407 LSAPR_HANDLE PolicyHandle,
408 POLICY_INFORMATION_CLASS InformationClass,
409 PLSAPR_POLICY_INFORMATION PolicyInformation)
410 {
411 PLSA_DB_OBJECT DbObject;
412 ACCESS_MASK DesiredAccess = 0;
413 NTSTATUS Status;
414
415 TRACE("LsarSetInformationPolicy(%p,0x%08x,%p)\n",
416 PolicyHandle, InformationClass, PolicyInformation);
417
418 if (PolicyInformation)
419 {
420 TRACE("*PolicyInformation %p\n", *PolicyInformation);
421 }
422
423 switch (InformationClass)
424 {
425 case PolicyAuditLogInformation:
426 case PolicyAuditFullSetInformation:
427 DesiredAccess = POLICY_AUDIT_LOG_ADMIN;
428 break;
429
430 case PolicyAuditEventsInformation:
431 DesiredAccess = POLICY_SET_AUDIT_REQUIREMENTS;
432 break;
433
434 case PolicyPrimaryDomainInformation:
435 case PolicyAccountDomainInformation:
436 case PolicyDnsDomainInformation:
437 case PolicyDnsDomainInformationInt:
438 case PolicyLocalAccountDomainInformation:
439 DesiredAccess = POLICY_TRUST_ADMIN;
440 break;
441
442 case PolicyLsaServerRoleInformation:
443 case PolicyReplicaSourceInformation:
444 DesiredAccess = POLICY_SERVER_ADMIN;
445 break;
446
447 case PolicyDefaultQuotaInformation:
448 DesiredAccess = POLICY_SET_DEFAULT_QUOTA_LIMITS;
449 break;
450
451 default:
452 ERR("Invalid InformationClass!\n");
453 return STATUS_INVALID_PARAMETER;
454 }
455
456 Status = LsapValidateDbObject(PolicyHandle,
457 LsaDbPolicyObject,
458 DesiredAccess,
459 &DbObject);
460 if (!NT_SUCCESS(Status))
461 return Status;
462
463 switch (InformationClass)
464 {
465 case PolicyAuditLogInformation: /* 1 */
466 Status = STATUS_NOT_IMPLEMENTED;
467 break;
468
469 case PolicyAuditEventsInformation: /* 2 */
470 Status = STATUS_NOT_IMPLEMENTED;
471 break;
472
473 case PolicyPrimaryDomainInformation: /* 3 */
474 Status = LsarSetPrimaryDomain(PolicyHandle,
475 (PLSAPR_POLICY_PRIMARY_DOM_INFO)PolicyInformation);
476 break;
477
478 case PolicyAccountDomainInformation: /* 5 */
479 Status = LsarSetAccountDomain(PolicyHandle,
480 (PLSAPR_POLICY_ACCOUNT_DOM_INFO)PolicyInformation);
481 break;
482
483 case PolicyLsaServerRoleInformation: /* 6 */
484 Status = STATUS_NOT_IMPLEMENTED;
485 break;
486
487 case PolicyReplicaSourceInformation: /* 7 */
488 Status = STATUS_NOT_IMPLEMENTED;
489 break;
490
491 case PolicyDefaultQuotaInformation: /* 8 */
492 Status = STATUS_NOT_IMPLEMENTED;
493 break;
494
495 case PolicyModificationInformation: /* 9 */
496 Status = STATUS_NOT_IMPLEMENTED;
497 break;
498
499 case PolicyAuditFullSetInformation: /* 10 (0xA) */
500 Status = STATUS_NOT_IMPLEMENTED;
501 break;
502
503 case PolicyDnsDomainInformation: /* 12 (0xC) */
504 Status = LsarSetDnsDomain(PolicyHandle,
505 (PLSAPR_POLICY_DNS_DOMAIN_INFO)PolicyInformation);
506 break;
507
508 case PolicyDnsDomainInformationInt: /* 13 (0xD) */
509 Status = STATUS_NOT_IMPLEMENTED;
510 break;
511
512 case PolicyLocalAccountDomainInformation: /* 14 (0xE) */
513 Status = STATUS_NOT_IMPLEMENTED;
514 break;
515
516 default:
517 Status = STATUS_INVALID_PARAMETER;
518 break;
519 }
520
521 return Status;
522 }
523
524
525 /* Function 9 */
526 NTSTATUS WINAPI LsarClearAuditLog(
527 LSAPR_HANDLE ObjectHandle)
528 {
529 /* Deprecated */
530 return STATUS_NOT_IMPLEMENTED;
531 }
532
533
534 /* Function 10 */
535 NTSTATUS WINAPI LsarCreateAccount(
536 LSAPR_HANDLE PolicyHandle,
537 PRPC_SID AccountSid,
538 ACCESS_MASK DesiredAccess,
539 LSAPR_HANDLE *AccountHandle)
540 {
541 PLSA_DB_OBJECT PolicyObject;
542 PLSA_DB_OBJECT AccountObject = NULL;
543 LPWSTR SidString = NULL;
544 PSECURITY_DESCRIPTOR AccountSd = NULL;
545 ULONG AccountSdSize;
546 NTSTATUS Status = STATUS_SUCCESS;
547
548 /* Validate the AccountSid */
549 if (!RtlValidSid(AccountSid))
550 return STATUS_INVALID_PARAMETER;
551
552 /* Validate the PolicyHandle */
553 Status = LsapValidateDbObject(PolicyHandle,
554 LsaDbPolicyObject,
555 POLICY_CREATE_ACCOUNT,
556 &PolicyObject);
557 if (!NT_SUCCESS(Status))
558 {
559 ERR("LsapValidateDbObject returned 0x%08lx\n", Status);
560 return Status;
561 }
562
563 /* Create SID string */
564 if (!ConvertSidToStringSid((PSID)AccountSid,
565 &SidString))
566 {
567 ERR("ConvertSidToStringSid failed\n");
568 Status = STATUS_INVALID_PARAMETER;
569 goto done;
570 }
571
572 /* Create a security descriptor for the account */
573 Status = LsapCreateAccountSd(&AccountSd,
574 &AccountSdSize);
575 if (!NT_SUCCESS(Status))
576 {
577 ERR("LsapCreateAccountSd returned 0x%08lx\n", Status);
578 return Status;
579 }
580
581 /* Create the Account object */
582 Status = LsapCreateDbObject(PolicyObject,
583 L"Accounts",
584 SidString,
585 LsaDbAccountObject,
586 DesiredAccess,
587 &AccountObject);
588 if (!NT_SUCCESS(Status))
589 {
590 ERR("LsapCreateDbObject failed (Status 0x%08lx)\n", Status);
591 goto done;
592 }
593
594 /* Set the Sid attribute */
595 Status = LsapSetObjectAttribute(AccountObject,
596 L"Sid",
597 (PVOID)AccountSid,
598 GetLengthSid(AccountSid));
599 if (!NT_SUCCESS(Status))
600 goto done;
601
602 /* Set the SecDesc attribute */
603 Status = LsapSetObjectAttribute(AccountObject,
604 L"SecDesc",
605 AccountSd,
606 AccountSdSize);
607
608 done:
609 if (SidString != NULL)
610 LocalFree(SidString);
611
612 if (AccountSd != NULL)
613 RtlFreeHeap(RtlGetProcessHeap(), 0, AccountSd);
614
615 if (!NT_SUCCESS(Status))
616 {
617 if (AccountObject != NULL)
618 LsapCloseDbObject(AccountObject);
619 }
620 else
621 {
622 *AccountHandle = (LSAPR_HANDLE)AccountObject;
623 }
624
625 return STATUS_SUCCESS;
626 }
627
628
629 /* Function 11 */
630 NTSTATUS WINAPI LsarEnumerateAccounts(
631 LSAPR_HANDLE PolicyHandle,
632 DWORD *EnumerationContext,
633 PLSAPR_ACCOUNT_ENUM_BUFFER EnumerationBuffer,
634 DWORD PreferedMaximumLength)
635 {
636 UNIMPLEMENTED;
637 return STATUS_NOT_IMPLEMENTED;
638 }
639
640
641 /* Function 12 */
642 NTSTATUS WINAPI LsarCreateTrustedDomain(
643 LSAPR_HANDLE PolicyHandle,
644 PLSAPR_TRUST_INFORMATION TrustedDomainInformation,
645 ACCESS_MASK DesiredAccess,
646 LSAPR_HANDLE *TrustedDomainHandle)
647 {
648 UNIMPLEMENTED;
649 return STATUS_NOT_IMPLEMENTED;
650 }
651
652
653 /* Function 13 */
654 NTSTATUS WINAPI LsarEnumerateTrustedDomains(
655 LSAPR_HANDLE PolicyHandle,
656 DWORD *EnumerationContext,
657 PLSAPR_TRUSTED_ENUM_BUFFER EnumerationBuffer,
658 DWORD PreferedMaximumLength)
659 {
660 UNIMPLEMENTED;
661 return STATUS_NOT_IMPLEMENTED;
662 }
663
664
665 /* Function 14 */
666 NTSTATUS WINAPI LsarLookupNames(
667 LSAPR_HANDLE PolicyHandle,
668 DWORD Count,
669 PRPC_UNICODE_STRING Names,
670 PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains,
671 PLSAPR_TRANSLATED_SIDS TranslatedSids,
672 LSAP_LOOKUP_LEVEL LookupLevel,
673 DWORD *MappedCount)
674 {
675 LSAPR_TRANSLATED_SIDS_EX2 TranslatedSidsEx2;
676 ULONG i;
677 NTSTATUS Status;
678
679 TRACE("(%p %lu %p %p %p %d %p)\n",
680 PolicyHandle, Count, Names, ReferencedDomains, TranslatedSids,
681 LookupLevel, MappedCount);
682
683 TranslatedSids->Entries = 0;
684 TranslatedSids->Sids = NULL;
685 *ReferencedDomains = NULL;
686
687 if (Count == 0)
688 return STATUS_NONE_MAPPED;
689
690 TranslatedSidsEx2.Entries = 0;
691 TranslatedSidsEx2.Sids = NULL;
692
693 Status = LsapLookupNames(Count,
694 Names,
695 ReferencedDomains,
696 &TranslatedSidsEx2,
697 LookupLevel,
698 MappedCount,
699 0,
700 0);
701 if (!NT_SUCCESS(Status))
702 return Status;
703
704 TranslatedSids->Entries = TranslatedSidsEx2.Entries;
705 TranslatedSids->Sids = MIDL_user_allocate(TranslatedSids->Entries * sizeof(LSA_TRANSLATED_SID));
706 if (TranslatedSids->Sids == NULL)
707 {
708 MIDL_user_free(TranslatedSidsEx2.Sids);
709 MIDL_user_free(*ReferencedDomains);
710 *ReferencedDomains = NULL;
711 return STATUS_INSUFFICIENT_RESOURCES;
712 }
713
714 for (i = 0; i < TranslatedSidsEx2.Entries; i++)
715 {
716 TranslatedSids->Sids[i].Use = TranslatedSidsEx2.Sids[i].Use;
717 TranslatedSids->Sids[i].RelativeId = LsapGetRelativeIdFromSid(TranslatedSidsEx2.Sids[i].Sid);
718 TranslatedSids->Sids[i].DomainIndex = TranslatedSidsEx2.Sids[i].DomainIndex;
719 }
720
721 MIDL_user_free(TranslatedSidsEx2.Sids);
722
723 return STATUS_SUCCESS;
724 }
725
726
727 /* Function 15 */
728 NTSTATUS WINAPI LsarLookupSids(
729 LSAPR_HANDLE PolicyHandle,
730 PLSAPR_SID_ENUM_BUFFER SidEnumBuffer,
731 PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains,
732 PLSAPR_TRANSLATED_NAMES TranslatedNames,
733 LSAP_LOOKUP_LEVEL LookupLevel,
734 DWORD *MappedCount)
735 {
736 LSAPR_TRANSLATED_NAMES_EX TranslatedNamesEx;
737 ULONG i;
738 NTSTATUS Status;
739
740 TRACE("(%p %p %p %p %d %p)\n",
741 PolicyHandle, SidEnumBuffer, ReferencedDomains, TranslatedNames,
742 LookupLevel, MappedCount);
743
744 /* FIXME: Fail, if there is an invalid SID in the SidEnumBuffer */
745
746 TranslatedNames->Entries = SidEnumBuffer->Entries;
747 TranslatedNames->Names = NULL;
748 *ReferencedDomains = NULL;
749
750 TranslatedNamesEx.Entries = SidEnumBuffer->Entries;
751 TranslatedNamesEx.Names = NULL;
752
753 Status = LsapLookupSids(SidEnumBuffer,
754 ReferencedDomains,
755 &TranslatedNamesEx,
756 LookupLevel,
757 MappedCount,
758 0,
759 0);
760 if (!NT_SUCCESS(Status))
761 return Status;
762
763 TranslatedNames->Entries = SidEnumBuffer->Entries;
764 TranslatedNames->Names = MIDL_user_allocate(SidEnumBuffer->Entries * sizeof(LSAPR_TRANSLATED_NAME));
765 if (TranslatedNames->Names == NULL)
766 {
767 MIDL_user_free(TranslatedNamesEx.Names);
768 MIDL_user_free(*ReferencedDomains);
769 *ReferencedDomains = NULL;
770 return STATUS_INSUFFICIENT_RESOURCES;
771 }
772
773 for (i = 0; i < TranslatedNamesEx.Entries; i++)
774 {
775 TranslatedNames->Names[i].Use = TranslatedNamesEx.Names[i].Use;
776 TranslatedNames->Names[i].Name.Length = TranslatedNamesEx.Names[i].Name.Length;
777 TranslatedNames->Names[i].Name.MaximumLength = TranslatedNamesEx.Names[i].Name.MaximumLength;
778 TranslatedNames->Names[i].Name.Buffer = TranslatedNamesEx.Names[i].Name.Buffer;
779 TranslatedNames->Names[i].DomainIndex = TranslatedNamesEx.Names[i].DomainIndex;
780 }
781
782 MIDL_user_free(TranslatedNamesEx.Names);
783
784 return Status;
785 }
786
787
788 /* Function 16 */
789 NTSTATUS WINAPI LsarCreateSecret(
790 LSAPR_HANDLE PolicyHandle,
791 PRPC_UNICODE_STRING SecretName,
792 ACCESS_MASK DesiredAccess,
793 LSAPR_HANDLE *SecretHandle)
794 {
795 PLSA_DB_OBJECT PolicyObject;
796 PLSA_DB_OBJECT SecretObject = NULL;
797 LARGE_INTEGER Time;
798 PSECURITY_DESCRIPTOR SecretSd = NULL;
799 ULONG SecretSdSize;
800 NTSTATUS Status = STATUS_SUCCESS;
801
802 /* Validate the PolicyHandle */
803 Status = LsapValidateDbObject(PolicyHandle,
804 LsaDbPolicyObject,
805 POLICY_CREATE_SECRET,
806 &PolicyObject);
807 if (!NT_SUCCESS(Status))
808 {
809 ERR("LsapValidateDbObject returned 0x%08lx\n", Status);
810 return Status;
811 }
812
813 /* Get the current time */
814 Status = NtQuerySystemTime(&Time);
815 if (!NT_SUCCESS(Status))
816 {
817 ERR("NtQuerySystemTime failed (Status 0x%08lx)\n", Status);
818 goto done;
819 }
820
821 /* Create a security descriptor for the secret */
822 Status = LsapCreateSecretSd(&SecretSd,
823 &SecretSdSize);
824 if (!NT_SUCCESS(Status))
825 {
826 ERR("LsapCreateAccountSd returned 0x%08lx\n", Status);
827 return Status;
828 }
829
830 /* Create the Secret object */
831 Status = LsapCreateDbObject(PolicyObject,
832 L"Secrets",
833 SecretName->Buffer,
834 LsaDbSecretObject,
835 DesiredAccess,
836 &SecretObject);
837 if (!NT_SUCCESS(Status))
838 {
839 ERR("LsapCreateDbObject failed (Status 0x%08lx)\n", Status);
840 goto done;
841 }
842
843 /* Set the CurrentTime attribute */
844 Status = LsapSetObjectAttribute(SecretObject,
845 L"CurrentTime",
846 (PVOID)&Time,
847 sizeof(LARGE_INTEGER));
848 if (!NT_SUCCESS(Status))
849 {
850 ERR("LsapSetObjectAttribute (CurrentTime) failed (Status 0x%08lx)\n", Status);
851 goto done;
852 }
853
854 /* Set the OldTime attribute */
855 Status = LsapSetObjectAttribute(SecretObject,
856 L"OldTime",
857 (PVOID)&Time,
858 sizeof(LARGE_INTEGER));
859 if (!NT_SUCCESS(Status))
860 {
861 ERR("LsapSetObjectAttribute (OldTime) failed (Status 0x%08lx)\n", Status);
862 goto done;
863 }
864
865 /* Set the SecDesc attribute */
866 Status = LsapSetObjectAttribute(SecretObject,
867 L"SecDesc",
868 SecretSd,
869 SecretSdSize);
870
871 done:
872 if (SecretSd != NULL)
873 RtlFreeHeap(RtlGetProcessHeap(), 0, SecretSd);
874
875 if (!NT_SUCCESS(Status))
876 {
877 if (SecretObject != NULL)
878 LsapCloseDbObject(SecretObject);
879 }
880 else
881 {
882 *SecretHandle = (LSAPR_HANDLE)SecretObject;
883 }
884
885 return STATUS_SUCCESS;
886 }
887
888
889 /* Function 17 */
890 NTSTATUS WINAPI LsarOpenAccount(
891 LSAPR_HANDLE PolicyHandle,
892 PRPC_SID AccountSid,
893 ACCESS_MASK DesiredAccess,
894 LSAPR_HANDLE *AccountHandle)
895 {
896 PLSA_DB_OBJECT PolicyObject;
897 PLSA_DB_OBJECT AccountObject = NULL;
898 LPWSTR SidString = NULL;
899 NTSTATUS Status = STATUS_SUCCESS;
900
901 /* Validate the AccountSid */
902 if (!RtlValidSid(AccountSid))
903 return STATUS_INVALID_PARAMETER;
904
905 /* Validate the PolicyHandle */
906 Status = LsapValidateDbObject(PolicyHandle,
907 LsaDbPolicyObject,
908 0,
909 &PolicyObject);
910 if (!NT_SUCCESS(Status))
911 {
912 ERR("LsapValidateDbObject returned 0x%08lx\n", Status);
913 return Status;
914 }
915
916 /* Create SID string */
917 if (!ConvertSidToStringSid((PSID)AccountSid,
918 &SidString))
919 {
920 ERR("ConvertSidToStringSid failed\n");
921 Status = STATUS_INVALID_PARAMETER;
922 goto done;
923 }
924
925 /* Create the Account object */
926 Status = LsapOpenDbObject(PolicyObject,
927 L"Accounts",
928 SidString,
929 LsaDbAccountObject,
930 DesiredAccess,
931 &AccountObject);
932 if (!NT_SUCCESS(Status))
933 {
934 ERR("LsapOpenDbObject failed (Status 0x%08lx)\n", Status);
935 goto done;
936 }
937
938 /* Set the Sid attribute */
939 Status = LsapSetObjectAttribute(AccountObject,
940 L"Sid",
941 (PVOID)AccountSid,
942 GetLengthSid(AccountSid));
943
944 done:
945 if (SidString != NULL)
946 LocalFree(SidString);
947
948 if (!NT_SUCCESS(Status))
949 {
950 if (AccountObject != NULL)
951 LsapCloseDbObject(AccountObject);
952 }
953 else
954 {
955 *AccountHandle = (LSAPR_HANDLE)AccountObject;
956 }
957
958 return Status;
959 }
960
961
962 /* Function 18 */
963 NTSTATUS WINAPI LsarEnumeratePrivilegesAccount(
964 LSAPR_HANDLE AccountHandle,
965 PLSAPR_PRIVILEGE_SET *Privileges)
966 {
967 PLSA_DB_OBJECT AccountObject;
968 ULONG PrivilegeSetSize = 0;
969 PLSAPR_PRIVILEGE_SET PrivilegeSet = NULL;
970 NTSTATUS Status;
971
972 *Privileges = NULL;
973
974 /* Validate the AccountHandle */
975 Status = LsapValidateDbObject(AccountHandle,
976 LsaDbAccountObject,
977 ACCOUNT_VIEW,
978 &AccountObject);
979 if (!NT_SUCCESS(Status))
980 {
981 ERR("LsapValidateDbObject returned 0x%08lx\n", Status);
982 return Status;
983 }
984
985 /* Get the size of the privilege set */
986 Status = LsapGetObjectAttribute(AccountObject,
987 L"Privilgs",
988 NULL,
989 &PrivilegeSetSize);
990 if (!NT_SUCCESS(Status))
991 return Status;
992
993 /* Allocate a buffer for the privilege set */
994 PrivilegeSet = MIDL_user_allocate(PrivilegeSetSize);
995 if (PrivilegeSet == NULL)
996 return STATUS_NO_MEMORY;
997
998 /* Get the privilege set */
999 Status = LsapGetObjectAttribute(AccountObject,
1000 L"Privilgs",
1001 PrivilegeSet,
1002 &PrivilegeSetSize);
1003 if (!NT_SUCCESS(Status))
1004 {
1005 MIDL_user_free(PrivilegeSet);
1006 return Status;
1007 }
1008
1009 /* Return a pointer to the privilege set */
1010 *Privileges = PrivilegeSet;
1011
1012 return STATUS_SUCCESS;
1013 }
1014
1015
1016 /* Function 19 */
1017 NTSTATUS WINAPI LsarAddPrivilegesToAccount(
1018 LSAPR_HANDLE AccountHandle,
1019 PLSAPR_PRIVILEGE_SET Privileges)
1020 {
1021 PLSA_DB_OBJECT AccountObject;
1022 PPRIVILEGE_SET CurrentPrivileges = NULL;
1023 PPRIVILEGE_SET NewPrivileges = NULL;
1024 ULONG PrivilegeSetSize = 0;
1025 ULONG PrivilegeCount;
1026 ULONG i, j;
1027 BOOL bFound;
1028 NTSTATUS Status;
1029
1030 /* Validate the AccountHandle */
1031 Status = LsapValidateDbObject(AccountHandle,
1032 LsaDbAccountObject,
1033 ACCOUNT_ADJUST_PRIVILEGES,
1034 &AccountObject);
1035 if (!NT_SUCCESS(Status))
1036 {
1037 ERR("LsapValidateDbObject returned 0x%08lx\n", Status);
1038 return Status;
1039 }
1040
1041 Status = LsapGetObjectAttribute(AccountObject,
1042 L"Privilgs",
1043 NULL,
1044 &PrivilegeSetSize);
1045 if (!NT_SUCCESS(Status) || PrivilegeSetSize == 0)
1046 {
1047 /* The Privilgs attribute does not exist */
1048
1049 PrivilegeSetSize = sizeof(PRIVILEGE_SET) +
1050 (Privileges->PrivilegeCount - 1) * sizeof(LUID_AND_ATTRIBUTES);
1051 Status = LsapSetObjectAttribute(AccountObject,
1052 L"Privilgs",
1053 Privileges,
1054 PrivilegeSetSize);
1055 }
1056 else
1057 {
1058 /* The Privilgs attribute exists */
1059
1060 /* Allocate memory for the stored privilege set */
1061 CurrentPrivileges = MIDL_user_allocate(PrivilegeSetSize);
1062 if (CurrentPrivileges == NULL)
1063 return STATUS_NO_MEMORY;
1064
1065 /* Get the current privilege set */
1066 Status = LsapGetObjectAttribute(AccountObject,
1067 L"Privilgs",
1068 CurrentPrivileges,
1069 &PrivilegeSetSize);
1070 if (!NT_SUCCESS(Status))
1071 {
1072 TRACE("LsapGetObjectAttribute() failed (Status 0x%08lx)\n", Status);
1073 goto done;
1074 }
1075
1076 PrivilegeCount = CurrentPrivileges->PrivilegeCount;
1077 TRACE("Current privilege count: %lu\n", PrivilegeCount);
1078
1079 /* Calculate the number privileges in the combined privilege set */
1080 for (i = 0; i < Privileges->PrivilegeCount; i++)
1081 {
1082 bFound = FALSE;
1083 for (j = 0; j < CurrentPrivileges->PrivilegeCount; j++)
1084 {
1085 if (RtlEqualLuid(&(Privileges->Privilege[i].Luid),
1086 &(CurrentPrivileges->Privilege[i].Luid)))
1087 {
1088 bFound = TRUE;
1089 break;
1090 }
1091 }
1092
1093 if (bFound == FALSE)
1094 {
1095 TRACE("Found new privilege\n");
1096 PrivilegeCount++;
1097 }
1098 }
1099 TRACE("New privilege count: %lu\n", PrivilegeCount);
1100
1101 /* Calculate the size of the new privilege set and allocate it */
1102 PrivilegeSetSize = sizeof(PRIVILEGE_SET) +
1103 (PrivilegeCount - 1) * sizeof(LUID_AND_ATTRIBUTES);
1104 NewPrivileges = MIDL_user_allocate(PrivilegeSetSize);
1105 if (NewPrivileges == NULL)
1106 {
1107 Status = STATUS_NO_MEMORY;
1108 goto done;
1109 }
1110
1111 /* Initialize the new privilege set */
1112 NewPrivileges->PrivilegeCount = PrivilegeCount;
1113 NewPrivileges->Control = 0;
1114
1115 /* Copy all privileges from the current privilege set */
1116 RtlCopyLuidAndAttributesArray(CurrentPrivileges->PrivilegeCount,
1117 &(CurrentPrivileges->Privilege[0]),
1118 &(NewPrivileges->Privilege[0]));
1119
1120 /* Add new privileges to the new privilege set */
1121 PrivilegeCount = CurrentPrivileges->PrivilegeCount;
1122 for (i = 0; i < Privileges->PrivilegeCount; i++)
1123 {
1124 bFound = FALSE;
1125 for (j = 0; j < CurrentPrivileges->PrivilegeCount; j++)
1126 {
1127 if (RtlEqualLuid(&(Privileges->Privilege[i].Luid),
1128 &(CurrentPrivileges->Privilege[i].Luid)))
1129 {
1130 /* Overwrite attributes if a matching privilege was found */
1131 NewPrivileges->Privilege[j].Attributes = Privileges->Privilege[i].Attributes;
1132
1133 bFound = TRUE;
1134 break;
1135 }
1136 }
1137
1138 if (bFound == FALSE)
1139 {
1140 /* Copy the new privilege */
1141 RtlCopyLuidAndAttributesArray(1,
1142 (PLUID_AND_ATTRIBUTES)&(Privileges->Privilege[i]),
1143 &(NewPrivileges->Privilege[PrivilegeCount]));
1144 PrivilegeCount++;
1145 }
1146 }
1147
1148 /* Set the new priivliege set */
1149 Status = LsapSetObjectAttribute(AccountObject,
1150 L"Privilgs",
1151 NewPrivileges,
1152 PrivilegeSetSize);
1153 }
1154
1155 done:
1156 if (CurrentPrivileges != NULL)
1157 MIDL_user_free(CurrentPrivileges);
1158
1159 if (NewPrivileges != NULL)
1160 MIDL_user_free(NewPrivileges);
1161
1162 return Status;
1163 }
1164
1165
1166 /* Function 20 */
1167 NTSTATUS WINAPI LsarRemovePrivilegesFromAccount(
1168 LSAPR_HANDLE AccountHandle,
1169 BOOL AllPrivileges,
1170 PLSAPR_PRIVILEGE_SET Privileges)
1171 {
1172 UNIMPLEMENTED;
1173 return STATUS_NOT_IMPLEMENTED;
1174 }
1175
1176
1177 /* Function 21 */
1178 NTSTATUS WINAPI LsarGetQuotasForAccount(
1179 LSAPR_HANDLE AccountHandle,
1180 PQUOTA_LIMITS QuotaLimits)
1181 {
1182 UNIMPLEMENTED;
1183 return STATUS_NOT_IMPLEMENTED;
1184 }
1185
1186
1187 /* Function 22 */
1188 NTSTATUS WINAPI LsarSetQuotasForAccount(
1189 LSAPR_HANDLE AccountHandle,
1190 PQUOTA_LIMITS QuotaLimits)
1191 {
1192 UNIMPLEMENTED;
1193 return STATUS_NOT_IMPLEMENTED;
1194 }
1195
1196
1197 /* Function 23 */
1198 NTSTATUS WINAPI LsarGetSystemAccessAccount(
1199 LSAPR_HANDLE AccountHandle,
1200 ACCESS_MASK *SystemAccess)
1201 {
1202 PLSA_DB_OBJECT AccountObject;
1203 ULONG Size;
1204 NTSTATUS Status;
1205
1206 /* Validate the account handle */
1207 Status = LsapValidateDbObject(AccountHandle,
1208 LsaDbAccountObject,
1209 ACCOUNT_VIEW,
1210 &AccountObject);
1211 if (!NT_SUCCESS(Status))
1212 {
1213 ERR("Invalid handle (Status %lx)\n", Status);
1214 return Status;
1215 }
1216
1217 /* Get the system access flags */
1218 Status = LsapGetObjectAttribute(AccountObject,
1219 L"ActSysAc",
1220 SystemAccess,
1221 &Size);
1222
1223 return Status;
1224 }
1225
1226
1227 /* Function 24 */
1228 NTSTATUS WINAPI LsarSetSystemAccessAccount(
1229 LSAPR_HANDLE AccountHandle,
1230 ACCESS_MASK SystemAccess)
1231 {
1232 PLSA_DB_OBJECT AccountObject;
1233 NTSTATUS Status;
1234
1235 /* Validate the account handle */
1236 Status = LsapValidateDbObject(AccountHandle,
1237 LsaDbAccountObject,
1238 ACCOUNT_ADJUST_SYSTEM_ACCESS,
1239 &AccountObject);
1240 if (!NT_SUCCESS(Status))
1241 {
1242 ERR("Invalid handle (Status %lx)\n", Status);
1243 return Status;
1244 }
1245
1246 /* Set the system access flags */
1247 Status = LsapSetObjectAttribute(AccountObject,
1248 L"ActSysAc",
1249 &SystemAccess,
1250 sizeof(ACCESS_MASK));
1251
1252 return Status;
1253 }
1254
1255
1256 /* Function 25 */
1257 NTSTATUS WINAPI LsarOpenTrustedDomain(
1258 LSAPR_HANDLE PolicyHandle,
1259 PRPC_SID TrustedDomainSid,
1260 ACCESS_MASK DesiredAccess,
1261 LSAPR_HANDLE *TrustedDomainHandle)
1262 {
1263 UNIMPLEMENTED;
1264 return STATUS_NOT_IMPLEMENTED;
1265 }
1266
1267
1268 /* Function 26 */
1269 NTSTATUS WINAPI LsarQueryInfoTrustedDomain(
1270 LSAPR_HANDLE TrustedDomainHandle,
1271 TRUSTED_INFORMATION_CLASS InformationClass,
1272 PLSAPR_TRUSTED_DOMAIN_INFO *TrustedDomainInformation)
1273 {
1274 UNIMPLEMENTED;
1275 return STATUS_NOT_IMPLEMENTED;
1276 }
1277
1278
1279 /* Function 27 */
1280 NTSTATUS WINAPI LsarSetInformationTrustedDomain(
1281 LSAPR_HANDLE TrustedDomainHandle,
1282 TRUSTED_INFORMATION_CLASS InformationClass,
1283 PLSAPR_TRUSTED_DOMAIN_INFO TrustedDomainInformation)
1284 {
1285 UNIMPLEMENTED;
1286 return STATUS_NOT_IMPLEMENTED;
1287 }
1288
1289
1290 /* Function 28 */
1291 NTSTATUS WINAPI LsarOpenSecret(
1292 LSAPR_HANDLE PolicyHandle,
1293 PRPC_UNICODE_STRING SecretName,
1294 ACCESS_MASK DesiredAccess,
1295 LSAPR_HANDLE *SecretHandle)
1296 {
1297 PLSA_DB_OBJECT PolicyObject;
1298 PLSA_DB_OBJECT SecretObject = NULL;
1299 NTSTATUS Status = STATUS_SUCCESS;
1300
1301 /* Validate the PolicyHandle */
1302 Status = LsapValidateDbObject(PolicyHandle,
1303 LsaDbPolicyObject,
1304 0,
1305 &PolicyObject);
1306 if (!NT_SUCCESS(Status))
1307 {
1308 ERR("LsapValidateDbObject returned 0x%08lx\n", Status);
1309 return Status;
1310 }
1311
1312 /* Create the secret object */
1313 Status = LsapOpenDbObject(PolicyObject,
1314 L"Secrets",
1315 SecretName->Buffer,
1316 LsaDbSecretObject,
1317 DesiredAccess,
1318 &SecretObject);
1319 if (!NT_SUCCESS(Status))
1320 {
1321 ERR("LsapOpenDbObject failed (Status 0x%08lx)\n", Status);
1322 goto done;
1323 }
1324
1325 done:
1326 if (!NT_SUCCESS(Status))
1327 {
1328 if (SecretObject != NULL)
1329 LsapCloseDbObject(SecretObject);
1330 }
1331 else
1332 {
1333 *SecretHandle = (LSAPR_HANDLE)SecretObject;
1334 }
1335
1336 return Status;
1337 }
1338
1339
1340 /* Function 29 */
1341 NTSTATUS WINAPI LsarSetSecret(
1342 LSAPR_HANDLE SecretHandle,
1343 PLSAPR_CR_CIPHER_VALUE EncryptedCurrentValue,
1344 PLSAPR_CR_CIPHER_VALUE EncryptedOldValue)
1345 {
1346 PLSA_DB_OBJECT SecretObject;
1347 PBYTE CurrentValue = NULL;
1348 PBYTE OldValue = NULL;
1349 ULONG CurrentValueLength = 0;
1350 ULONG OldValueLength = 0;
1351 LARGE_INTEGER Time;
1352 NTSTATUS Status;
1353
1354 TRACE("LsarSetSecret(%p %p %p)\n", SecretHandle,
1355 EncryptedCurrentValue, EncryptedOldValue);
1356
1357 /* Validate the SecretHandle */
1358 Status = LsapValidateDbObject(SecretHandle,
1359 LsaDbSecretObject,
1360 SECRET_SET_VALUE,
1361 &SecretObject);
1362 if (!NT_SUCCESS(Status))
1363 {
1364 ERR("LsapValidateDbObject returned 0x%08lx\n", Status);
1365 return Status;
1366 }
1367
1368 if (EncryptedCurrentValue != NULL)
1369 {
1370 /* FIXME: Decrypt the current value */
1371 CurrentValue = EncryptedCurrentValue->Buffer;
1372 CurrentValueLength = EncryptedCurrentValue->MaximumLength;
1373 }
1374
1375 /* Set the current value */
1376 Status = LsapSetObjectAttribute(SecretObject,
1377 L"CurrentValue",
1378 CurrentValue,
1379 CurrentValueLength);
1380 if (!NT_SUCCESS(Status))
1381 {
1382 ERR("LsapSetObjectAttribute failed (Status 0x%08lx)\n", Status);
1383 goto done;
1384 }
1385
1386 /* Get the current time */
1387 Status = NtQuerySystemTime(&Time);
1388 if (!NT_SUCCESS(Status))
1389 {
1390 ERR("NtQuerySystemTime failed (Status 0x%08lx)\n", Status);
1391 goto done;
1392 }
1393
1394 /* Set the current time */
1395 Status = LsapSetObjectAttribute(SecretObject,
1396 L"CurrentTime",
1397 &Time,
1398 sizeof(LARGE_INTEGER));
1399 if (!NT_SUCCESS(Status))
1400 {
1401 ERR("LsapSetObjectAttribute failed (Status 0x%08lx)\n", Status);
1402 goto done;
1403 }
1404
1405 if (EncryptedOldValue != NULL)
1406 {
1407 /* FIXME: Decrypt the old value */
1408 OldValue = EncryptedOldValue->Buffer;
1409 OldValueLength = EncryptedOldValue->MaximumLength;
1410 }
1411
1412 /* Set the old value */
1413 Status = LsapSetObjectAttribute(SecretObject,
1414 L"OldValue",
1415 OldValue,
1416 OldValueLength);
1417 if (!NT_SUCCESS(Status))
1418 {
1419 ERR("LsapSetObjectAttribute failed (Status 0x%08lx)\n", Status);
1420 goto done;
1421 }
1422
1423 /* Set the old time */
1424 Status = LsapSetObjectAttribute(SecretObject,
1425 L"OldTime",
1426 &Time,
1427 sizeof(LARGE_INTEGER));
1428 if (!NT_SUCCESS(Status))
1429 {
1430 ERR("LsapSetObjectAttribute failed (Status 0x%08lx)\n", Status);
1431 }
1432
1433 done:
1434 return Status;
1435 }
1436
1437
1438 /* Function 30 */
1439 NTSTATUS WINAPI LsarQuerySecret(
1440 LSAPR_HANDLE SecretHandle,
1441 PLSAPR_CR_CIPHER_VALUE *EncryptedCurrentValue,
1442 PLARGE_INTEGER CurrentValueSetTime,
1443 PLSAPR_CR_CIPHER_VALUE *EncryptedOldValue,
1444 PLARGE_INTEGER OldValueSetTime)
1445 {
1446 PLSA_DB_OBJECT SecretObject;
1447 PLSAPR_CR_CIPHER_VALUE EncCurrentValue = NULL;
1448 PLSAPR_CR_CIPHER_VALUE EncOldValue = NULL;
1449 PBYTE CurrentValue = NULL;
1450 PBYTE OldValue = NULL;
1451 ULONG CurrentValueLength = 0;
1452 ULONG OldValueLength = 0;
1453 ULONG BufferSize;
1454 NTSTATUS Status;
1455
1456 TRACE("LsarQuerySecret(%p %p %p %p %p)\n", SecretHandle,
1457 EncryptedCurrentValue, CurrentValueSetTime,
1458 EncryptedOldValue, OldValueSetTime);
1459
1460 /* Validate the SecretHandle */
1461 Status = LsapValidateDbObject(SecretHandle,
1462 LsaDbSecretObject,
1463 SECRET_QUERY_VALUE,
1464 &SecretObject);
1465 if (!NT_SUCCESS(Status))
1466 {
1467 ERR("LsapValidateDbObject returned 0x%08lx\n", Status);
1468 return Status;
1469 }
1470
1471 if (EncryptedCurrentValue != NULL)
1472 {
1473 CurrentValueLength = 0;
1474
1475 /* Get the size of the current value */
1476 Status = LsapGetObjectAttribute(SecretObject,
1477 L"CurrentValue",
1478 NULL,
1479 &CurrentValueLength);
1480 if (!NT_SUCCESS(Status))
1481 goto done;
1482
1483 /* Allocate a buffer for the current value */
1484 CurrentValue = midl_user_allocate(CurrentValueLength);
1485 if (CurrentValue == NULL)
1486 {
1487 Status = STATUS_INSUFFICIENT_RESOURCES;
1488 goto done;
1489 }
1490
1491 /* Get the current value */
1492 Status = LsapGetObjectAttribute(SecretObject,
1493 L"CurrentValue",
1494 CurrentValue,
1495 &CurrentValueLength);
1496 if (!NT_SUCCESS(Status))
1497 goto done;
1498
1499 /* Allocate a buffer for the encrypted current value */
1500 EncCurrentValue = midl_user_allocate(sizeof(LSAPR_CR_CIPHER_VALUE));
1501 if (EncCurrentValue == NULL)
1502 {
1503 Status = STATUS_INSUFFICIENT_RESOURCES;
1504 goto done;
1505 }
1506
1507 /* FIXME: Encrypt the current value */
1508 EncCurrentValue->Length = (USHORT)(CurrentValueLength - sizeof(WCHAR));
1509 EncCurrentValue->MaximumLength = (USHORT)CurrentValueLength;
1510 EncCurrentValue->Buffer = (PBYTE)CurrentValue;
1511 }
1512
1513 if (CurrentValueSetTime != NULL)
1514 {
1515 BufferSize = sizeof(LARGE_INTEGER);
1516
1517 /* Get the current value time */
1518 Status = LsapGetObjectAttribute(SecretObject,
1519 L"CurrentTime",
1520 (PBYTE)CurrentValueSetTime,
1521 &BufferSize);
1522 if (!NT_SUCCESS(Status))
1523 goto done;
1524 }
1525
1526 if (EncryptedOldValue != NULL)
1527 {
1528 OldValueLength = 0;
1529
1530 /* Get the size of the old value */
1531 Status = LsapGetObjectAttribute(SecretObject,
1532 L"OldValue",
1533 NULL,
1534 &OldValueLength);
1535 if (!NT_SUCCESS(Status))
1536 goto done;
1537
1538 /* Allocate a buffer for the old value */
1539 OldValue = midl_user_allocate(OldValueLength);
1540 if (OldValue == NULL)
1541 {
1542 Status = STATUS_INSUFFICIENT_RESOURCES;
1543 goto done;
1544 }
1545
1546 /* Get the old value */
1547 Status = LsapGetObjectAttribute(SecretObject,
1548 L"OldValue",
1549 OldValue,
1550 &OldValueLength);
1551 if (!NT_SUCCESS(Status))
1552 goto done;
1553
1554 /* Allocate a buffer for the encrypted old value */
1555 EncOldValue = midl_user_allocate(sizeof(LSAPR_CR_CIPHER_VALUE) + OldValueLength);
1556 if (EncOldValue == NULL)
1557 {
1558 Status = STATUS_INSUFFICIENT_RESOURCES;
1559 goto done;
1560 }
1561
1562 /* FIXME: Encrypt the old value */
1563 EncOldValue->Length = (USHORT)(OldValueLength - sizeof(WCHAR));
1564 EncOldValue->MaximumLength = (USHORT)OldValueLength;
1565 EncOldValue->Buffer = (PBYTE)OldValue;
1566 }
1567
1568 if (OldValueSetTime != NULL)
1569 {
1570 BufferSize = sizeof(LARGE_INTEGER);
1571
1572 /* Get the old value time */
1573 Status = LsapGetObjectAttribute(SecretObject,
1574 L"OldTime",
1575 (PBYTE)OldValueSetTime,
1576 &BufferSize);
1577 if (!NT_SUCCESS(Status))
1578 goto done;
1579 }
1580
1581
1582 done:
1583 if (NT_SUCCESS(Status))
1584 {
1585 if (EncryptedCurrentValue != NULL)
1586 *EncryptedCurrentValue = EncCurrentValue;
1587
1588 if (EncryptedOldValue != NULL)
1589 *EncryptedOldValue = EncOldValue;
1590 }
1591 else
1592 {
1593 if (EncryptedCurrentValue != NULL)
1594 *EncryptedCurrentValue = NULL;
1595
1596 if (EncryptedOldValue != NULL)
1597 *EncryptedOldValue = NULL;
1598
1599 if (EncCurrentValue != NULL)
1600 midl_user_free(EncCurrentValue);
1601
1602 if (EncOldValue != NULL)
1603 midl_user_free(EncOldValue);
1604
1605 if (CurrentValue != NULL)
1606 midl_user_free(CurrentValue);
1607
1608 if (OldValue != NULL)
1609 midl_user_free(OldValue);
1610 }
1611
1612 TRACE("LsarQuerySecret done (Status 0x%08lx)\n", Status);
1613
1614 return Status;
1615 }
1616
1617
1618 /* Function 31 */
1619 NTSTATUS WINAPI LsarLookupPrivilegeValue(
1620 LSAPR_HANDLE PolicyHandle,
1621 PRPC_UNICODE_STRING Name,
1622 PLUID Value)
1623 {
1624 NTSTATUS Status;
1625
1626 TRACE("LsarLookupPrivilegeValue(%p, %wZ, %p)\n",
1627 PolicyHandle, Name, Value);
1628
1629 Status = LsapValidateDbObject(PolicyHandle,
1630 LsaDbPolicyObject,
1631 POLICY_LOOKUP_NAMES,
1632 NULL);
1633 if (!NT_SUCCESS(Status))
1634 {
1635 ERR("Invalid handle (Status %lx)\n", Status);
1636 return Status;
1637 }
1638
1639 TRACE("Privilege: %wZ\n", Name);
1640
1641 Status = LsarpLookupPrivilegeValue((PUNICODE_STRING)Name,
1642 Value);
1643
1644 return Status;
1645 }
1646
1647
1648 /* Function 32 */
1649 NTSTATUS WINAPI LsarLookupPrivilegeName(
1650 LSAPR_HANDLE PolicyHandle,
1651 PLUID Value,
1652 PRPC_UNICODE_STRING *Name)
1653 {
1654 NTSTATUS Status;
1655
1656 TRACE("LsarLookupPrivilegeName(%p, %p, %p)\n",
1657 PolicyHandle, Value, Name);
1658
1659 Status = LsapValidateDbObject(PolicyHandle,
1660 LsaDbPolicyObject,
1661 POLICY_LOOKUP_NAMES,
1662 NULL);
1663 if (!NT_SUCCESS(Status))
1664 {
1665 ERR("Invalid handle\n");
1666 return Status;
1667 }
1668
1669 Status = LsarpLookupPrivilegeName(Value, (PUNICODE_STRING*)Name);
1670
1671 return Status;
1672 }
1673
1674
1675 /* Function 33 */
1676 NTSTATUS WINAPI LsarLookupPrivilegeDisplayName(
1677 LSAPR_HANDLE PolicyHandle,
1678 PRPC_UNICODE_STRING Name,
1679 USHORT ClientLanguage,
1680 USHORT ClientSystemDefaultLanguage,
1681 PRPC_UNICODE_STRING *DisplayName,
1682 USHORT *LanguageReturned)
1683 {
1684 UNIMPLEMENTED;
1685 return STATUS_NOT_IMPLEMENTED;
1686 }
1687
1688
1689 /* Function 34 */
1690 NTSTATUS WINAPI LsarDeleteObject(
1691 LSAPR_HANDLE *ObjectHandle)
1692 {
1693 UNIMPLEMENTED;
1694 return STATUS_NOT_IMPLEMENTED;
1695 }
1696
1697
1698 /* Function 35 */
1699 NTSTATUS WINAPI LsarEnumerateAccountsWithUserRight(
1700 LSAPR_HANDLE PolicyHandle,
1701 PRPC_UNICODE_STRING UserRight,
1702 PLSAPR_ACCOUNT_ENUM_BUFFER EnumerationBuffer)
1703 {
1704 UNIMPLEMENTED;
1705 return STATUS_NOT_IMPLEMENTED;
1706 }
1707
1708
1709 /* Function 36 */
1710 NTSTATUS WINAPI LsarEnumerateAccountRights(
1711 LSAPR_HANDLE PolicyHandle,
1712 PRPC_SID AccountSid,
1713 PLSAPR_USER_RIGHT_SET UserRights)
1714 {
1715 LSAPR_HANDLE AccountHandle;
1716 PLSAPR_PRIVILEGE_SET PrivilegeSet = NULL;
1717 PRPC_UNICODE_STRING RightsBuffer = NULL;
1718 PRPC_UNICODE_STRING PrivilegeString;
1719 ULONG RightsCount;
1720 ULONG RightsIndex;
1721 ULONG PrivIndex;
1722 NTSTATUS Status;
1723
1724 TRACE("LsarEnumerateAccountRights(%p %p %p)\n",
1725 PolicyHandle, AccountSid, UserRights);
1726
1727 /* Open the account */
1728 Status = LsarOpenAccount(PolicyHandle,
1729 AccountSid,
1730 ACCOUNT_VIEW,
1731 &AccountHandle);
1732 if (!NT_SUCCESS(Status))
1733 {
1734 ERR("LsarOpenAccount returned 0x%08lx\n", Status);
1735 return Status;
1736 }
1737
1738 /* Enumerate the privileges */
1739 Status = LsarEnumeratePrivilegesAccount(AccountHandle,
1740 &PrivilegeSet);
1741 if (!NT_SUCCESS(Status))
1742 {
1743 ERR("LsarEnumeratePrivilegesAccount returned 0x%08lx\n", Status);
1744 goto done;
1745 }
1746
1747 /* FIXME: Get account rights */
1748
1749
1750 RightsCount = PrivilegeSet->PrivilegeCount;
1751
1752 /* FIXME: Count account rights */
1753
1754
1755 /* We are done if there are no rights to be enumerated */
1756 if (RightsCount == 0)
1757 {
1758 UserRights->Entries = 0;
1759 UserRights->UserRights = NULL;
1760 Status = STATUS_SUCCESS;
1761 goto done;
1762 }
1763
1764 /* Allocate a buffer for the account rights */
1765 RightsBuffer = MIDL_user_allocate(RightsCount * sizeof(RPC_UNICODE_STRING));
1766 if (RightsBuffer == NULL)
1767 {
1768 Status = STATUS_INSUFFICIENT_RESOURCES;
1769 goto done;
1770 }
1771
1772 /* Copy the privileges into the buffer */
1773 RightsIndex = 0;
1774 for (PrivIndex = 0; PrivIndex < PrivilegeSet->PrivilegeCount; PrivIndex++)
1775 {
1776 PrivilegeString = NULL;
1777 Status = LsarLookupPrivilegeName(PolicyHandle,
1778 (PLUID)&PrivilegeSet->Privilege[PrivIndex].Luid,
1779 (PRPC_UNICODE_STRING *)&PrivilegeString);
1780 if (!NT_SUCCESS(Status))
1781 goto done;
1782
1783 RightsBuffer[RightsIndex].Length = PrivilegeString->Length;
1784 RightsBuffer[RightsIndex].MaximumLength = PrivilegeString->MaximumLength;
1785 RightsBuffer[RightsIndex].Buffer = PrivilegeString->Buffer;
1786
1787 MIDL_user_free(PrivilegeString);
1788 RightsIndex++;
1789 }
1790
1791 /* FIXME: Copy account rights into the buffer */
1792
1793
1794 UserRights->Entries = RightsCount;
1795 UserRights->UserRights = (PRPC_UNICODE_STRING)RightsBuffer;
1796
1797 done:
1798 if (!NT_SUCCESS(Status))
1799 {
1800 if (RightsBuffer != NULL)
1801 {
1802 for (RightsIndex = 0; RightsIndex < RightsCount; RightsIndex++)
1803 {
1804 if (RightsBuffer[RightsIndex].Buffer != NULL)
1805 MIDL_user_free(RightsBuffer[RightsIndex].Buffer);
1806 }
1807
1808 MIDL_user_free(RightsBuffer);
1809 }
1810 }
1811
1812 if (PrivilegeSet != NULL)
1813 MIDL_user_free(PrivilegeSet);
1814
1815 LsarClose(&AccountHandle);
1816
1817 return Status;
1818 }
1819
1820
1821 /* Function 37 */
1822 NTSTATUS WINAPI LsarAddAccountRights(
1823 LSAPR_HANDLE PolicyHandle,
1824 PRPC_SID AccountSid,
1825 PLSAPR_USER_RIGHT_SET UserRights)
1826 {
1827 UNIMPLEMENTED;
1828 return STATUS_NOT_IMPLEMENTED;
1829 }
1830
1831
1832 /* Function 38 */
1833 NTSTATUS WINAPI LsarRemoveAccountRights(
1834 LSAPR_HANDLE PolicyHandle,
1835 PRPC_SID AccountSid,
1836 BOOL AllRights,
1837 PLSAPR_USER_RIGHT_SET UserRights)
1838 {
1839 UNIMPLEMENTED;
1840 return STATUS_NOT_IMPLEMENTED;
1841 }
1842
1843
1844 /* Function 39 */
1845 NTSTATUS WINAPI LsarQueryTrustedDomainInfo(
1846 LSAPR_HANDLE PolicyHandle,
1847 PRPC_SID TrustedDomainSid,
1848 TRUSTED_INFORMATION_CLASS InformationClass,
1849 PLSAPR_TRUSTED_DOMAIN_INFO *TrustedDomainInformation)
1850 {
1851 UNIMPLEMENTED;
1852 return STATUS_NOT_IMPLEMENTED;
1853 }
1854
1855
1856 /* Function 40 */
1857 NTSTATUS WINAPI LsarSetTrustedDomainInfo(
1858 LSAPR_HANDLE PolicyHandle,
1859 PRPC_SID TrustedDomainSid,
1860 TRUSTED_INFORMATION_CLASS InformationClass,
1861 PLSAPR_TRUSTED_DOMAIN_INFO TrustedDomainInformation)
1862 {
1863 UNIMPLEMENTED;
1864 return STATUS_NOT_IMPLEMENTED;
1865 }
1866
1867
1868 /* Function 41 */
1869 NTSTATUS WINAPI LsarDeleteTrustedDomain(
1870 LSAPR_HANDLE PolicyHandle,
1871 PRPC_SID TrustedDomainSid)
1872 {
1873 UNIMPLEMENTED;
1874 return STATUS_NOT_IMPLEMENTED;
1875 }
1876
1877
1878 /* Function 42 */
1879 NTSTATUS WINAPI LsarStorePrivateData(
1880 LSAPR_HANDLE PolicyHandle,
1881 PRPC_UNICODE_STRING KeyName,
1882 PLSAPR_CR_CIPHER_VALUE EncryptedData)
1883 {
1884 UNIMPLEMENTED;
1885 return STATUS_NOT_IMPLEMENTED;
1886 }
1887
1888
1889 /* Function 43 */
1890 NTSTATUS WINAPI LsarRetrievePrivateData(
1891 LSAPR_HANDLE PolicyHandle,
1892 PRPC_UNICODE_STRING KeyName,
1893 PLSAPR_CR_CIPHER_VALUE *EncryptedData)
1894 {
1895 UNIMPLEMENTED;
1896 return STATUS_NOT_IMPLEMENTED;
1897 }
1898
1899
1900 /* Function 44 */
1901 NTSTATUS WINAPI LsarOpenPolicy2(
1902 LPWSTR SystemName,
1903 PLSAPR_OBJECT_ATTRIBUTES ObjectAttributes,
1904 ACCESS_MASK DesiredAccess,
1905 LSAPR_HANDLE *PolicyHandle)
1906 {
1907 UNIMPLEMENTED;
1908 return STATUS_NOT_IMPLEMENTED;
1909 }
1910
1911
1912 /* Function 45 */
1913 NTSTATUS WINAPI LsarGetUserName(
1914 LPWSTR SystemName,
1915 PRPC_UNICODE_STRING *UserName,
1916 PRPC_UNICODE_STRING *DomainName)
1917 {
1918 UNIMPLEMENTED;
1919 return STATUS_NOT_IMPLEMENTED;
1920 }
1921
1922
1923 /* Function 46 */
1924 NTSTATUS WINAPI LsarQueryInformationPolicy2(
1925 LSAPR_HANDLE PolicyHandle,
1926 POLICY_INFORMATION_CLASS InformationClass,
1927 PLSAPR_POLICY_INFORMATION *PolicyInformation)
1928 {
1929 return LsarQueryInformationPolicy(PolicyHandle,
1930 InformationClass,
1931 PolicyInformation);
1932 }
1933
1934
1935 /* Function 47 */
1936 NTSTATUS WINAPI LsarSetInformationPolicy2(
1937 LSAPR_HANDLE PolicyHandle,
1938 POLICY_INFORMATION_CLASS InformationClass,
1939 PLSAPR_POLICY_INFORMATION PolicyInformation)
1940 {
1941 return LsarSetInformationPolicy(PolicyHandle,
1942 InformationClass,
1943 PolicyInformation);
1944 }
1945
1946
1947 /* Function 48 */
1948 NTSTATUS WINAPI LsarQueryTrustedDomainInfoByName(
1949 LSAPR_HANDLE PolicyHandle,
1950 PRPC_UNICODE_STRING TrustedDomainName,
1951 POLICY_INFORMATION_CLASS InformationClass,
1952 PLSAPR_TRUSTED_DOMAIN_INFO *PolicyInformation)
1953 {
1954 UNIMPLEMENTED;
1955 return STATUS_NOT_IMPLEMENTED;
1956 }
1957
1958
1959 /* Function 49 */
1960 NTSTATUS WINAPI LsarSetTrustedDomainInfoByName(
1961 LSAPR_HANDLE PolicyHandle,
1962 PRPC_UNICODE_STRING TrustedDomainName,
1963 POLICY_INFORMATION_CLASS InformationClass,
1964 PLSAPR_TRUSTED_DOMAIN_INFO PolicyInformation)
1965 {
1966 UNIMPLEMENTED;
1967 return STATUS_NOT_IMPLEMENTED;
1968 }
1969
1970
1971 /* Function 50 */
1972 NTSTATUS WINAPI LsarEnumerateTrustedDomainsEx(
1973 LSAPR_HANDLE PolicyHandle,
1974 DWORD *EnumerationContext,
1975 PLSAPR_TRUSTED_ENUM_BUFFER_EX EnumerationBuffer,
1976 DWORD PreferedMaximumLength)
1977 {
1978 UNIMPLEMENTED;
1979 return STATUS_NOT_IMPLEMENTED;
1980 }
1981
1982
1983 /* Function 51 */
1984 NTSTATUS WINAPI LsarCreateTrustedDomainEx(
1985 LSAPR_HANDLE PolicyHandle,
1986 PLSAPR_TRUSTED_DOMAIN_INFORMATION_EX TrustedDomainInformation,
1987 PLSAPR_TRUSTED_DOMAIN_AUTH_INFORMATION AuthentificationInformation,
1988 ACCESS_MASK DesiredAccess,
1989 LSAPR_HANDLE *TrustedDomainHandle)
1990 {
1991 UNIMPLEMENTED;
1992 return STATUS_NOT_IMPLEMENTED;
1993 }
1994
1995
1996 /* Function 52 */
1997 NTSTATUS WINAPI LsarSetPolicyReplicationHandle(
1998 PLSAPR_HANDLE PolicyHandle)
1999 {
2000 /* Deprecated */
2001 return STATUS_NOT_IMPLEMENTED;
2002 }
2003
2004
2005 /* Function 53 */
2006 NTSTATUS WINAPI LsarQueryDomainInformationPolicy(
2007 LSAPR_HANDLE PolicyHandle,
2008 POLICY_INFORMATION_CLASS InformationClass,
2009 PLSAPR_POLICY_DOMAIN_INFORMATION *PolicyInformation)
2010 {
2011 UNIMPLEMENTED;
2012 return STATUS_NOT_IMPLEMENTED;
2013 }
2014
2015
2016 /* Function 54 */
2017 NTSTATUS WINAPI LsarSetDomainInformationPolicy(
2018 LSAPR_HANDLE PolicyHandle,
2019 POLICY_INFORMATION_CLASS InformationClass,
2020 PLSAPR_POLICY_DOMAIN_INFORMATION PolicyInformation)
2021 {
2022 UNIMPLEMENTED;
2023 return STATUS_NOT_IMPLEMENTED;
2024 }
2025
2026
2027 /* Function 55 */
2028 NTSTATUS WINAPI LsarOpenTrustedDomainByName(
2029 LSAPR_HANDLE PolicyHandle,
2030 PRPC_UNICODE_STRING TrustedDomainName,
2031 ACCESS_MASK DesiredAccess,
2032 LSAPR_HANDLE *TrustedDomainHandle)
2033 {
2034 UNIMPLEMENTED;
2035 return STATUS_NOT_IMPLEMENTED;
2036 }
2037
2038
2039 /* Function 56 */
2040 NTSTATUS WINAPI LsarTestCall(
2041 handle_t hBinding)
2042 {
2043 UNIMPLEMENTED;
2044 return STATUS_NOT_IMPLEMENTED;
2045 }
2046
2047
2048 /* Function 57 */
2049 NTSTATUS WINAPI LsarLookupSids2(
2050 LSAPR_HANDLE PolicyHandle,
2051 PLSAPR_SID_ENUM_BUFFER SidEnumBuffer,
2052 PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains,
2053 PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
2054 LSAP_LOOKUP_LEVEL LookupLevel,
2055 DWORD *MappedCount,
2056 DWORD LookupOptions,
2057 DWORD ClientRevision)
2058 {
2059 NTSTATUS Status;
2060
2061 TRACE("(%p %p %p %p %d %p %lu %lu)\n",
2062 PolicyHandle, SidEnumBuffer, ReferencedDomains, TranslatedNames,
2063 LookupLevel, MappedCount, LookupOptions, ClientRevision);
2064
2065 TranslatedNames->Entries = SidEnumBuffer->Entries;
2066 TranslatedNames->Names = NULL;
2067 *ReferencedDomains = NULL;
2068
2069 /* FIXME: Fail, if there is an invalid SID in the SidEnumBuffer */
2070
2071 Status = LsapLookupSids(SidEnumBuffer,
2072 ReferencedDomains,
2073 TranslatedNames,
2074 LookupLevel,
2075 MappedCount,
2076 LookupOptions,
2077 ClientRevision);
2078
2079 return Status;
2080 }
2081
2082
2083 /* Function 58 */
2084 NTSTATUS WINAPI LsarLookupNames2(
2085 LSAPR_HANDLE PolicyHandle,
2086 DWORD Count,
2087 PRPC_UNICODE_STRING Names,
2088 PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains,
2089 PLSAPR_TRANSLATED_SIDS_EX TranslatedSids,
2090 LSAP_LOOKUP_LEVEL LookupLevel,
2091 DWORD *MappedCount,
2092 DWORD LookupOptions,
2093 DWORD ClientRevision)
2094 {
2095 LSAPR_TRANSLATED_SIDS_EX2 TranslatedSidsEx2;
2096 ULONG i;
2097 NTSTATUS Status;
2098
2099 TRACE("(%p %lu %p %p %p %d %p %lu %lu)\n",
2100 PolicyHandle, Count, Names, ReferencedDomains, TranslatedSids,
2101 LookupLevel, MappedCount, LookupOptions, ClientRevision);
2102
2103 TranslatedSids->Entries = 0;
2104 TranslatedSids->Sids = NULL;
2105 *ReferencedDomains = NULL;
2106
2107 if (Count == 0)
2108 return STATUS_NONE_MAPPED;
2109
2110 TranslatedSidsEx2.Entries = 0;
2111 TranslatedSidsEx2.Sids = NULL;
2112
2113 Status = LsapLookupNames(Count,
2114 Names,
2115 ReferencedDomains,
2116 &TranslatedSidsEx2,
2117 LookupLevel,
2118 MappedCount,
2119 LookupOptions,
2120 ClientRevision);
2121 if (!NT_SUCCESS(Status))
2122 return Status;
2123
2124 TranslatedSids->Entries = TranslatedSidsEx2.Entries;
2125 TranslatedSids->Sids = MIDL_user_allocate(TranslatedSids->Entries * sizeof(LSA_TRANSLATED_SID));
2126 if (TranslatedSids->Sids == NULL)
2127 {
2128 MIDL_user_free(TranslatedSidsEx2.Sids);
2129 MIDL_user_free(*ReferencedDomains);
2130 *ReferencedDomains = NULL;
2131 return STATUS_INSUFFICIENT_RESOURCES;
2132 }
2133
2134 for (i = 0; i < TranslatedSidsEx2.Entries; i++)
2135 {
2136 TranslatedSids->Sids[i].Use = TranslatedSidsEx2.Sids[i].Use;
2137 TranslatedSids->Sids[i].RelativeId = LsapGetRelativeIdFromSid(TranslatedSidsEx2.Sids[i].Sid);
2138 TranslatedSids->Sids[i].DomainIndex = TranslatedSidsEx2.Sids[i].DomainIndex;
2139 TranslatedSids->Sids[i].Flags = TranslatedSidsEx2.Sids[i].Flags;
2140 }
2141
2142 MIDL_user_free(TranslatedSidsEx2.Sids);
2143
2144 return STATUS_SUCCESS;
2145 }
2146
2147
2148 /* Function 59 */
2149 NTSTATUS WINAPI LsarCreateTrustedDomainEx2(
2150 LSAPR_HANDLE PolicyHandle,
2151 PLSAPR_TRUSTED_DOMAIN_INFORMATION_EX TrustedDomainInformation,
2152 PLSAPR_TRUSTED_DOMAIN_AUTH_INFORMATION_INTERNAL AuthentificationInformation,
2153 ACCESS_MASK DesiredAccess,
2154 LSAPR_HANDLE *TrustedDomainHandle)
2155 {
2156 UNIMPLEMENTED;
2157 return STATUS_NOT_IMPLEMENTED;
2158 }
2159
2160
2161 /* Function 60 */
2162 NTSTATUS WINAPI CredrWrite(
2163 handle_t hBinding)
2164 {
2165 UNIMPLEMENTED;
2166 return STATUS_NOT_IMPLEMENTED;
2167 }
2168
2169
2170 /* Function 61 */
2171 NTSTATUS WINAPI CredrRead(
2172 handle_t hBinding)
2173 {
2174 UNIMPLEMENTED;
2175 return STATUS_NOT_IMPLEMENTED;
2176 }
2177
2178
2179 /* Function 62 */
2180 NTSTATUS WINAPI CredrEnumerate(
2181 handle_t hBinding)
2182 {
2183 UNIMPLEMENTED;
2184 return STATUS_NOT_IMPLEMENTED;
2185 }
2186
2187
2188 /* Function 63 */
2189 NTSTATUS WINAPI CredrWriteDomainCredentials(
2190 handle_t hBinding)
2191 {
2192 UNIMPLEMENTED;
2193 return STATUS_NOT_IMPLEMENTED;
2194 }
2195
2196
2197 /* Function 64 */
2198 NTSTATUS WINAPI CredrReadDomainCredentials(
2199 handle_t hBinding)
2200 {
2201 UNIMPLEMENTED;
2202 return STATUS_NOT_IMPLEMENTED;
2203 }
2204
2205
2206 /* Function 65 */
2207 NTSTATUS WINAPI CredrDelete(
2208 handle_t hBinding)
2209 {
2210 UNIMPLEMENTED;
2211 return STATUS_NOT_IMPLEMENTED;
2212 }
2213
2214
2215 /* Function 66 */
2216 NTSTATUS WINAPI CredrGetTargetInfo(
2217 handle_t hBinding)
2218 {
2219 UNIMPLEMENTED;
2220 return STATUS_NOT_IMPLEMENTED;
2221 }
2222
2223
2224 /* Function 67 */
2225 NTSTATUS WINAPI CredrProfileLoaded(
2226 handle_t hBinding)
2227 {
2228 UNIMPLEMENTED;
2229 return STATUS_NOT_IMPLEMENTED;
2230 }
2231
2232
2233 /* Function 68 */
2234 NTSTATUS WINAPI LsarLookupNames3(
2235 LSAPR_HANDLE PolicyHandle,
2236 DWORD Count,
2237 PRPC_UNICODE_STRING Names,
2238 PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains,
2239 PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
2240 LSAP_LOOKUP_LEVEL LookupLevel,
2241 DWORD *MappedCount,
2242 DWORD LookupOptions,
2243 DWORD ClientRevision)
2244 {
2245 NTSTATUS Status;
2246
2247 TRACE("(%p %lu %p %p %p %d %p %lu %lu)\n",
2248 PolicyHandle, Count, Names, ReferencedDomains, TranslatedSids,
2249 LookupLevel, MappedCount, LookupOptions, ClientRevision);
2250
2251 TranslatedSids->Entries = 0;
2252 TranslatedSids->Sids = NULL;
2253 *ReferencedDomains = NULL;
2254
2255 if (Count == 0)
2256 return STATUS_NONE_MAPPED;
2257
2258 Status = LsapLookupNames(Count,
2259 Names,
2260 ReferencedDomains,
2261 TranslatedSids,
2262 LookupLevel,
2263 MappedCount,
2264 LookupOptions,
2265 ClientRevision);
2266
2267 return Status;
2268 }
2269
2270
2271 /* Function 69 */
2272 NTSTATUS WINAPI CredrGetSessionTypes(
2273 handle_t hBinding)
2274 {
2275 UNIMPLEMENTED;
2276 return STATUS_NOT_IMPLEMENTED;
2277 }
2278
2279
2280 /* Function 70 */
2281 NTSTATUS WINAPI LsarRegisterAuditEvent(
2282 handle_t hBinding)
2283 {
2284 UNIMPLEMENTED;
2285 return STATUS_NOT_IMPLEMENTED;
2286 }
2287
2288
2289 /* Function 71 */
2290 NTSTATUS WINAPI LsarGenAuditEvent(
2291 handle_t hBinding)
2292 {
2293 UNIMPLEMENTED;
2294 return STATUS_NOT_IMPLEMENTED;
2295 }
2296
2297
2298 /* Function 72 */
2299 NTSTATUS WINAPI LsarUnregisterAuditEvent(
2300 handle_t hBinding)
2301 {
2302 UNIMPLEMENTED;
2303 return STATUS_NOT_IMPLEMENTED;
2304 }
2305
2306
2307 /* Function 73 */
2308 NTSTATUS WINAPI LsarQueryForestTrustInformation(
2309 LSAPR_HANDLE PolicyHandle,
2310 PLSA_UNICODE_STRING TrustedDomainName,
2311 LSA_FOREST_TRUST_RECORD_TYPE HighestRecordType,
2312 PLSA_FOREST_TRUST_INFORMATION *ForestTrustInfo)
2313 {
2314 UNIMPLEMENTED;
2315 return STATUS_NOT_IMPLEMENTED;
2316 }
2317
2318
2319 /* Function 74 */
2320 NTSTATUS WINAPI LsarSetForestTrustInformation(
2321 LSAPR_HANDLE PolicyHandle,
2322 PLSA_UNICODE_STRING TrustedDomainName,
2323 LSA_FOREST_TRUST_RECORD_TYPE HighestRecordType,
2324 PLSA_FOREST_TRUST_INFORMATION ForestTrustInfo,
2325 BOOL CheckOnly,
2326 PLSA_FOREST_TRUST_COLLISION_INFORMATION *CollisionInfo)
2327 {
2328 UNIMPLEMENTED;
2329 return STATUS_NOT_IMPLEMENTED;
2330 }
2331
2332
2333 /* Function 75 */
2334 NTSTATUS WINAPI CredrRename(
2335 handle_t hBinding)
2336 {
2337 UNIMPLEMENTED;
2338 return STATUS_NOT_IMPLEMENTED;
2339 }
2340
2341
2342 /* Function 76 */
2343 NTSTATUS WINAPI LsarLookupSids3(
2344 LSAPR_HANDLE PolicyHandle,
2345 PLSAPR_SID_ENUM_BUFFER SidEnumBuffer,
2346 PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains,
2347 PLSAPR_TRANSLATED_NAMES_EX TranslatedNames,
2348 LSAP_LOOKUP_LEVEL LookupLevel,
2349 DWORD *MappedCount,
2350 DWORD LookupOptions,
2351 DWORD ClientRevision)
2352 {
2353 NTSTATUS Status;
2354
2355 TRACE("(%p %p %p %p %d %p %lu %lu)\n",
2356 PolicyHandle, SidEnumBuffer, ReferencedDomains, TranslatedNames,
2357 LookupLevel, MappedCount, LookupOptions, ClientRevision);
2358
2359 TranslatedNames->Entries = SidEnumBuffer->Entries;
2360 TranslatedNames->Names = NULL;
2361 *ReferencedDomains = NULL;
2362
2363 /* FIXME: Fail, if there is an invalid SID in the SidEnumBuffer */
2364
2365 Status = LsapLookupSids(SidEnumBuffer,
2366 ReferencedDomains,
2367 TranslatedNames,
2368 LookupLevel,
2369 MappedCount,
2370 LookupOptions,
2371 ClientRevision);
2372
2373 return Status;
2374 }
2375
2376
2377 /* Function 77 */
2378 NTSTATUS WINAPI LsarLookupNames4(
2379 handle_t RpcHandle,
2380 DWORD Count,
2381 PRPC_UNICODE_STRING Names,
2382 PLSAPR_REFERENCED_DOMAIN_LIST *ReferencedDomains,
2383 PLSAPR_TRANSLATED_SIDS_EX2 TranslatedSids,
2384 LSAP_LOOKUP_LEVEL LookupLevel,
2385 DWORD *MappedCount,
2386 DWORD LookupOptions,
2387 DWORD ClientRevision)
2388 {
2389 NTSTATUS Status;
2390
2391 TRACE("(%p %lu %p %p %p %d %p %lu %lu)\n",
2392 RpcHandle, Count, Names, ReferencedDomains, TranslatedSids,
2393 LookupLevel, MappedCount, LookupOptions, ClientRevision);
2394
2395 TranslatedSids->Entries = 0;
2396 TranslatedSids->Sids = NULL;
2397 *ReferencedDomains = NULL;
2398
2399 if (Count == 0)
2400 return STATUS_NONE_MAPPED;
2401
2402 Status = LsapLookupNames(Count,
2403 Names,
2404 ReferencedDomains,
2405 TranslatedSids,
2406 LookupLevel,
2407 MappedCount,
2408 LookupOptions,
2409 ClientRevision);
2410
2411 return Status;
2412 }
2413
2414
2415 /* Function 78 */
2416 NTSTATUS WINAPI LsarOpenPolicySce(
2417 handle_t hBinding)
2418 {
2419 UNIMPLEMENTED;
2420 return STATUS_NOT_IMPLEMENTED;
2421 }
2422
2423
2424 /* Function 79 */
2425 NTSTATUS WINAPI LsarAdtRegisterSecurityEventSource(
2426 handle_t hBinding)
2427 {
2428 UNIMPLEMENTED;
2429 return STATUS_NOT_IMPLEMENTED;
2430 }
2431
2432
2433 /* Function 80 */
2434 NTSTATUS WINAPI LsarAdtUnregisterSecurityEventSource(
2435 handle_t hBinding)
2436 {
2437 UNIMPLEMENTED;
2438 return STATUS_NOT_IMPLEMENTED;
2439 }
2440
2441
2442 /* Function 81 */
2443 NTSTATUS WINAPI LsarAdtReportSecurityEvent(
2444 handle_t hBinding)
2445 {
2446 UNIMPLEMENTED;
2447 return STATUS_NOT_IMPLEMENTED;
2448 }
2449
2450
2451 /* Function 82 */
2452 NTSTATUS WINAPI CredrFindBestCredential(
2453 handle_t hBinding)
2454 {
2455 UNIMPLEMENTED;
2456 return STATUS_NOT_IMPLEMENTED;
2457 }
2458
2459
2460 /* Function 83 */
2461 NTSTATUS WINAPI LsarSetAuditPolicy(
2462 handle_t hBinding)
2463 {
2464 UNIMPLEMENTED;
2465 return STATUS_NOT_IMPLEMENTED;
2466 }
2467
2468
2469 /* Function 84 */
2470 NTSTATUS WINAPI LsarQueryAuditPolicy(
2471 handle_t hBinding)
2472 {
2473 UNIMPLEMENTED;
2474 return STATUS_NOT_IMPLEMENTED;
2475 }
2476
2477
2478 /* Function 85 */
2479 NTSTATUS WINAPI LsarEnumerateAuditPolicy(
2480 handle_t hBinding)
2481 {
2482 UNIMPLEMENTED;
2483 return STATUS_NOT_IMPLEMENTED;
2484 }
2485
2486
2487 /* Function 86 */
2488 NTSTATUS WINAPI LsarEnumerateAuditCategories(
2489 handle_t hBinding)
2490 {
2491 UNIMPLEMENTED;
2492 return STATUS_NOT_IMPLEMENTED;
2493 }
2494
2495
2496 /* Function 87 */
2497 NTSTATUS WINAPI LsarEnumerateAuditSubCategories(
2498 handle_t hBinding)
2499 {
2500 UNIMPLEMENTED;
2501 return STATUS_NOT_IMPLEMENTED;
2502 }
2503
2504
2505 /* Function 88 */
2506 NTSTATUS WINAPI LsarLookupAuditCategoryName(
2507 handle_t hBinding)
2508 {
2509 UNIMPLEMENTED;
2510 return STATUS_NOT_IMPLEMENTED;
2511 }
2512
2513
2514 /* Function 89 */
2515 NTSTATUS WINAPI LsarLookupAuditSubCategoryName(
2516 handle_t hBinding)
2517 {
2518 UNIMPLEMENTED;
2519 return STATUS_NOT_IMPLEMENTED;
2520 }
2521
2522
2523 /* Function 90 */
2524 NTSTATUS WINAPI LsarSetAuditSecurity(
2525 handle_t hBinding)
2526 {
2527 UNIMPLEMENTED;
2528 return STATUS_NOT_IMPLEMENTED;
2529 }
2530
2531
2532 /* Function 91 */
2533 NTSTATUS WINAPI LsarQueryAuditSecurity(
2534 handle_t hBinding)
2535 {
2536 UNIMPLEMENTED;
2537 return STATUS_NOT_IMPLEMENTED;
2538 }
2539
2540
2541 /* Function 92 */
2542 NTSTATUS WINAPI CredReadByTokenHandle(
2543 handle_t hBinding)
2544 {
2545 UNIMPLEMENTED;
2546 return STATUS_NOT_IMPLEMENTED;
2547 }
2548
2549
2550 /* Function 93 */
2551 NTSTATUS WINAPI CredrRestoreCredentials(
2552 handle_t hBinding)
2553 {
2554 UNIMPLEMENTED;
2555 return STATUS_NOT_IMPLEMENTED;
2556 }
2557
2558
2559 /* Function 94 */
2560 NTSTATUS WINAPI CredrBackupCredentials(
2561 handle_t hBinding)
2562 {
2563 UNIMPLEMENTED;
2564 return STATUS_NOT_IMPLEMENTED;
2565 }
2566
2567 /* EOF */