Robert Reif : advapi32: LsaQueryInformationPolicy update.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Aug 1 04:57:38 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 3879fef21d505783c7e8ce362928b4504971c26f
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=3879fef21d505783c7e8ce362928b4504971c26f

Author: Robert Reif <reif at earthlink.net>
Date:   Mon Jul 31 17:53:32 2006 -0400

advapi32: LsaQueryInformationPolicy update.

Update LsaQueryInformationPolicy to use correct computer name and SID.
Add support for PolicyDnsDomainInformation.

---

 dlls/advapi32/lsa.c |  114 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 104 insertions(+), 10 deletions(-)

diff --git a/dlls/advapi32/lsa.c b/dlls/advapi32/lsa.c
index 62b2075..44ae295 100644
--- a/dlls/advapi32/lsa.c
+++ b/dlls/advapi32/lsa.c
@@ -394,10 +394,9 @@ NTSTATUS WINAPI LsaQueryInformationPolic
             {
                 POLICY_PRIMARY_DOMAIN_INFO ppdi;
                 SID sid;
+                DWORD padding[3];
             };
 
-            SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
-
             struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*xdi));
             HKEY key;
             BOOL useDefault = TRUE;
@@ -431,15 +430,111 @@ NTSTATUS WINAPI LsaQueryInformationPolic
                 RegCloseKey(key);
             }
             if (useDefault)
-                RtlCreateUnicodeStringFromAsciiz(&(xdi->ppdi.Name), "DOMAIN");
-
+            {
+                DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
+                LPWSTR buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize * sizeof(WCHAR));
+                if (GetComputerNameW(buf, &dwSize))
+                {
+                    xdi->ppdi.Name.Buffer = buf;
+                    xdi->ppdi.Name.Length = dwSize * sizeof(WCHAR);
+                }
+            }
+                                                                                
             TRACE("setting domain to %s\n", debugstr_w(xdi->ppdi.Name.Buffer));
-
+                                                                                
             xdi->ppdi.Sid = &(xdi->sid);
-            xdi->sid.Revision = SID_REVISION;
-            xdi->sid.SubAuthorityCount = 1;
-            xdi->sid.IdentifierAuthority = localSidAuthority;
-            xdi->sid.SubAuthority[0] = SECURITY_LOCAL_SYSTEM_RID;
+                                                                                
+            /* read the computer SID from the registry */
+            if (!ADVAPI_GetComputerSid(&(xdi->sid)))
+            {
+                SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
+                                                                                
+                xdi->sid.Revision = SID_REVISION;
+                xdi->sid.SubAuthorityCount = 4;
+                xdi->sid.IdentifierAuthority = localSidAuthority;
+                xdi->sid.SubAuthority[0] = SECURITY_NT_NON_UNIQUE;
+                xdi->sid.SubAuthority[1] = 0;
+                xdi->sid.SubAuthority[2] = 0;
+                xdi->sid.SubAuthority[3] = 0;
+            }
+                                                                                
+            TRACE("setting SID to %s\n", debugstr_sid(&xdi->sid));
+
+            *Buffer = xdi;
+        }
+        break;
+        case  PolicyDnsDomainInformation:	/* 12 (0xc) */
+        {
+            struct di
+            {
+                POLICY_DNS_DOMAIN_INFO pddi;
+                SID sid;
+                DWORD padding[3];
+            };
+
+            struct di * xdi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*xdi));
+            HKEY key;
+            BOOL useDefault = TRUE;
+            LONG ret;
+
+            if ((ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
+                 "System\\CurrentControlSet\\Services\\VxD\\VNETSUP", 0,
+                 KEY_READ, &key)) == ERROR_SUCCESS)
+            {
+                DWORD size = 0;
+                static const WCHAR wg[] = { 'W','o','r','k','g','r','o','u','p',0 };
+
+                ret = RegQueryValueExW(key, wg, NULL, NULL, NULL, &size);
+                if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
+                {
+                    xdi->pddi.Name.Buffer = HeapAlloc(GetProcessHeap(),
+                                                      HEAP_ZERO_MEMORY, size);
+
+                    if ((ret = RegQueryValueExW(key, wg, NULL, NULL,
+                         (LPBYTE)xdi->pddi.Name.Buffer, &size)) == ERROR_SUCCESS)
+                    {
+                        xdi->pddi.Name.Length = (USHORT)size;
+                        useDefault = FALSE;
+                    }
+                    else
+                    {
+                        HeapFree(GetProcessHeap(), 0, xdi->pddi.Name.Buffer);
+                        xdi->pddi.Name.Buffer = NULL;
+                    }
+                }
+                RegCloseKey(key);
+            }
+            if (useDefault)
+            {
+                DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
+                LPWSTR buf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize * sizeof(WCHAR));
+                if (GetComputerNameW(buf, &dwSize))
+                {
+                    xdi->pddi.Name.Buffer = buf;
+                    xdi->pddi.Name.Length = dwSize * sizeof(WCHAR);
+                }
+            }
+                                                                                
+            TRACE("setting domain to %s\n", debugstr_w(xdi->pddi.Name.Buffer));
+                                                                                
+            xdi->pddi.Sid = &(xdi->sid);
+                                                                                
+            /* read the computer SID from the registry */
+            if (!ADVAPI_GetComputerSid(&(xdi->sid)))
+            {
+                SID_IDENTIFIER_AUTHORITY localSidAuthority = {SECURITY_NT_AUTHORITY};
+                                                                                
+                xdi->sid.Revision = SID_REVISION;
+                xdi->sid.SubAuthorityCount = 4;
+                xdi->sid.IdentifierAuthority = localSidAuthority;
+                xdi->sid.SubAuthority[0] = SECURITY_NT_NON_UNIQUE;
+                xdi->sid.SubAuthority[1] = 0;
+                xdi->sid.SubAuthority[2] = 0;
+                xdi->sid.SubAuthority[3] = 0;
+            }
+                                                                                
+            TRACE("setting SID to %s\n", debugstr_sid(&xdi->sid));
+
             *Buffer = xdi;
         }
         break;
@@ -451,7 +546,6 @@ NTSTATUS WINAPI LsaQueryInformationPolic
         case  PolicyModificationInformation:
         case  PolicyAuditFullSetInformation:
         case  PolicyAuditFullQueryInformation:
-        case  PolicyDnsDomainInformation:
         {
             FIXME("category not implemented\n");
             return STATUS_UNSUCCESSFUL;




More information about the wine-cvs mailing list