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