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