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