[LSASRV]
authorEric Kohl <eric.kohl@reactos.org>
Wed, 26 Sep 2012 22:51:12 +0000 (22:51 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Wed, 26 Sep 2012 22:51:12 +0000 (22:51 +0000)
- Implement the PolicyDnsDomainInformation class of LsarQueryInformationPolicy and enable the PolicyModificationInformation class.
- Add required attributes to the initialization code.

svn path=/trunk/; revision=57397

reactos/dll/win32/lsasrv/database.c
reactos/dll/win32/lsasrv/lsarpc.c
reactos/dll/win32/lsasrv/policy.c

index b5d4fc7..de113c5 100644 (file)
@@ -231,7 +231,7 @@ LsapCreateDatabaseObjects(VOID)
     POLICY_MODIFICATION_INFO ModificationInfo;
     POLICY_AUDIT_FULL_QUERY_INFO AuditFullInfo = {FALSE, FALSE};
     POLICY_AUDIT_LOG_INFO AuditLogInfo;
-
+    GUID DnsDomainGuid;
     PLSA_DB_OBJECT PolicyObject = NULL;
     PSID AccountDomainSid = NULL;
     ULONG AuditEventsCount;
@@ -255,6 +255,7 @@ LsapCreateDatabaseObjects(VOID)
     AuditLogInfo.TimeToShutdown.QuadPart = 0;          // LARGE_INTEGER
     AuditLogInfo.NextAuditRecordId = 0;                        // DWORD
 
+    /* Initialize the Audit Events attribute */
     AuditEventsCount = AuditCategoryAccountLogon - AuditCategorySystem + 1;
     AuditEventsSize = sizeof(LSAP_POLICY_AUDIT_EVENTS_DATA) + AuditEventsCount * sizeof(DWORD);
     AuditEventsInfo = RtlAllocateHeap(RtlGetProcessHeap(),
@@ -268,6 +269,9 @@ LsapCreateDatabaseObjects(VOID)
     for (i = 0; i < AuditEventsCount; i++)
         AuditEventsInfo->AuditEvents[i] = 0;
 
+    /* Initialize the DNS Domain GUID attribute */
+    memset(&DnsDomainGuid, 0, sizeof(GUID));
+
     /* Initialize the modification attribute */
     ModificationInfo.ModifiedId.QuadPart = 0;
     NtQuerySystemTime(&ModificationInfo.DatabaseCreationTime);
@@ -336,6 +340,24 @@ LsapCreateDatabaseObjects(VOID)
                            &AuditEventsInfo,
                            AuditEventsSize);
 
+    /* Set the DNS Domain Name attribute */
+    LsapSetObjectAttribute(PolicyObject,
+                           L"PolDnDDN",
+                           NULL,
+                           0);
+
+    /* Set the DNS Forest Name attribute */
+    LsapSetObjectAttribute(PolicyObject,
+                           L"PolDnTrN",
+                           NULL,
+                           0);
+
+    /* Set the DNS Domain GUID attribute */
+    LsapSetObjectAttribute(PolicyObject,
+                           L"PolDnDmG",
+                           &DnsDomainGuid,
+                           sizeof(GUID));
+
 done:
     if (AuditEventsInfo != NULL)
         RtlFreeHeap(RtlGetProcessHeap(), 0, AuditEventsInfo);
index 9ec67ee..5e9742d 100644 (file)
@@ -212,6 +212,7 @@ NTSTATUS WINAPI LsarQueryInformationPolicy(
         case PolicyLsaServerRoleInformation:
         case PolicyReplicaSourceInformation:
         case PolicyDefaultQuotaInformation:
+        case PolicyModificationInformation:
         case PolicyDnsDomainInformation:
         case PolicyDnsDomainInformationInt:
         case PolicyLocalAccountDomainInformation:
index 24cc3ca..91e3b58 100644 (file)
@@ -612,42 +612,215 @@ LsarQueryDnsDomain(PLSA_DB_OBJECT PolicyObject,
                    PLSAPR_POLICY_INFORMATION *PolicyInformation)
 {
     PLSAPR_POLICY_DNS_DOMAIN_INFO p = NULL;
+    PUNICODE_STRING DomainName;
+    ULONG AttributeSize;
+    NTSTATUS Status;
+
+    *PolicyInformation = NULL;
 
     p = MIDL_user_allocate(sizeof(LSAPR_POLICY_DNS_DOMAIN_INFO));
     if (p == NULL)
         return STATUS_INSUFFICIENT_RESOURCES;
 
-    p->Name.Length = 0;
-    p->Name.MaximumLength = 0;
-    p->Name.Buffer = NULL;
-#if 0
-            p->Name.Length = wcslen(L"COMPUTERNAME");
-            p->Name.MaximumLength = p->Name.Length + sizeof(WCHAR);
-            p->Name.Buffer = MIDL_user_allocate(p->Name.MaximumLength);
+    /* Primary Domain Name */
+    AttributeSize = 0;
+    Status = LsapGetObjectAttribute(PolicyObject,
+                                    L"PolPrDmN",
+                                    NULL,
+                                    &AttributeSize);
+    if (!NT_SUCCESS(Status))
+    {
+        goto done;
+    }
+
+    if (AttributeSize > 0)
+    {
+        DomainName = MIDL_user_allocate(AttributeSize);
+        if (DomainName == NULL)
+        {
+            Status = STATUS_INSUFFICIENT_RESOURCES;
+            goto done;
+        }
+
+        Status = LsapGetObjectAttribute(PolicyObject,
+                                        L"PolPrDmN",
+                                        DomainName,
+                                        &AttributeSize);
+        if (Status == STATUS_SUCCESS)
+        {
+            DomainName->Buffer = (LPWSTR)((ULONG_PTR)DomainName + (ULONG_PTR)DomainName->Buffer);
+
+            TRACE("PrimaryDomainName: %wZ\n", DomainName);
+
+            p->Name.Buffer = MIDL_user_allocate(DomainName->MaximumLength);
             if (p->Name.Buffer == NULL)
             {
-                MIDL_user_free(p);
-                return STATUS_INSUFFICIENT_RESOURCES;
+                MIDL_user_free(DomainName);
+                Status = STATUS_INSUFFICIENT_RESOURCES;
+                goto done;
+            }
+
+            p->Name.Length = DomainName->Length;
+            p->Name.MaximumLength = DomainName->MaximumLength;
+            memcpy(p->Name.Buffer,
+                   DomainName->Buffer,
+                   DomainName->MaximumLength);
+        }
+
+        MIDL_user_free(DomainName);
+    }
+
+    /* Primary Domain SID */
+    AttributeSize = 0;
+    Status = LsapGetObjectAttribute(PolicyObject,
+                                    L"PolPrDmS",
+                                    NULL,
+                                    &AttributeSize);
+    if (!NT_SUCCESS(Status))
+    {
+        goto done;
+    }
+
+    if (AttributeSize > 0)
+    {
+        p->Sid = MIDL_user_allocate(AttributeSize);
+        if (p->Sid == NULL)
+        {
+            Status = STATUS_INSUFFICIENT_RESOURCES;
+            goto done;
+        }
+
+        Status = LsapGetObjectAttribute(PolicyObject,
+                                        L"PolPrDmS",
+                                        p->Sid,
+                                        &AttributeSize);
+    }
+
+    /* DNS Domain Name */
+    AttributeSize = 0;
+    Status = LsapGetObjectAttribute(PolicyObject,
+                                    L"PolDnDDN",
+                                    NULL,
+                                    &AttributeSize);
+    if (!NT_SUCCESS(Status))
+        goto done;
+
+    if (AttributeSize > 0)
+    {
+        DomainName = MIDL_user_allocate(AttributeSize);
+        if (DomainName == NULL)
+        {
+            Status = STATUS_INSUFFICIENT_RESOURCES;
+            goto done;
+        }
+
+        Status = LsapGetObjectAttribute(PolicyObject,
+                                        L"PolDnDDN",
+                                        DomainName,
+                                        &AttributeSize);
+        if (Status == STATUS_SUCCESS)
+        {
+            DomainName->Buffer = (LPWSTR)((ULONG_PTR)DomainName + (ULONG_PTR)DomainName->Buffer);
+
+            TRACE("DNS Domain Name: %wZ\n", DomainName);
+
+            p->DnsDomainName.Buffer = MIDL_user_allocate(DomainName->MaximumLength);
+            if (p->DnsDomainName.Buffer == NULL)
+            {
+                MIDL_user_free(DomainName);
+                Status = STATUS_INSUFFICIENT_RESOURCES;
+                goto done;
             }
 
-            wcscpy(p->Name.Buffer, L"COMPUTERNAME");
-#endif
+            p->DnsDomainName.Length = DomainName->Length;
+            p->DnsDomainName.MaximumLength = DomainName->MaximumLength;
+            memcpy(p->DnsDomainName.Buffer,
+                   DomainName->Buffer,
+                   DomainName->MaximumLength);
+        }
 
-    p->DnsDomainName.Length = 0;
-    p->DnsDomainName.MaximumLength = 0;
-    p->DnsDomainName.Buffer = NULL;
+        MIDL_user_free(DomainName);
+    }
 
-    p->DnsForestName.Length = 0;
-    p->DnsForestName.MaximumLength = 0;
-    p->DnsForestName.Buffer = 0;
+    /* DNS Forest Name */
+    AttributeSize = 0;
+    Status = LsapGetObjectAttribute(PolicyObject,
+                                    L"PolDnTrN",
+                                    NULL,
+                                    &AttributeSize);
+    if (!NT_SUCCESS(Status))
+        goto done;
 
-    memset(&p->DomainGuid, 0, sizeof(GUID));
+    if (AttributeSize > 0)
+    {
+        DomainName = MIDL_user_allocate(AttributeSize);
+        if (DomainName == NULL)
+        {
+            Status = STATUS_INSUFFICIENT_RESOURCES;
+            goto done;
+        }
 
-    p->Sid = NULL; /* no domain, no workgroup */
+        Status = LsapGetObjectAttribute(PolicyObject,
+                                        L"PolDnTrN",
+                                        DomainName,
+                                        &AttributeSize);
+        if (Status == STATUS_SUCCESS)
+        {
+            DomainName->Buffer = (LPWSTR)((ULONG_PTR)DomainName + (ULONG_PTR)DomainName->Buffer);
+
+            TRACE("DNS Forest Name: %wZ\n", DomainName);
+
+            p->DnsForestName.Buffer = MIDL_user_allocate(DomainName->MaximumLength);
+            if (p->DnsForestName.Buffer == NULL)
+            {
+                MIDL_user_free(DomainName);
+                Status = STATUS_INSUFFICIENT_RESOURCES;
+                goto done;
+            }
+
+            p->DnsForestName.Length = DomainName->Length;
+            p->DnsForestName.MaximumLength = DomainName->MaximumLength;
+            memcpy(p->DnsForestName.Buffer,
+                   DomainName->Buffer,
+                   DomainName->MaximumLength);
+        }
+
+        MIDL_user_free(DomainName);
+    }
+
+    /* DNS Domain GUID */
+    AttributeSize = sizeof(GUID);
+    Status = LsapGetObjectAttribute(PolicyObject,
+                                    L"PolDnDmG",
+                                    &(p->DomainGuid),
+                                    &AttributeSize);
+    if (!NT_SUCCESS(Status))
+        goto done;
 
     *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
 
-    return STATUS_SUCCESS;
+done:
+    if (!NT_SUCCESS(Status))
+    {
+        if (p)
+        {
+            if (p->Name.Buffer)
+                MIDL_user_free(p->Name.Buffer);
+
+            if (p->DnsDomainName.Buffer)
+                MIDL_user_free(p->DnsDomainName.Buffer);
+
+            if (p->DnsForestName.Buffer)
+                MIDL_user_free(p->DnsForestName.Buffer);
+
+            if (p->Sid)
+                MIDL_user_free(p->Sid);
+
+            MIDL_user_free(p);
+        }
+    }
+
+    return Status;
 }