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