[LSASRV]
[reactos.git] / reactos / dll / win32 / lsasrv / policy.c
1 /*
2 * PROJECT: Local Security Authority Server DLL
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/win32/lsasrv/policy.c
5 * PURPOSE: Policy object routines
6 * COPYRIGHT: Copyright 2011 Eric Kohl
7 */
8
9 /* INCLUDES ****************************************************************/
10
11 #include "lsasrv.h"
12
13 WINE_DEFAULT_DEBUG_CHANNEL(lsasrv);
14
15
16 /* FUNCTIONS ***************************************************************/
17
18 NTSTATUS
19 WINAPI
20 LsaIOpenPolicyTrusted(OUT LSAPR_HANDLE *PolicyHandle)
21 {
22 PLSA_DB_OBJECT PolicyObject;
23 NTSTATUS Status;
24
25 TRACE("(%p)\n", PolicyHandle);
26
27 Status = LsapOpenDbObject(NULL,
28 NULL,
29 L"Policy",
30 LsaDbPolicyObject,
31 POLICY_ALL_ACCESS,
32 TRUE,
33 &PolicyObject);
34
35 if (NT_SUCCESS(Status))
36 *PolicyHandle = (LSAPR_HANDLE)PolicyObject;
37
38 return Status;
39 }
40
41
42 NTSTATUS
43 LsarQueryAuditLog(PLSA_DB_OBJECT PolicyObject,
44 PLSAPR_POLICY_INFORMATION *PolicyInformation)
45 {
46 PPOLICY_AUDIT_LOG_INFO AuditLogInfo = NULL;
47 ULONG AttributeSize;
48 NTSTATUS Status;
49
50 *PolicyInformation = NULL;
51
52 AttributeSize = sizeof(POLICY_AUDIT_LOG_INFO);
53 AuditLogInfo = MIDL_user_allocate(AttributeSize);
54 if (AuditLogInfo == NULL)
55 return STATUS_INSUFFICIENT_RESOURCES;
56
57 Status = LsapGetObjectAttribute(PolicyObject,
58 L"PolAdtLg",
59 AuditLogInfo,
60 &AttributeSize);
61 if (!NT_SUCCESS(Status))
62 {
63 MIDL_user_free(AuditLogInfo);
64 }
65 else
66 {
67 *PolicyInformation = (PLSAPR_POLICY_INFORMATION)AuditLogInfo;
68 }
69
70 return Status;
71 }
72
73
74 NTSTATUS
75 LsarQueryAuditEvents(PLSA_DB_OBJECT PolicyObject,
76 PLSAPR_POLICY_INFORMATION *PolicyInformation)
77 {
78 PLSAP_POLICY_AUDIT_EVENTS_DATA AuditData = NULL;
79 PLSAPR_POLICY_AUDIT_EVENTS_INFO p = NULL;
80 ULONG AttributeSize;
81 NTSTATUS Status = STATUS_SUCCESS;
82
83 *PolicyInformation = NULL;
84
85 AttributeSize = 0;
86 Status = LsapGetObjectAttribute(PolicyObject,
87 L"PolAdtEv",
88 NULL,
89 &AttributeSize);
90 if (!NT_SUCCESS(Status))
91 return Status;
92
93 if (AttributeSize > 0)
94 {
95 AuditData = MIDL_user_allocate(AttributeSize);
96 if (AuditData == NULL)
97 return STATUS_INSUFFICIENT_RESOURCES;
98
99 Status = LsapGetObjectAttribute(PolicyObject,
100 L"PolAdtEv",
101 AuditData,
102 &AttributeSize);
103 if (!NT_SUCCESS(Status))
104 goto done;
105
106 p = MIDL_user_allocate(sizeof(LSAPR_POLICY_AUDIT_EVENTS_INFO));
107 if (p == NULL)
108 {
109 Status = STATUS_INSUFFICIENT_RESOURCES;
110 goto done;
111 }
112
113 p->AuditingMode = AuditData->AuditingMode;
114 p->MaximumAuditEventCount = AuditData->MaximumAuditEventCount;
115
116 p->EventAuditingOptions = MIDL_user_allocate(AuditData->MaximumAuditEventCount * sizeof(DWORD));
117 if (p->EventAuditingOptions == NULL)
118 {
119 Status = STATUS_INSUFFICIENT_RESOURCES;
120 goto done;
121 }
122
123 memcpy(p->EventAuditingOptions,
124 &(AuditData->AuditEvents[0]),
125 AuditData->MaximumAuditEventCount * sizeof(DWORD));
126 }
127
128 *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
129
130 done:
131 if (!NT_SUCCESS(Status))
132 {
133 if (p->EventAuditingOptions != NULL)
134 MIDL_user_free(p->EventAuditingOptions);
135
136 if (p != NULL)
137 MIDL_user_free(p);
138 }
139
140 if (AuditData != NULL)
141 MIDL_user_free(AuditData);
142
143 return STATUS_SUCCESS;
144 }
145
146
147 NTSTATUS
148 LsarQueryPrimaryDomain(PLSA_DB_OBJECT PolicyObject,
149 PLSAPR_POLICY_INFORMATION *PolicyInformation)
150 {
151 PLSAPR_POLICY_PRIMARY_DOM_INFO p = NULL;
152 PUNICODE_STRING DomainName;
153 ULONG AttributeSize;
154 NTSTATUS Status;
155
156 *PolicyInformation = NULL;
157
158 p = MIDL_user_allocate(sizeof(LSAPR_POLICY_PRIMARY_DOM_INFO));
159 if (p == NULL)
160 return STATUS_INSUFFICIENT_RESOURCES;
161
162 /* Domain Name */
163 AttributeSize = 0;
164 Status = LsapGetObjectAttribute(PolicyObject,
165 L"PolPrDmN",
166 NULL,
167 &AttributeSize);
168 if (!NT_SUCCESS(Status))
169 {
170 goto Done;
171 }
172
173 if (AttributeSize > 0)
174 {
175 DomainName = MIDL_user_allocate(AttributeSize);
176 if (DomainName == NULL)
177 {
178 Status = STATUS_INSUFFICIENT_RESOURCES;
179 goto Done;
180 }
181
182 Status = LsapGetObjectAttribute(PolicyObject,
183 L"PolPrDmN",
184 DomainName,
185 &AttributeSize);
186 if (Status == STATUS_SUCCESS)
187 {
188 DomainName->Buffer = (LPWSTR)((ULONG_PTR)DomainName + (ULONG_PTR)DomainName->Buffer);
189
190 TRACE("PrimaryDomainName: %wZ\n", DomainName);
191
192 p->Name.Buffer = MIDL_user_allocate(DomainName->MaximumLength);
193 if (p->Name.Buffer == NULL)
194 {
195 MIDL_user_free(DomainName);
196 Status = STATUS_INSUFFICIENT_RESOURCES;
197 goto Done;
198 }
199
200 p->Name.Length = DomainName->Length;
201 p->Name.MaximumLength = DomainName->MaximumLength;
202 memcpy(p->Name.Buffer,
203 DomainName->Buffer,
204 DomainName->MaximumLength);
205 }
206
207 MIDL_user_free(DomainName);
208 }
209
210 /* Domain SID */
211 AttributeSize = 0;
212 Status = LsapGetObjectAttribute(PolicyObject,
213 L"PolPrDmS",
214 NULL,
215 &AttributeSize);
216 if (!NT_SUCCESS(Status))
217 {
218 goto Done;
219 }
220
221 if (AttributeSize > 0)
222 {
223 p->Sid = MIDL_user_allocate(AttributeSize);
224 if (p->Sid == NULL)
225 {
226 Status = STATUS_INSUFFICIENT_RESOURCES;
227 goto Done;
228 }
229
230 Status = LsapGetObjectAttribute(PolicyObject,
231 L"PolPrDmS",
232 p->Sid,
233 &AttributeSize);
234 }
235
236 *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
237
238 Done:
239 if (!NT_SUCCESS(Status))
240 {
241 if (p != NULL)
242 {
243 if (p->Name.Buffer)
244 MIDL_user_free(p->Name.Buffer);
245
246 if (p->Sid)
247 MIDL_user_free(p->Sid);
248
249 MIDL_user_free(p);
250 }
251 }
252
253 return Status;
254 }
255
256
257 NTSTATUS
258 LsarQueryPdAccount(PLSA_DB_OBJECT PolicyObject,
259 PLSAPR_POLICY_INFORMATION *PolicyInformation)
260 {
261 PLSAPR_POLICY_PD_ACCOUNT_INFO PdAccountInfo = NULL;
262
263 *PolicyInformation = NULL;
264
265 PdAccountInfo = MIDL_user_allocate(sizeof(LSAPR_POLICY_PD_ACCOUNT_INFO));
266 if (PdAccountInfo == NULL)
267 return STATUS_INSUFFICIENT_RESOURCES;
268
269 PdAccountInfo->Name.Length = 0;
270 PdAccountInfo->Name.MaximumLength = 0;
271 PdAccountInfo->Name.Buffer = NULL;
272
273 *PolicyInformation = (PLSAPR_POLICY_INFORMATION)PdAccountInfo;
274
275 return STATUS_SUCCESS;
276 }
277
278
279 NTSTATUS
280 LsarQueryAccountDomain(PLSA_DB_OBJECT PolicyObject,
281 PLSAPR_POLICY_INFORMATION *PolicyInformation)
282 {
283 PLSAPR_POLICY_ACCOUNT_DOM_INFO p = NULL;
284 PUNICODE_STRING DomainName;
285 ULONG AttributeSize = 0;
286 NTSTATUS Status;
287
288 *PolicyInformation = NULL;
289
290 p = MIDL_user_allocate(sizeof(LSAPR_POLICY_ACCOUNT_DOM_INFO));
291 if (p == NULL)
292 return STATUS_INSUFFICIENT_RESOURCES;
293
294 /* Domain Name */
295 Status = LsapGetObjectAttribute(PolicyObject,
296 L"PolAcDmN",
297 NULL,
298 &AttributeSize);
299 if (!NT_SUCCESS(Status))
300 {
301 goto Done;
302 }
303
304 if (AttributeSize > 0)
305 {
306 DomainName = MIDL_user_allocate(AttributeSize);
307 if (DomainName == NULL)
308 {
309 Status = STATUS_INSUFFICIENT_RESOURCES;
310 goto Done;
311 }
312
313 Status = LsapGetObjectAttribute(PolicyObject,
314 L"PolAcDmN",
315 DomainName,
316 &AttributeSize);
317 if (Status == STATUS_SUCCESS)
318 {
319 DomainName->Buffer = (LPWSTR)((ULONG_PTR)DomainName + (ULONG_PTR)DomainName->Buffer);
320
321 TRACE("AccountDomainName: %wZ\n", DomainName);
322
323 p->DomainName.Buffer = MIDL_user_allocate(DomainName->MaximumLength);
324 if (p->DomainName.Buffer == NULL)
325 {
326 MIDL_user_free(DomainName);
327 Status = STATUS_INSUFFICIENT_RESOURCES;
328 goto Done;
329 }
330
331 p->DomainName.Length = DomainName->Length;
332 p->DomainName.MaximumLength = DomainName->MaximumLength;
333 memcpy(p->DomainName.Buffer,
334 DomainName->Buffer,
335 DomainName->MaximumLength);
336 }
337
338 MIDL_user_free(DomainName);
339 }
340
341 /* Domain SID */
342 AttributeSize = 0;
343 Status = LsapGetObjectAttribute(PolicyObject,
344 L"PolAcDmS",
345 NULL,
346 &AttributeSize);
347 if (!NT_SUCCESS(Status))
348 {
349 goto Done;
350 }
351
352 if (AttributeSize > 0)
353 {
354 p->Sid = MIDL_user_allocate(AttributeSize);
355 if (p->Sid == NULL)
356 {
357 Status = STATUS_INSUFFICIENT_RESOURCES;
358 goto Done;
359 }
360
361 Status = LsapGetObjectAttribute(PolicyObject,
362 L"PolAcDmS",
363 p->Sid,
364 &AttributeSize);
365 }
366
367 *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
368
369 Done:
370 if (!NT_SUCCESS(Status))
371 {
372 if (p)
373 {
374 if (p->DomainName.Buffer)
375 MIDL_user_free(p->DomainName.Buffer);
376
377 if (p->Sid)
378 MIDL_user_free(p->Sid);
379
380 MIDL_user_free(p);
381 }
382 }
383
384 return Status;
385 }
386
387
388 NTSTATUS
389 LsarQueryServerRole(PLSA_DB_OBJECT PolicyObject,
390 PLSAPR_POLICY_INFORMATION *PolicyInformation)
391 {
392 PPOLICY_LSA_SERVER_ROLE_INFO ServerRoleInfo = NULL;
393 ULONG AttributeSize;
394 NTSTATUS Status;
395
396 *PolicyInformation = NULL;
397
398 AttributeSize = sizeof(POLICY_LSA_SERVER_ROLE_INFO);
399 ServerRoleInfo = MIDL_user_allocate(AttributeSize);
400 if (ServerRoleInfo == NULL)
401 return STATUS_INSUFFICIENT_RESOURCES;
402
403 Status = LsapGetObjectAttribute(PolicyObject,
404 L"PolSrvRo",
405 ServerRoleInfo,
406 &AttributeSize);
407 if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
408 {
409 ServerRoleInfo->LsaServerRole = PolicyServerRolePrimary;
410 Status = STATUS_SUCCESS;
411 }
412
413 if (!NT_SUCCESS(Status))
414 {
415 MIDL_user_free(ServerRoleInfo);
416 }
417 else
418 {
419 *PolicyInformation = (PLSAPR_POLICY_INFORMATION)ServerRoleInfo;
420 }
421
422 return Status;
423 }
424
425
426 NTSTATUS
427 LsarQueryReplicaSource(PLSA_DB_OBJECT PolicyObject,
428 PLSAPR_POLICY_INFORMATION *PolicyInformation)
429 {
430 FIXME("\n");
431 *PolicyInformation = NULL;
432 return STATUS_NOT_IMPLEMENTED;
433 }
434
435
436 NTSTATUS
437 LsarQueryDefaultQuota(PLSA_DB_OBJECT PolicyObject,
438 PLSAPR_POLICY_INFORMATION *PolicyInformation)
439 {
440 PPOLICY_DEFAULT_QUOTA_INFO QuotaInfo = NULL;
441 ULONG AttributeSize;
442 NTSTATUS Status;
443
444 *PolicyInformation = NULL;
445
446 AttributeSize = sizeof(POLICY_DEFAULT_QUOTA_INFO);
447 QuotaInfo = MIDL_user_allocate(AttributeSize);
448 if (QuotaInfo == NULL)
449 return STATUS_INSUFFICIENT_RESOURCES;
450
451 Status = LsapGetObjectAttribute(PolicyObject,
452 L"DefQuota",
453 QuotaInfo,
454 &AttributeSize);
455 if (!NT_SUCCESS(Status))
456 {
457 MIDL_user_free(QuotaInfo);
458 }
459 else
460 {
461 *PolicyInformation = (PLSAPR_POLICY_INFORMATION)QuotaInfo;
462 }
463
464 return Status;
465 }
466
467
468 NTSTATUS
469 LsarQueryModification(PLSA_DB_OBJECT PolicyObject,
470 PLSAPR_POLICY_INFORMATION *PolicyInformation)
471 {
472 PPOLICY_MODIFICATION_INFO Info = NULL;
473 ULONG AttributeSize;
474 NTSTATUS Status;
475
476 *PolicyInformation = NULL;
477
478 AttributeSize = sizeof(POLICY_MODIFICATION_INFO);
479 Info = MIDL_user_allocate(AttributeSize);
480 if (Info == NULL)
481 return STATUS_INSUFFICIENT_RESOURCES;
482
483 Status = LsapGetObjectAttribute(PolicyObject,
484 L"PolMod",
485 Info,
486 &AttributeSize);
487 if (!NT_SUCCESS(Status))
488 {
489 MIDL_user_free(Info);
490 }
491 else
492 {
493 *PolicyInformation = (PLSAPR_POLICY_INFORMATION)Info;
494 }
495
496 return Status;
497 }
498
499
500 NTSTATUS
501 LsarQueryAuditFull(PLSA_DB_OBJECT PolicyObject,
502 PLSAPR_POLICY_INFORMATION *PolicyInformation)
503 {
504 PPOLICY_AUDIT_FULL_QUERY_INFO AuditFullInfo = NULL;
505 ULONG AttributeSize;
506 NTSTATUS Status;
507
508 *PolicyInformation = NULL;
509
510 AttributeSize = sizeof(POLICY_AUDIT_FULL_QUERY_INFO);
511 AuditFullInfo = MIDL_user_allocate(AttributeSize);
512 if (AuditFullInfo == NULL)
513 return STATUS_INSUFFICIENT_RESOURCES;
514
515 Status = LsapGetObjectAttribute(PolicyObject,
516 L"PolAdtFl",
517 AuditFullInfo,
518 &AttributeSize);
519 if (!NT_SUCCESS(Status))
520 {
521 MIDL_user_free(AuditFullInfo);
522 }
523 else
524 {
525 *PolicyInformation = (PLSAPR_POLICY_INFORMATION)AuditFullInfo;
526 }
527
528 return Status;
529 }
530
531
532 NTSTATUS
533 LsarQueryDnsDomain(PLSA_DB_OBJECT PolicyObject,
534 PLSAPR_POLICY_INFORMATION *PolicyInformation)
535 {
536 PLSAPR_POLICY_DNS_DOMAIN_INFO p = NULL;
537 PUNICODE_STRING DomainName;
538 ULONG AttributeSize;
539 NTSTATUS Status;
540
541 *PolicyInformation = NULL;
542
543 p = MIDL_user_allocate(sizeof(LSAPR_POLICY_DNS_DOMAIN_INFO));
544 if (p == NULL)
545 return STATUS_INSUFFICIENT_RESOURCES;
546
547 /* Primary Domain Name */
548 AttributeSize = 0;
549 Status = LsapGetObjectAttribute(PolicyObject,
550 L"PolPrDmN",
551 NULL,
552 &AttributeSize);
553 if (!NT_SUCCESS(Status))
554 {
555 goto done;
556 }
557
558 if (AttributeSize > 0)
559 {
560 DomainName = MIDL_user_allocate(AttributeSize);
561 if (DomainName == NULL)
562 {
563 Status = STATUS_INSUFFICIENT_RESOURCES;
564 goto done;
565 }
566
567 Status = LsapGetObjectAttribute(PolicyObject,
568 L"PolPrDmN",
569 DomainName,
570 &AttributeSize);
571 if (Status == STATUS_SUCCESS)
572 {
573 DomainName->Buffer = (LPWSTR)((ULONG_PTR)DomainName + (ULONG_PTR)DomainName->Buffer);
574
575 TRACE("PrimaryDomainName: %wZ\n", DomainName);
576
577 p->Name.Buffer = MIDL_user_allocate(DomainName->MaximumLength);
578 if (p->Name.Buffer == NULL)
579 {
580 MIDL_user_free(DomainName);
581 Status = STATUS_INSUFFICIENT_RESOURCES;
582 goto done;
583 }
584
585 p->Name.Length = DomainName->Length;
586 p->Name.MaximumLength = DomainName->MaximumLength;
587 memcpy(p->Name.Buffer,
588 DomainName->Buffer,
589 DomainName->MaximumLength);
590 }
591
592 MIDL_user_free(DomainName);
593 }
594
595 /* Primary Domain SID */
596 AttributeSize = 0;
597 Status = LsapGetObjectAttribute(PolicyObject,
598 L"PolPrDmS",
599 NULL,
600 &AttributeSize);
601 if (!NT_SUCCESS(Status))
602 {
603 goto done;
604 }
605
606 if (AttributeSize > 0)
607 {
608 p->Sid = MIDL_user_allocate(AttributeSize);
609 if (p->Sid == NULL)
610 {
611 Status = STATUS_INSUFFICIENT_RESOURCES;
612 goto done;
613 }
614
615 Status = LsapGetObjectAttribute(PolicyObject,
616 L"PolPrDmS",
617 p->Sid,
618 &AttributeSize);
619 }
620
621 /* DNS Domain Name */
622 AttributeSize = 0;
623 Status = LsapGetObjectAttribute(PolicyObject,
624 L"PolDnDDN",
625 NULL,
626 &AttributeSize);
627 if (!NT_SUCCESS(Status))
628 goto done;
629
630 if (AttributeSize > 0)
631 {
632 DomainName = MIDL_user_allocate(AttributeSize);
633 if (DomainName == NULL)
634 {
635 Status = STATUS_INSUFFICIENT_RESOURCES;
636 goto done;
637 }
638
639 Status = LsapGetObjectAttribute(PolicyObject,
640 L"PolDnDDN",
641 DomainName,
642 &AttributeSize);
643 if (Status == STATUS_SUCCESS)
644 {
645 DomainName->Buffer = (LPWSTR)((ULONG_PTR)DomainName + (ULONG_PTR)DomainName->Buffer);
646
647 TRACE("DNS Domain Name: %wZ\n", DomainName);
648
649 p->DnsDomainName.Buffer = MIDL_user_allocate(DomainName->MaximumLength);
650 if (p->DnsDomainName.Buffer == NULL)
651 {
652 MIDL_user_free(DomainName);
653 Status = STATUS_INSUFFICIENT_RESOURCES;
654 goto done;
655 }
656
657 p->DnsDomainName.Length = DomainName->Length;
658 p->DnsDomainName.MaximumLength = DomainName->MaximumLength;
659 memcpy(p->DnsDomainName.Buffer,
660 DomainName->Buffer,
661 DomainName->MaximumLength);
662 }
663
664 MIDL_user_free(DomainName);
665 }
666
667 /* DNS Forest Name */
668 AttributeSize = 0;
669 Status = LsapGetObjectAttribute(PolicyObject,
670 L"PolDnTrN",
671 NULL,
672 &AttributeSize);
673 if (!NT_SUCCESS(Status))
674 goto done;
675
676 if (AttributeSize > 0)
677 {
678 DomainName = MIDL_user_allocate(AttributeSize);
679 if (DomainName == NULL)
680 {
681 Status = STATUS_INSUFFICIENT_RESOURCES;
682 goto done;
683 }
684
685 Status = LsapGetObjectAttribute(PolicyObject,
686 L"PolDnTrN",
687 DomainName,
688 &AttributeSize);
689 if (Status == STATUS_SUCCESS)
690 {
691 DomainName->Buffer = (LPWSTR)((ULONG_PTR)DomainName + (ULONG_PTR)DomainName->Buffer);
692
693 TRACE("DNS Forest Name: %wZ\n", DomainName);
694
695 p->DnsForestName.Buffer = MIDL_user_allocate(DomainName->MaximumLength);
696 if (p->DnsForestName.Buffer == NULL)
697 {
698 MIDL_user_free(DomainName);
699 Status = STATUS_INSUFFICIENT_RESOURCES;
700 goto done;
701 }
702
703 p->DnsForestName.Length = DomainName->Length;
704 p->DnsForestName.MaximumLength = DomainName->MaximumLength;
705 memcpy(p->DnsForestName.Buffer,
706 DomainName->Buffer,
707 DomainName->MaximumLength);
708 }
709
710 MIDL_user_free(DomainName);
711 }
712
713 /* DNS Domain GUID */
714 AttributeSize = sizeof(GUID);
715 Status = LsapGetObjectAttribute(PolicyObject,
716 L"PolDnDmG",
717 &(p->DomainGuid),
718 &AttributeSize);
719 if (!NT_SUCCESS(Status))
720 goto done;
721
722 *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
723
724 done:
725 if (!NT_SUCCESS(Status))
726 {
727 if (p)
728 {
729 if (p->Name.Buffer)
730 MIDL_user_free(p->Name.Buffer);
731
732 if (p->DnsDomainName.Buffer)
733 MIDL_user_free(p->DnsDomainName.Buffer);
734
735 if (p->DnsForestName.Buffer)
736 MIDL_user_free(p->DnsForestName.Buffer);
737
738 if (p->Sid)
739 MIDL_user_free(p->Sid);
740
741 MIDL_user_free(p);
742 }
743 }
744
745 return Status;
746 }
747
748
749 NTSTATUS
750 LsarQueryDnsDomainInt(PLSA_DB_OBJECT PolicyObject,
751 PLSAPR_POLICY_INFORMATION *PolicyInformation)
752 {
753 FIXME("\n");
754 *PolicyInformation = NULL;
755 return STATUS_NOT_IMPLEMENTED;
756 }
757
758
759 NTSTATUS
760 LsarQueryLocalAccountDomain(PLSA_DB_OBJECT PolicyObject,
761 PLSAPR_POLICY_INFORMATION *PolicyInformation)
762 {
763 FIXME("\n");
764 *PolicyInformation = NULL;
765 return STATUS_NOT_IMPLEMENTED;
766 }
767
768
769 NTSTATUS
770 LsarSetAuditLog(PLSA_DB_OBJECT PolicyObject,
771 PPOLICY_AUDIT_LOG_INFO Info)
772 {
773 TRACE("(%p %p)\n", PolicyObject, Info);
774
775 return LsapSetObjectAttribute(PolicyObject,
776 L"PolAdtLg",
777 Info,
778 sizeof(POLICY_AUDIT_LOG_INFO));
779 }
780
781
782 NTSTATUS
783 LsarSetAuditEvents(PLSA_DB_OBJECT PolicyObject,
784 PLSAPR_POLICY_AUDIT_EVENTS_INFO Info)
785 {
786 FIXME("\n");
787 return STATUS_NOT_IMPLEMENTED;
788 }
789
790
791 NTSTATUS
792 LsarSetPrimaryDomain(PLSA_DB_OBJECT PolicyObject,
793 PLSAPR_POLICY_PRIMARY_DOM_INFO Info)
794 {
795 PUNICODE_STRING Buffer;
796 ULONG Length = 0;
797 NTSTATUS Status;
798 LPWSTR Ptr;
799
800 TRACE("(%p %p)\n", PolicyObject, Info);
801
802 Length = sizeof(UNICODE_STRING) + Info->Name.MaximumLength;
803 Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
804 0,
805 Length);
806 if (Buffer == NULL)
807 return STATUS_INSUFFICIENT_RESOURCES;
808
809 Buffer->Length = Info->Name.Length;
810 Buffer->MaximumLength = Info->Name.MaximumLength;
811 Buffer->Buffer = (LPWSTR)sizeof(UNICODE_STRING);
812 Ptr = (LPWSTR)((ULONG_PTR)Buffer + sizeof(UNICODE_STRING));
813 memcpy(Ptr, Info->Name.Buffer, Info->Name.MaximumLength);
814
815 Status = LsapSetObjectAttribute(PolicyObject,
816 L"PolPrDmN",
817 Buffer,
818 Length);
819
820 RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
821
822 if (!NT_SUCCESS(Status))
823 return Status;
824
825 Length = 0;
826 if (Info->Sid != NULL)
827 Length = RtlLengthSid(Info->Sid);
828
829 Status = LsapSetObjectAttribute(PolicyObject,
830 L"PolPrDmS",
831 (LPBYTE)Info->Sid,
832 Length);
833
834 return Status;
835 }
836
837
838 NTSTATUS
839 LsarSetAccountDomain(PLSA_DB_OBJECT PolicyObject,
840 PLSAPR_POLICY_ACCOUNT_DOM_INFO Info)
841 {
842 PUNICODE_STRING Buffer;
843 ULONG Length = 0;
844 NTSTATUS Status;
845 LPWSTR Ptr;
846
847 TRACE("(%p %p)\n", PolicyObject, Info);
848
849 Length = sizeof(UNICODE_STRING) + Info->DomainName.MaximumLength;
850 Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
851 0,
852 Length);
853 if (Buffer == NULL)
854 return STATUS_INSUFFICIENT_RESOURCES;
855
856 Buffer->Length = Info->DomainName.Length;
857 Buffer->MaximumLength = Info->DomainName.MaximumLength;
858 Buffer->Buffer = (LPWSTR)sizeof(UNICODE_STRING);
859 Ptr = (LPWSTR)((ULONG_PTR)Buffer + sizeof(UNICODE_STRING));
860 memcpy(Ptr, Info->DomainName.Buffer, Info->DomainName.MaximumLength);
861
862 Status = LsapSetObjectAttribute(PolicyObject,
863 L"PolAcDmN",
864 Buffer,
865 Length);
866
867 RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
868
869 if (!NT_SUCCESS(Status))
870 return Status;
871
872 Length = 0;
873 if (Info->Sid != NULL)
874 Length = RtlLengthSid(Info->Sid);
875
876 Status = LsapSetObjectAttribute(PolicyObject,
877 L"PolAcDmS",
878 (LPBYTE)Info->Sid,
879 Length);
880
881 return Status;
882 }
883
884
885 NTSTATUS
886 LsarSetServerRole(PLSA_DB_OBJECT PolicyObject,
887 PPOLICY_LSA_SERVER_ROLE_INFO Info)
888 {
889 TRACE("(%p %p)\n", PolicyObject, Info);
890
891 return LsapSetObjectAttribute(PolicyObject,
892 L"PolSrvRo",
893 Info,
894 sizeof(POLICY_LSA_SERVER_ROLE_INFO));
895 }
896
897
898 NTSTATUS
899 LsarSetReplicaSource(PLSA_DB_OBJECT PolicyObject,
900 PPOLICY_LSA_REPLICA_SRCE_INFO Info)
901 {
902 FIXME("\n");
903 return STATUS_NOT_IMPLEMENTED;
904 }
905
906
907 NTSTATUS
908 LsarSetDefaultQuota(PLSA_DB_OBJECT PolicyObject,
909 PPOLICY_DEFAULT_QUOTA_INFO Info)
910 {
911 TRACE("(%p %p)\n", PolicyObject, Info);
912
913 return LsapSetObjectAttribute(PolicyObject,
914 L"DefQuota",
915 Info,
916 sizeof(POLICY_DEFAULT_QUOTA_INFO));
917 }
918
919
920 NTSTATUS
921 LsarSetModification(PLSA_DB_OBJECT PolicyObject,
922 PPOLICY_MODIFICATION_INFO Info)
923 {
924 TRACE("(%p %p)\n", PolicyObject, Info);
925
926 return LsapSetObjectAttribute(PolicyObject,
927 L"PolMod",
928 Info,
929 sizeof(POLICY_MODIFICATION_INFO));
930 }
931
932
933 NTSTATUS
934 LsarSetAuditFull(PLSA_DB_OBJECT PolicyObject,
935 PPOLICY_AUDIT_FULL_QUERY_INFO Info)
936 {
937 PPOLICY_AUDIT_FULL_QUERY_INFO AuditFullInfo = NULL;
938 ULONG AttributeSize;
939 NTSTATUS Status;
940
941 TRACE("(%p %p)\n", PolicyObject, Info);
942
943 AttributeSize = sizeof(POLICY_AUDIT_FULL_QUERY_INFO);
944 AuditFullInfo = MIDL_user_allocate(AttributeSize);
945 if (AuditFullInfo == NULL)
946 return STATUS_INSUFFICIENT_RESOURCES;
947
948 Status = LsapGetObjectAttribute(PolicyObject,
949 L"PolAdtFl",
950 AuditFullInfo,
951 &AttributeSize);
952 if (!NT_SUCCESS(Status))
953 goto done;
954
955 AuditFullInfo->ShutDownOnFull = Info->ShutDownOnFull;
956
957 Status = LsapSetObjectAttribute(PolicyObject,
958 L"PolAdtFl",
959 AuditFullInfo,
960 AttributeSize);
961
962 done:
963 if (AuditFullInfo != NULL)
964 MIDL_user_free(AuditFullInfo);
965
966 return Status;
967 }
968
969
970 NTSTATUS
971 LsarSetDnsDomain(PLSA_DB_OBJECT PolicyObject,
972 PLSAPR_POLICY_DNS_DOMAIN_INFO Info)
973 {
974 FIXME("\n");
975 return STATUS_NOT_IMPLEMENTED;
976 }
977
978
979 NTSTATUS
980 LsarSetDnsDomainInt(PLSA_DB_OBJECT PolicyObject,
981 PLSAPR_POLICY_DNS_DOMAIN_INFO Info)
982 {
983 FIXME("\n");
984 return STATUS_NOT_IMPLEMENTED;
985 }
986
987
988 NTSTATUS
989 LsarSetLocalAccountDomain(PLSA_DB_OBJECT PolicyObject,
990 PLSAPR_POLICY_ACCOUNT_DOM_INFO Info)
991 {
992 FIXME("\n");
993 return STATUS_NOT_IMPLEMENTED;
994 }
995
996 /* EOF */