Author: ekohl
Date: Fri Sep 23 10:01:22 2011
New Revision: 53808
URL:
http://svn.reactos.org/svn/reactos?rev=53808&view=rev
Log:
[LSASRV]
Implement the PolicyPrimaryDomainInformation and PolicyAccountDomainInformation cases of
LsarQueryInformationPolicy.
Modified:
trunk/reactos/dll/win32/lsasrv/lsarpc.c
trunk/reactos/dll/win32/lsasrv/lsasrv.h
trunk/reactos/dll/win32/lsasrv/policy.c
Modified: trunk/reactos/dll/win32/lsasrv/lsarpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsarpc.c?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsarpc.c [iso-8859-1] Fri Sep 23 10:01:22 2011
@@ -200,113 +200,25 @@
switch (InformationClass)
{
- case PolicyAuditEventsInformation: /* 2 */
- {
- PLSAPR_POLICY_AUDIT_EVENTS_INFO p =
MIDL_user_allocate(sizeof(LSAPR_POLICY_AUDIT_EVENTS_INFO));
- if (p == NULL)
- return STATUS_INSUFFICIENT_RESOURCES;
-
- p->AuditingMode = FALSE; /* no auditing */
- p->EventAuditingOptions = NULL;
- p->MaximumAuditEventCount = 0;
-
- *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
- }
- break;
+ case PolicyAuditEventsInformation: /* 2 */
+ Status = LsarQueryAuditEvents(PolicyHandle,
+ PolicyInformation);
+ break;
case PolicyPrimaryDomainInformation: /* 3 */
- {
- PLSAPR_POLICY_PRIMARY_DOM_INFO p =
MIDL_user_allocate(sizeof(LSAPR_POLICY_PRIMARY_DOM_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);
- if (p->Name.Buffer == NULL)
- {
- MIDL_user_free(p);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- wcscpy(p->Name.Buffer, L"COMPUTERNAME");
-#endif
-
- p->Sid = NULL; /* no domain, no workgroup */
-
- *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
- }
- break;
+ Status = LsarQueryPrimaryDomain(PolicyHandle,
+ PolicyInformation);
+ break;
case PolicyAccountDomainInformation: /* 5 */
- {
- PLSAPR_POLICY_ACCOUNT_DOM_INFO p =
MIDL_user_allocate(sizeof(LSAPR_POLICY_ACCOUNT_DOM_INFO));
- if (p == NULL)
- return STATUS_INSUFFICIENT_RESOURCES;
-
- p->DomainName.Length = 0;
- p->DomainName.MaximumLength = 0;
- p->DomainName.Buffer = NULL;
-#if 0
- p->DomainName.Length = wcslen(L"COMPUTERNAME");
- p->DomainName.MaximumLength = p->DomainName.Length + sizeof(WCHAR);
- p->DomainName.Buffer =
MIDL_user_allocate(p->DomainName.MaximumLength);
- if (p->DomainName.Buffer == NULL)
- {
- MIDL_user_free(p);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- wcscpy(p->DomainName.Buffer, L"COMPUTERNAME");
-#endif
-
- p->Sid = NULL; /* no domain, no workgroup */
-
- *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
- }
- break;
-
- case PolicyDnsDomainInformation: /* 12 (0xc) */
- {
- PLSAPR_POLICY_DNS_DOMAIN_INFO 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);
- if (p->Name.Buffer == NULL)
- {
- MIDL_user_free(p);
- return STATUS_INSUFFICIENT_RESOURCES;
- }
-
- wcscpy(p->Name.Buffer, L"COMPUTERNAME");
-#endif
-
- p->DnsDomainName.Length = 0;
- p->DnsDomainName.MaximumLength = 0;
- p->DnsDomainName.Buffer = NULL;
-
- p->DnsForestName.Length = 0;
- p->DnsForestName.MaximumLength = 0;
- p->DnsForestName.Buffer = 0;
-
- memset(&p->DomainGuid, 0, sizeof(GUID));
-
- p->Sid = NULL; /* no domain, no workgroup */
-
- *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
- }
- break;
+ Status = LsarQueryAccountDomain(PolicyHandle,
+ PolicyInformation);
+ break;
+
+ case PolicyDnsDomainInformation: /* 12 (0xc) */
+ Status = LsarQueryDnsDomain(PolicyHandle,
+ PolicyInformation);
+ break;
case PolicyAuditLogInformation:
case PolicyPdAccountInformation:
@@ -317,13 +229,12 @@
case PolicyAuditFullSetInformation:
case PolicyAuditFullQueryInformation:
case PolicyEfsInformation:
- {
FIXME("category not implemented\n");
- return STATUS_UNSUCCESSFUL;
- }
- }
-
- return STATUS_SUCCESS;
+ Status = STATUS_UNSUCCESSFUL;
+ break;
+ }
+
+ return Status;
}
Modified: trunk/reactos/dll/win32/lsasrv/lsasrv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/lsasrv.h?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/lsasrv.h [iso-8859-1] Fri Sep 23 10:01:22 2011
@@ -92,6 +92,22 @@
/* policy.c */
NTSTATUS
+LsarQueryAuditEvents(LSAPR_HANDLE PolicyHandle,
+ PLSAPR_POLICY_INFORMATION *PolicyInformation);
+
+NTSTATUS
+LsarQueryPrimaryDomain(LSAPR_HANDLE PolicyHandle,
+ PLSAPR_POLICY_INFORMATION *PolicyInformation);
+
+NTSTATUS
+LsarQueryAccountDomain(LSAPR_HANDLE PolicyHandle,
+ PLSAPR_POLICY_INFORMATION *PolicyInformation);
+
+NTSTATUS
+LsarQueryDnsDomain(LSAPR_HANDLE PolicyHandle,
+ PLSAPR_POLICY_INFORMATION *PolicyInformation);
+
+NTSTATUS
LsarSetPrimaryDomain(LSAPR_HANDLE PolicyObject,
PLSAPR_POLICY_PRIMARY_DOM_INFO Info);
Modified: trunk/reactos/dll/win32/lsasrv/policy.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/lsasrv/policy.c?…
==============================================================================
--- trunk/reactos/dll/win32/lsasrv/policy.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/lsasrv/policy.c [iso-8859-1] Fri Sep 23 10:01:22 2011
@@ -115,4 +115,286 @@
return STATUS_NOT_IMPLEMENTED;
}
+
+NTSTATUS
+LsarQueryAuditEvents(LSAPR_HANDLE PolicyHandle,
+ PLSAPR_POLICY_INFORMATION *PolicyInformation)
+{
+ PLSAPR_POLICY_AUDIT_EVENTS_INFO p = NULL;
+
+ p = MIDL_user_allocate(sizeof(LSAPR_POLICY_AUDIT_EVENTS_INFO));
+ if (p == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ p->AuditingMode = FALSE; /* no auditing */
+ p->EventAuditingOptions = NULL;
+ p->MaximumAuditEventCount = 0;
+
+ *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
+
+ return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+LsarQueryPrimaryDomain(LSAPR_HANDLE PolicyHandle,
+ PLSAPR_POLICY_INFORMATION *PolicyInformation)
+{
+ PLSAPR_POLICY_PRIMARY_DOM_INFO p = NULL;
+ PUNICODE_STRING DomainName;
+ ULONG AttributeSize;
+ NTSTATUS Status;
+
+ *PolicyInformation = NULL;
+
+ p = MIDL_user_allocate(sizeof(LSAPR_POLICY_PRIMARY_DOM_INFO));
+ if (p == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ /* Domain Name */
+ Status = LsapGetObjectAttribute((PLSA_DB_OBJECT)PolicyHandle,
+ 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((PLSA_DB_OBJECT)PolicyHandle,
+ 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(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);
+ }
+
+ /* Domain SID */
+ AttributeSize = 0;
+ Status = LsapGetObjectAttribute((PLSA_DB_OBJECT)PolicyHandle,
+ 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((PLSA_DB_OBJECT)PolicyHandle,
+ L"PolPrDmS",
+ p->Sid,
+ &AttributeSize);
+ }
+
+ *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
+
+Done:
+ if (!NT_SUCCESS(Status))
+ {
+ if (p)
+ {
+ if (p->Name.Buffer)
+ MIDL_user_free(p->Name.Buffer);
+
+ if (p->Sid)
+ MIDL_user_free(p->Sid);
+
+ MIDL_user_free(p);
+ }
+ }
+
+ return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+LsarQueryAccountDomain(LSAPR_HANDLE PolicyHandle,
+ PLSAPR_POLICY_INFORMATION *PolicyInformation)
+{
+ PLSAPR_POLICY_ACCOUNT_DOM_INFO p = NULL;
+ PUNICODE_STRING DomainName;
+ ULONG AttributeSize;
+ NTSTATUS Status;
+
+ *PolicyInformation = NULL;
+
+ p = MIDL_user_allocate(sizeof(LSAPR_POLICY_ACCOUNT_DOM_INFO));
+ if (p == NULL)
+ return STATUS_INSUFFICIENT_RESOURCES;
+
+ /* Domain Name */
+ Status = LsapGetObjectAttribute((PLSA_DB_OBJECT)PolicyHandle,
+ L"PolAcDmN",
+ 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((PLSA_DB_OBJECT)PolicyHandle,
+ L"PolAcDmN",
+ DomainName,
+ &AttributeSize);
+ if (Status == STATUS_SUCCESS)
+ {
+ DomainName->Buffer = (LPWSTR)((ULONG_PTR)DomainName +
(ULONG_PTR)DomainName->Buffer);
+
+ TRACE("AccountDomainName: %wZ\n", DomainName);
+
+ p->DomainName.Buffer = MIDL_user_allocate(DomainName->MaximumLength);
+ if (p->DomainName.Buffer == NULL)
+ {
+ MIDL_user_free(DomainName);
+ Status = STATUS_INSUFFICIENT_RESOURCES;
+ goto Done;
+ }
+
+ p->DomainName.Length = DomainName->Length;
+ p->DomainName.MaximumLength = DomainName->MaximumLength;
+ memcpy(p->DomainName.Buffer,
+ DomainName->Buffer,
+ DomainName->MaximumLength);
+ }
+
+ MIDL_user_free(DomainName);
+ }
+
+ /* Domain SID */
+ AttributeSize = 0;
+ Status = LsapGetObjectAttribute((PLSA_DB_OBJECT)PolicyHandle,
+ L"PolAcDmS",
+ 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((PLSA_DB_OBJECT)PolicyHandle,
+ L"PolAcDmS",
+ p->Sid,
+ &AttributeSize);
+ }
+
+ *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
+
+Done:
+ if (!NT_SUCCESS(Status))
+ {
+ if (p)
+ {
+ if (p->DomainName.Buffer)
+ MIDL_user_free(p->DomainName.Buffer);
+
+ if (p->Sid)
+ MIDL_user_free(p->Sid);
+
+ MIDL_user_free(p);
+ }
+ }
+
+ return STATUS_SUCCESS;
+}
+
+
+NTSTATUS
+LsarQueryDnsDomain(LSAPR_HANDLE PolicyHandle,
+ PLSAPR_POLICY_INFORMATION *PolicyInformation)
+{
+ PLSAPR_POLICY_DNS_DOMAIN_INFO p = 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);
+ if (p->Name.Buffer == NULL)
+ {
+ MIDL_user_free(p);
+ return STATUS_INSUFFICIENT_RESOURCES;
+ }
+
+ wcscpy(p->Name.Buffer, L"COMPUTERNAME");
+#endif
+
+ p->DnsDomainName.Length = 0;
+ p->DnsDomainName.MaximumLength = 0;
+ p->DnsDomainName.Buffer = NULL;
+
+ p->DnsForestName.Length = 0;
+ p->DnsForestName.MaximumLength = 0;
+ p->DnsForestName.Buffer = 0;
+
+ memset(&p->DomainGuid, 0, sizeof(GUID));
+
+ p->Sid = NULL; /* no domain, no workgroup */
+
+ *PolicyInformation = (PLSAPR_POLICY_INFORMATION)p;
+
+ return STATUS_SUCCESS;
+}
+
/* EOF */