Ge van Geldorp : msi/tests: Handle running the tests as a domain user.

Alexandre Julliard julliard at winehq.org
Tue Apr 7 09:04:38 CDT 2009


Module: wine
Branch: master
Commit: 215fd0b81311438720d9a53bfd7ae6b890ba1ed3
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=215fd0b81311438720d9a53bfd7ae6b890ba1ed3

Author: Ge van Geldorp <ge at gse.nl>
Date:   Tue Apr  7 10:54:22 2009 +0200

msi/tests: Handle running the tests as a domain user.

---

 dlls/msi/tests/source.c |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/dlls/msi/tests/source.c b/dlls/msi/tests/source.c
index 192f010..2e9e3ff 100644
--- a/dlls/msi/tests/source.c
+++ b/dlls/msi/tests/source.c
@@ -27,10 +27,12 @@
 #include <msidefs.h>
 #include <msi.h>
 #include <sddl.h>
+#include <secext.h>
 
 #include "wine/test.h"
 
 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
+static BOOLEAN (WINAPI *pGetUserNameExA)(EXTENDED_NAME_FORMAT, LPSTR, PULONG);
 static UINT (WINAPI *pMsiSourceListAddMediaDiskA)
     (LPCSTR, LPCSTR, MSIINSTALLCONTEXT, DWORD, DWORD, LPCSTR, LPCSTR);
 static UINT (WINAPI *pMsiSourceListAddSourceExA)
@@ -51,6 +53,7 @@ static void init_functionpointers(void)
 {
     HMODULE hmsi = GetModuleHandleA("msi.dll");
     HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
+    HMODULE hsecur32 = LoadLibraryA("secur32.dll");
 
 #define GET_PROC(dll, func) \
     p ## func = (void *)GetProcAddress(dll, #func); \
@@ -67,6 +70,8 @@ static void init_functionpointers(void)
 
     GET_PROC(hadvapi32, ConvertSidToStringSidA)
 
+    GET_PROC(hsecur32, GetUserNameExA)
+
 #undef GET_PROC
 }
 
@@ -3139,12 +3144,16 @@ static void test_MsiSourceListAddSource(void)
 
     /* MACHINENAME\username */
     size = MAX_PATH;
-    GetComputerNameA(username, &size);
-    lstrcatA(username, "\\");
-    ptr = username + lstrlenA(username);
-    size = MAX_PATH;
-    GetUserNameA(ptr, &size);
-
+    if (pGetUserNameExA != NULL)
+        pGetUserNameExA(NameSamCompatible, username, &size);
+    else
+    {
+        GetComputerNameA(username, &size);
+        lstrcatA(username, "\\");
+        ptr = username + lstrlenA(username);
+        size = MAX_PATH - (ptr - username);
+        GetUserNameA(ptr, &size);
+    }
     trace("username: %s\n", username);
 
     /* GetLastError is not set by the function */




More information about the wine-cvs mailing list