ReactOS 0.4.15-dev-7788-g1ad9096
access.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winerror.h>
#include <lmaccess.h>
#include <lmerr.h>
#include <lmapibuf.h>
#include "wine/test.h"
Include dependency graph for access.c:

Go to the source code of this file.

Functions

static NET_API_STATUS (WINAPI *pNetApiBufferFree)(LPVOID)
 
static DWORD (WINAPI *pDavGetHTTPFromUNCPath)(LPCWSTR
 
static BOOL init_access_tests (void)
 
static NET_API_STATUS create_test_user (void)
 
static NET_API_STATUS delete_test_user (void)
 
static void run_usergetinfo_tests (void)
 
static void run_querydisplayinformation1_tests (void)
 
static void run_usermodalsget_tests (void)
 
static void run_userhandling_tests (void)
 
static void run_localgroupgetinfo_tests (void)
 
static void test_DavGetHTTPFromUNCPath (void)
 
static void test_DavGetUNCFromHTTPPath (void)
 
 START_TEST (access)
 

Variables

static WCHAR user_name [UNLEN+1]
 
static WCHAR computer_name [MAX_COMPUTERNAME_LENGTH+1]
 
static const WCHAR sNonexistentUser []
 
static WCHAR sTooLongName []
 
static WCHAR sTooLongPassword []
 
static WCHAR sTestUserName [] = {'t', 'e', 's', 't', 'u', 's', 'e', 'r', 0}
 
static WCHAR sTestUserOldPass [] = {'O', 'l', 'd', 'P', 'a', 's', 's', 'W', '0', 'r', 'd', 'S', 'e', 't', '!', '~', 0}
 
static const WCHAR sBadNetPath [] = {'\\','\\','B','a',' ',' ','p','a','t','h',0}
 
static const WCHAR sInvalidName [] = {'\\',0}
 
static const WCHAR sInvalidName2 [] = {'\\','\\',0}
 
static const WCHAR sEmptyStr [] = { 0 }
 
static LPDWORD
 
static DWORD
 
static PVOID *static LPCWSTR
 
static PVOID *static LPBYTE *static LPBYTE *static LPBYTE
 
static LPBYTE *static LPBYTE PDWORD_PTR
 
static LPWSTR
 

Function Documentation

◆ create_test_user()

static NET_API_STATUS create_test_user ( void  )
static

Definition at line 92 of file access.c.

93{
94 USER_INFO_1 usri;
95
99 usri.usri1_home_dir = NULL;
100 usri.usri1_comment = NULL;
101 usri.usri1_flags = UF_SCRIPT;
102 usri.usri1_script_path = NULL;
103
104 return pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL);
105}
#define NULL
Definition: types.h:112
#define USER_PRIV_USER
Definition: lmaccess.h:117
#define UF_SCRIPT
Definition: lmaccess.h:23
static WCHAR sTestUserName[]
Definition: access.c:52
static WCHAR sTestUserOldPass[]
Definition: access.c:53
DWORD usri1_flags
Definition: lmaccess.h:209
LPWSTR usri1_comment
Definition: lmaccess.h:208
LPWSTR usri1_name
Definition: lmaccess.h:203
LPWSTR usri1_script_path
Definition: lmaccess.h:210
LPWSTR usri1_home_dir
Definition: lmaccess.h:207
LPWSTR usri1_password
Definition: lmaccess.h:204
DWORD usri1_priv
Definition: lmaccess.h:206
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by run_usergetinfo_tests().

◆ delete_test_user()

static NET_API_STATUS delete_test_user ( void  )
static

Definition at line 107 of file access.c.

108{
109 return pNetUserDel(NULL, sTestUserName);
110}

Referenced by run_usergetinfo_tests().

◆ DWORD()

static DWORD ( WINAPI pDavGetHTTPFromUNCPath)
static

◆ init_access_tests()

static BOOL init_access_tests ( void  )
static

Definition at line 71 of file access.c.

72{
74 BOOL rc;
75
76 user_name[0] = 0;
80 {
81 win_skip("GetUserNameW is not available.\n");
82 return FALSE;
83 }
84 ok(rc, "User Name Retrieved\n");
85
86 computer_name[0] = 0;
88 ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved\n");
89 return TRUE;
90}
#define ok(value,...)
Definition: atltest.h:57
#define ARRAY_SIZE(A)
Definition: main.h:33
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static WCHAR computer_name[MAX_COMPUTERNAME_LENGTH+1]
Definition: access.c:33
static WCHAR user_name[UNLEN+1]
Definition: access.c:32
#define win_skip
Definition: test.h:160
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by START_TEST().

◆ NET_API_STATUS()

static NET_API_STATUS ( WINAPI pNetApiBufferFree)
static

◆ run_localgroupgetinfo_tests()

static void run_localgroupgetinfo_tests ( void  )
static

Definition at line 328 of file access.c.

329{
331 static const WCHAR admins[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r','s',0};
334 DWORD entries_read = 0, total_entries =0;
335 int i;
336
337 status = pNetLocalGroupGetInfo(NULL, admins, 1, (LPBYTE *)&lgi);
339 "NetLocalGroupGetInfo unexpectedly returned %d\n", status);
340 if (status != NERR_Success) return;
341
342 trace("Local groupname:%s\n", wine_dbgstr_w( lgi->lgrpi1_name));
343 trace("Comment: %s\n", wine_dbgstr_w( lgi->lgrpi1_comment));
344
345 pNetApiBufferFree(lgi);
346
347 status = pNetLocalGroupGetMembers(NULL, admins, 3, (LPBYTE *)&buffer, MAX_PREFERRED_LENGTH, &entries_read, &total_entries, NULL);
348 ok(status == NERR_Success, "NetLocalGroupGetMembers unexpectedly returned %d\n", status);
349 ok(entries_read > 0 && total_entries > 0, "Amount of entries is unexpectedly 0\n");
350
351 for(i=0;i<entries_read;i++)
352 trace("domain and name: %s\n", wine_dbgstr_w(buffer[i].lgrmi3_domainandname));
353
354 pNetApiBufferFree(buffer);
355}
#define broken(x)
Definition: _sntprintf.h:21
#define trace
Definition: atltest.h:70
GLuint buffer
Definition: glext.h:5915
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define wine_dbgstr_w
Definition: kernel32.h:34
#define MAX_PREFERRED_LENGTH
Definition: lmcons.h:48
#define NERR_Success
Definition: lmerr.h:5
#define NERR_GroupNotFound
Definition: lmerr.h:87
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
LPWSTR lgrpi1_comment
Definition: lmaccess.h:510
LPWSTR lgrpi1_name
Definition: lmaccess.h:509
Definition: ps.c:97
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ run_querydisplayinformation1_tests()

static void run_querydisplayinformation1_tests ( void  )
static

Definition at line 182 of file access.c.

183{
185 DWORD Result, EntryCount;
186 DWORD i = 0;
187 BOOL hasAdmin = FALSE;
188 BOOL hasGuest = FALSE;
189
190 do
191 {
192 Result = pNetQueryDisplayInformation(
193 NULL, 1, i, 1000, MAX_PREFERRED_LENGTH, &EntryCount,
194 (PVOID *)&Buffer);
195
197 "Information Retrieved\n");
198 rec = Buffer;
199 for(; EntryCount > 0; EntryCount--)
200 {
202 {
203 ok(!hasAdmin, "One admin user\n");
204 ok(rec->usri1_flags & UF_SCRIPT, "UF_SCRIPT flag is set\n");
205 ok(rec->usri1_flags & UF_NORMAL_ACCOUNT, "UF_NORMAL_ACCOUNT flag is set\n");
206 hasAdmin = TRUE;
207 }
208 else if (rec->usri1_user_id == DOMAIN_USER_RID_GUEST)
209 {
210 ok(!hasGuest, "One guest record\n");
211 ok(rec->usri1_flags & UF_SCRIPT, "UF_SCRIPT flag is set\n");
212 ok(rec->usri1_flags & UF_NORMAL_ACCOUNT, "UF_NORMAL_ACCOUNT flag is set\n");
213 hasGuest = TRUE;
214 }
215
216 i = rec->usri1_next_index;
217 rec++;
218 }
219
220 pNetApiBufferFree(Buffer);
221 } while (Result == ERROR_MORE_DATA);
222
223 ok(hasAdmin, "Doesn't have 'Administrator' account\n");
224}
Definition: bufpool.h:45
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_SUCCESS
Definition: deptool.c:10
#define UF_NORMAL_ACCOUNT
Definition: lmaccess.h:30
DWORD usri1_user_id
Definition: lmaccess.h:540
DWORD usri1_next_index
Definition: lmaccess.h:541
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
#define DOMAIN_USER_RID_ADMIN
Definition: setypes.h:631
#define DOMAIN_USER_RID_GUEST
Definition: setypes.h:632

Referenced by START_TEST().

◆ run_usergetinfo_tests()

static void run_usergetinfo_tests ( void  )
static

Definition at line 112 of file access.c.

113{
115 PUSER_INFO_0 ui0 = NULL;
116 PUSER_INFO_10 ui10 = NULL;
118
119 if((rc = create_test_user()) != NERR_Success )
120 {
121 skip("Skipping usergetinfo_tests, create_test_user failed: 0x%08x\n", rc);
122 return;
123 }
124
125 /* Level 0 */
126 rc=pNetUserGetInfo(NULL, sTestUserName, 0, (LPBYTE *)&ui0);
127 ok(rc == NERR_Success, "NetUserGetInfo level 0 failed: 0x%08x.\n", rc);
128 ok(!lstrcmpW(sTestUserName, ui0->usri0_name),"Username mismatch for level 0.\n");
129 pNetApiBufferSize(ui0, &dwSize);
130 ok(dwSize >= (sizeof(USER_INFO_0) +
131 (lstrlenW(ui0->usri0_name) + 1) * sizeof(WCHAR)),
132 "Is allocated with NetApiBufferAllocate\n");
133
134 /* Level 10 */
135 rc=pNetUserGetInfo(NULL, sTestUserName, 10, (LPBYTE *)&ui10);
136 ok(rc == NERR_Success, "NetUserGetInfo level 10 failed: 0x%08x.\n", rc);
137 ok(!lstrcmpW(sTestUserName, ui10->usri10_name), "Username mismatch for level 10.\n");
138 pNetApiBufferSize(ui10, &dwSize);
139 ok(dwSize >= (sizeof(USER_INFO_10) +
140 (lstrlenW(ui10->usri10_name) + 1 +
141 lstrlenW(ui10->usri10_comment) + 1 +
142 lstrlenW(ui10->usri10_usr_comment) + 1 +
143 lstrlenW(ui10->usri10_full_name) + 1) * sizeof(WCHAR)),
144 "Is allocated with NetApiBufferAllocate\n");
145
146 pNetApiBufferFree(ui0);
147 pNetApiBufferFree(ui10);
148
149 /* NetUserGetInfo should always work for the current user. */
150 rc=pNetUserGetInfo(NULL, user_name, 0, (LPBYTE*)&ui0);
151 ok(rc == NERR_Success, "NetUsetGetInfo for current user failed: 0x%08x.\n", rc);
152 pNetApiBufferFree(ui0);
153
154 /* errors handling */
155 rc=pNetUserGetInfo(NULL, sTestUserName, 10000, (LPBYTE *)&ui0);
156 ok(rc == ERROR_INVALID_LEVEL,"Invalid Level: rc=%d\n",rc);
157 rc=pNetUserGetInfo(NULL, sNonexistentUser, 0, (LPBYTE *)&ui0);
158 ok(rc == NERR_UserNotFound,"Invalid User Name: rc=%d\n",rc);
159 todo_wine {
160 /* FIXME - Currently Wine can't verify whether the network path is good or bad */
161 rc=pNetUserGetInfo(sBadNetPath, sTestUserName, 0, (LPBYTE *)&ui0);
162 ok(rc == ERROR_BAD_NETPATH ||
165 rc == NERR_WkstaNotStarted || /* workstation service not running */
166 rc == RPC_S_INVALID_NET_ADDR, /* Some Win7 */
167 "Bad Network Path: rc=%d\n",rc);
168 }
169 rc=pNetUserGetInfo(sEmptyStr, sTestUserName, 0, (LPBYTE *)&ui0);
170 ok(rc == ERROR_BAD_NETPATH || rc == NERR_Success,
171 "Bad Network Path: rc=%d\n",rc);
172 rc=pNetUserGetInfo(sInvalidName, sTestUserName, 0, (LPBYTE *)&ui0);
173 ok(rc == ERROR_INVALID_NAME || rc == ERROR_INVALID_HANDLE,"Invalid Server Name: rc=%d\n",rc);
174 rc=pNetUserGetInfo(sInvalidName2, sTestUserName, 0, (LPBYTE *)&ui0);
175 ok(rc == ERROR_INVALID_NAME || rc == ERROR_INVALID_HANDLE,"Invalid Server Name: rc=%d\n",rc);
176
178 trace("Deleting the test user failed. You might have to manually delete it.\n");
179}
#define skip(...)
Definition: atltest.h:64
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define ERROR_INVALID_NAME
Definition: compat.h:103
#define lstrlenW
Definition: compat.h:750
#define NERR_WkstaNotStarted
Definition: lmerr.h:26
#define NERR_UserNotFound
Definition: lmerr.h:88
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define todo_wine
Definition: custom.c:79
static const WCHAR sEmptyStr[]
Definition: access.c:57
static const WCHAR sInvalidName[]
Definition: access.c:55
static const WCHAR sNonexistentUser[]
Definition: access.c:35
static NET_API_STATUS delete_test_user(void)
Definition: access.c:107
static const WCHAR sInvalidName2[]
Definition: access.c:56
static NET_API_STATUS create_test_user(void)
Definition: access.c:92
static const WCHAR sBadNetPath[]
Definition: access.c:54
LPWSTR usri0_name
Definition: lmaccess.h:201
LPWSTR usri10_usr_comment
Definition: lmaccess.h:303
LPWSTR usri10_full_name
Definition: lmaccess.h:304
LPWSTR usri10_comment
Definition: lmaccess.h:302
LPWSTR usri10_name
Definition: lmaccess.h:301
#define ERROR_BAD_NETPATH
Definition: winerror.h:145
#define ERROR_INVALID_LEVEL
Definition: winerror.h:196
#define ERROR_NETWORK_UNREACHABLE
Definition: winerror.h:734
#define RPC_S_SERVER_UNAVAILABLE
Definition: winerror.h:1033
#define RPC_S_INVALID_NET_ADDR
Definition: winerror.h:1018

Referenced by START_TEST().

◆ run_userhandling_tests()

static void run_userhandling_tests ( void  )
static

Definition at line 238 of file access.c.

239{
241 USER_INFO_1 usri;
242
244 usri.usri1_home_dir = NULL;
245 usri.usri1_comment = NULL;
246 usri.usri1_flags = UF_SCRIPT;
247 usri.usri1_script_path = NULL;
248
251
252 ret = pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL);
253 if (ret == NERR_Success || ret == NERR_UserExists)
254 {
255 /* Windows NT4 does create the user. Delete the user and also if it already existed
256 * due to a previous test run on NT4.
257 */
258 trace("We are on NT4, we have to delete the user with the too long username\n");
259 ret = pNetUserDel(NULL, sTooLongName);
260 ok(ret == NERR_Success, "Deleting the user failed : %d\n", ret);
261 }
262 else if (ret == ERROR_ACCESS_DENIED)
263 {
264 skip("not enough permissions to add a user\n");
265 return;
266 }
267 else
269 broken(ret == NERR_PasswordTooShort), /* NT4 */
270 "Adding user with too long username returned 0x%08x\n", ret);
271
274
275 ret = pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL);
276 ok(ret == NERR_PasswordTooShort || ret == ERROR_ACCESS_DENIED /* Win2003 */,
277 "Adding user with too long password returned 0x%08x\n", ret);
278
281
282 ret = pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL);
283 /* NT4 doesn't have a problem with the username so it will report the too long password
284 * as the error. NERR_PasswordTooShort is reported for all kind of password related errors.
285 */
287 "Adding user with too long username/password returned 0x%08x\n", ret);
288
291
292 ret = pNetUserAdd(NULL, 5, (LPBYTE)&usri, NULL);
293 ok(ret == ERROR_INVALID_LEVEL, "Adding user with level 5 returned 0x%08x\n", ret);
294
295 ret = pNetUserAdd(NULL, 1, (LPBYTE)&usri, NULL);
297 {
298 skip("Insufficient permissions to add users. Skipping test.\n");
299 return;
300 }
301 if(ret == NERR_UserExists)
302 {
303 skip("User already exists, skipping test to not mess up the system\n");
304 return;
305 }
306
307 ok(ret == NERR_Success ||
308 broken(ret == NERR_PasswordTooShort), /* NT4 */
309 "Adding user failed with error 0x%08x\n", ret);
310 if(ret != NERR_Success)
311 return;
312
313 /* On Windows XP (and newer), calling NetUserChangePassword with a NULL
314 * domainname parameter creates a user home directory, iff the machine is
315 * not member of a domain.
316 * Using \\127.0.0.1 as domain name does not work on standalone machines
317 * either, unless the ForceGuest option in the registry is turned off.
318 * So let's not test NetUserChangePassword for now.
319 */
320
321 ret = pNetUserDel(NULL, sTestUserName);
322 ok(ret == NERR_Success, "Deleting the user failed.\n");
323
324 ret = pNetUserDel(NULL, sTestUserName);
325 ok(ret == NERR_UserNotFound, "Deleting a nonexistent user returned 0x%08x\n",ret);
326}
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define NERR_BadUsername
Definition: lmerr.h:72
#define NERR_PasswordTooShort
Definition: lmerr.h:112
#define NERR_UserExists
Definition: lmerr.h:91
static WCHAR sTooLongPassword[]
Definition: access.c:39
static WCHAR sTooLongName[]
Definition: access.c:37
int ret

Referenced by START_TEST().

◆ run_usermodalsget_tests()

static void run_usermodalsget_tests ( void  )
static

Definition at line 226 of file access.c.

227{
229 USER_MODALS_INFO_2 * umi2 = NULL;
230
231 rc = pNetUserModalsGet(NULL, 2, (LPBYTE *)&umi2);
232 ok(rc == ERROR_SUCCESS, "NetUserModalsGet failed, rc = %d\n", rc);
233
234 if (umi2)
235 pNetApiBufferFree(umi2);
236}

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( access  )

Definition at line 704 of file access.c.

705{
706 HMODULE hnetapi32=LoadLibraryA("netapi32.dll");
707
708 pNetApiBufferFree=(void*)GetProcAddress(hnetapi32,"NetApiBufferFree");
709 pNetApiBufferSize=(void*)GetProcAddress(hnetapi32,"NetApiBufferSize");
710 pNetQueryDisplayInformation=(void*)GetProcAddress(hnetapi32,"NetQueryDisplayInformation");
711 pNetUserGetInfo=(void*)GetProcAddress(hnetapi32,"NetUserGetInfo");
712 pNetUserModalsGet=(void*)GetProcAddress(hnetapi32,"NetUserModalsGet");
713 pNetUserAdd=(void*)GetProcAddress(hnetapi32, "NetUserAdd");
714 pNetUserDel=(void*)GetProcAddress(hnetapi32, "NetUserDel");
715 pNetLocalGroupGetInfo=(void*)GetProcAddress(hnetapi32, "NetLocalGroupGetInfo");
716 pNetLocalGroupGetMembers=(void*)GetProcAddress(hnetapi32, "NetLocalGroupGetMembers");
717 pDavGetHTTPFromUNCPath = (void*)GetProcAddress(hnetapi32, "DavGetHTTPFromUNCPath");
718 pDavGetUNCFromHTTPPath = (void*)GetProcAddress(hnetapi32, "DavGetUNCFromHTTPPath");
719
720 /* These functions were introduced with NT. It's safe to assume that
721 * if one is not available, none are.
722 */
723 if (!pNetApiBufferFree) {
724 win_skip("Needed functions are not available\n");
725 FreeLibrary(hnetapi32);
726 return;
727 }
728
729 if (init_access_tests()) {
735 }
736
739 FreeLibrary(hnetapi32);
740}
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static void run_usergetinfo_tests(void)
Definition: access.c:112
static void test_DavGetHTTPFromUNCPath(void)
Definition: access.c:357
static void run_usermodalsget_tests(void)
Definition: access.c:226
static void run_localgroupgetinfo_tests(void)
Definition: access.c:328
static BOOL init_access_tests(void)
Definition: access.c:71
static void run_userhandling_tests(void)
Definition: access.c:238
static void test_DavGetUNCFromHTTPPath(void)
Definition: access.c:554
static void run_querydisplayinformation1_tests(void)
Definition: access.c:182

◆ test_DavGetHTTPFromUNCPath()

static void test_DavGetHTTPFromUNCPath ( void  )
static

Definition at line 357 of file access.c.

358{
359 static const WCHAR path[] =
360 {0};
361 static const WCHAR path2[] =
362 {'c',':','\\',0};
363 static const WCHAR path3[] =
364 {'\\','\\','.','\\','c',':',0};
365 static const WCHAR path4[] =
366 {'\\','\\','.','\\','c',':','\\',0};
367 static const WCHAR path5[] =
368 {'\\','\\','.','\\','c',':','\\','n','o','s','u','c','h','p','a','t','h',0};
369 static const WCHAR path6[] =
370 {'\\','\\','n','o','s','u','c','h','s','e','r','v','e','r','\\','c',':','\\',0};
371 static const WCHAR path7[] =
372 {'\\','.','\\','c',':',0};
373 static const WCHAR path8[] =
374 {'\\','\\','.','\\','c',':','\\','\\',0};
375 static const WCHAR path9[] =
376 {'\\','\\','.','@','S','S','L','\\','c',':',0};
377 static const WCHAR path10[] =
378 {'\\','\\','.','@','s','s','l','\\','c',':',0};
379 static const WCHAR path11[] =
380 {'\\','\\','.','@','t','l','s','\\','c',':',0};
381 static const WCHAR path12[] =
382 {'\\','\\','.','@','S','S','L','@','4','4','3','\\','c',':',0};
383 static const WCHAR path13[] =
384 {'\\','\\','.','@','S','S','L','@','8','0','\\','c',':',0};
385 static const WCHAR path14[] =
386 {'\\','\\','.','@','8','0','\\','c',':',0};
387 static const WCHAR path15[] =
388 {'\\','\\','.','@','8','0','8','0','\\','c',':',0};
389 static const WCHAR path16[] =
390 {'\\','\\','\\','c',':',0};
391 static const WCHAR path17[] =
392 {'\\','\\',0};
393 static const WCHAR path18[] =
394 {'/','/','.','/','c',':',0};
395 static const WCHAR path19[] =
396 {'\\','\\','.','\\','c',':','/',0};
397 static const WCHAR path20[] =
398 {'\\','\\','.','\\','c',':','\\','\\','\\',0};
399 static const WCHAR path21[] =
400 {'\\','\\','.','\\','\\','c',':',0};
401 static const WCHAR path22[] =
402 {'\\','\\','.','\\','c',':','d','i','r',0};
403 static const WCHAR path23[] =
404 {'\\','\\','.',0};
405 static const WCHAR path24[] =
406 {'\\','\\','.','\\','d','i','r',0};
407 static const WCHAR path25[] =
408 {'\\','\\','.','\\','\\',0};
409 static const WCHAR path26[] =
410 {'\\','\\','.','\\','c',':','d','i','r','/',0};
411 static const WCHAR path27[] =
412 {'\\','\\','.','/','c',':',0};
413 static const WCHAR path28[] =
414 {'\\','\\','.','@','8','0','@','S','S','L','\\','c',':',0};
415 static const WCHAR result[] =
416 {'h','t','t','p',':','/','/','.','/','c',':',0};
417 static const WCHAR result2[] =
418 {'h','t','t','p',':','/','/','.','/','c',':','/','n','o','s','u','c','h','p','a','t','h',0};
419 static const WCHAR result3[] =
420 {'h','t','t','p',':','/','/','n','o','s','u','c','h','s','e','r','v','e','r','/','c',':',0};
421 static const WCHAR result4[] =
422 {'h','t','t','p',':','/','/','.','/','c',':','/',0};
423 static const WCHAR result5[] =
424 {'h','t','t','p','s',':','/','/','.','/','c',':',0};
425 static const WCHAR result6[] =
426 {'h','t','t','p','s',':','/','/','.',':','8','0','/','c',':',0};
427 static const WCHAR result7[] =
428 {'h','t','t','p',':','/','/','.',':','8','0','8','0','/','c',':',0};
429 static const WCHAR result8[] =
430 {'h','t','t','p',':','/','/','/','c',':',0};
431 static const WCHAR result9[] =
432 {'h','t','t','p',':','/','/','.','/','c',':','/','/',0};
433 static const WCHAR result10[] =
434 {'h','t','t','p',':','/','/','.','/','/','c',':',0};
435 static const WCHAR result11[] =
436 {'h','t','t','p',':','/','/','.','/','c',':','d','i','r',0};
437 static const WCHAR result12[] =
438 {'h','t','t','p',':','/','/','.',0};
439 static const WCHAR result13[] =
440 {'h','t','t','p',':','/','/','.','/','d','i','r',0};
441 static const WCHAR result14[] =
442 {'h','t','t','p',':','/','/','.','/',0};
443 static const struct
444 {
445 const WCHAR *path;
446 DWORD size;
447 DWORD ret;
448 const WCHAR *ret_path;
449 DWORD ret_size;
450 int todo;
451 }
452 tests[] =
453 {
458 { path5, MAX_PATH, ERROR_SUCCESS, result2, 23 },
459 { path6, MAX_PATH, ERROR_SUCCESS, result3, 23 },
461 { path8, MAX_PATH, ERROR_SUCCESS, result4, 13 },
462 { path9, MAX_PATH, ERROR_SUCCESS, result5, 13 },
463 { path10, MAX_PATH, ERROR_SUCCESS, result5, 13 },
465 { path12, MAX_PATH, ERROR_SUCCESS, result5, 13 },
466 { path13, MAX_PATH, ERROR_SUCCESS, result6, 16 },
468 { path15, MAX_PATH, ERROR_SUCCESS, result7, 17 },
469 { path16, MAX_PATH, ERROR_SUCCESS, result8, 11 },
473 { path20, MAX_PATH, ERROR_SUCCESS, result9, 14 },
474 { path21, MAX_PATH, ERROR_SUCCESS, result10, 13 },
475 { path22, MAX_PATH, ERROR_SUCCESS, result11, 15 },
476 { path23, MAX_PATH, ERROR_SUCCESS, result12, 9 },
477 { path24, MAX_PATH, ERROR_SUCCESS, result13, 13 },
478 { path25, MAX_PATH, ERROR_SUCCESS, result14, 10, 1 },
479 { path26, MAX_PATH, ERROR_SUCCESS, result11, 15 },
480 { path27, MAX_PATH, ERROR_SUCCESS, result, 12 },
482 };
484 DWORD i, ret, size;
485
486 if (!pDavGetHTTPFromUNCPath)
487 {
488 win_skip( "DavGetHTTPFromUNCPath is missing\n" );
489 return;
490 }
491
492 if (0) { /* crash */
493 ret = pDavGetHTTPFromUNCPath( NULL, NULL, NULL );
494 ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
495 }
496
497 ret = pDavGetHTTPFromUNCPath( path, buf, NULL );
498 ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
499
500 size = 0;
501 ret = pDavGetHTTPFromUNCPath( path, NULL, &size );
502 ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
503
504 if (0) { /* crash */
505 buf[0] = 0;
506 size = 0;
507 ret = pDavGetHTTPFromUNCPath( path, buf, &size );
508 ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
509
510 ret = pDavGetHTTPFromUNCPath( path3, buf, NULL );
511 ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
512 }
513
514 size = 0;
515 ret = pDavGetHTTPFromUNCPath( path3, NULL, &size );
516 ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret );
517
518 buf[0] = 0;
519 size = 0;
520 ret = pDavGetHTTPFromUNCPath( path3, buf, &size );
521 ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret );
522 ok( size == 12, "got %u\n", size );
523
524 for (i = 0; i < ARRAY_SIZE(tests); i++)
525 {
526 buf[0] = 0;
527 size = tests[i].size;
528 ret = pDavGetHTTPFromUNCPath( tests[i].path, buf, &size );
529 if (tests[i].todo)
530 {
531 ok( ret == tests[i].ret, "%u: expected %u got %u\n", i, tests[i].ret, ret );
532 todo_wine {
533 if (tests[i].ret_path)
534 {
535 ok( !lstrcmpW( buf, tests[i].ret_path ), "%u: expected %s got %s\n",
536 i, wine_dbgstr_w(tests[i].ret_path), wine_dbgstr_w(buf) );
537 }
538 ok( size == tests[i].ret_size, "%u: expected %u got %u\n", i, tests[i].ret_size, size );
539 }
540 }
541 else
542 {
543 ok( ret == tests[i].ret, "%u: expected %u got %u\n", i, tests[i].ret, ret );
544 if (tests[i].ret_path)
545 {
546 ok( !lstrcmpW( buf, tests[i].ret_path ), "%u: expected %s got %s\n",
547 i, wine_dbgstr_w(tests[i].ret_path), wine_dbgstr_w(buf) );
548 }
549 ok( size == tests[i].ret_size, "%u: expected %u got %u\n", i, tests[i].ret_size, size );
550 }
551 }
552}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define MAX_PATH
Definition: compat.h:34
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint64EXT * result
Definition: glext.h:11304
static struct test_info tests[]
BOOL todo
Definition: filedlg.c:313
static const WCHAR path3[]
Definition: misc.c:320
static const WCHAR path4[]
Definition: misc.c:321
static const WCHAR path19[]
Definition: path.c:68
static const WCHAR path7[]
Definition: path.c:34
static const WCHAR path18[]
Definition: path.c:64
static const WCHAR path11[]
Definition: path.c:46
static const WCHAR path5[]
Definition: path.c:32
static const WCHAR path14[]
Definition: path.c:54
static const WCHAR path10[]
Definition: path.c:43
static const WCHAR path12[]
Definition: path.c:49
static const WCHAR path20[]
Definition: path.c:71
static const WCHAR path16[]
Definition: path.c:58
static const WCHAR path13[]
Definition: path.c:52
static const WCHAR path8[]
Definition: path.c:37
static const WCHAR path17[]
Definition: path.c:60
static const WCHAR path6[]
Definition: path.c:33
static const WCHAR path9[]
Definition: path.c:40
static const WCHAR path2[]
Definition: path.c:29
static const WCHAR path15[]
Definition: path.c:56

Referenced by START_TEST().

◆ test_DavGetUNCFromHTTPPath()

static void test_DavGetUNCFromHTTPPath ( void  )
static

Definition at line 554 of file access.c.

555{
556 static const WCHAR path[] =
557 {0};
558 static const WCHAR path2[] =
559 {'h','t','t','p',':','/','/','s','e','r','v','e','r','/','p','a','t','h',0};
560 static const WCHAR path3[] =
561 {'h','t','t','p','s',':','/','/','h','o','s','t','/','p','a','t','h',0};
562 static const WCHAR path4[] =
563 {'\\','\\','s','e','r','v','e','r',0};
564 static const WCHAR path5[] =
565 {'\\','\\','s','e','r','v','e','r','\\','p','a','t','h',0};
566 static const WCHAR path6[] =
567 {'\\','\\','h','t','t','p',':','/','/','s','e','r','v','e','r','/','p','a','t','h',0};
568 static const WCHAR path7[] =
569 {'h','t','t','p',':','/','/',0};
570 static const WCHAR path8[] =
571 {'h','t','t','p',':',0};
572 static const WCHAR path9[] =
573 {'h','t','t','p',0};
574 static const WCHAR path10[] =
575 {'h','t','t','p',':','s','e','r','v','e','r',0};
576 static const WCHAR path11[] =
577 {'h','t','t','p',':','/','/','s','e','r','v','e','r',':','8','0',0};
578 static const WCHAR path12[] =
579 {'h','t','t','p',':','/','/','s','e','r','v','e','r',':','8','1',0};
580 static const WCHAR path13[] =
581 {'h','t','t','p','s',':','/','/','s','e','r','v','e','r',':','8','0',0};
582 static const WCHAR path14[] =
583 {'H','T','T','P',':','/','/','s','e','r','v','e','r','/','p','a','t','h',0};
584 static const WCHAR path15[] =
585 {'h','t','t','p',':','/','/','s','e','r','v','e','r',':','6','5','5','3','7',0};
586 static const WCHAR path16[] =
587 {'h','t','t','p',':','/','/','s','e','r','v','e','r','/','p','a','t','h','/',0};
588 static const WCHAR path17[] =
589 {'h','t','t','p',':','/','/','s','e','r','v','e','r','/','p','a','t','h','/','/',0};
590 static const WCHAR path18[] =
591 {'h','t','t','p',':','/','/','s','e','r','v','e','r',':','/','p','a','t','h',0};
592 static const WCHAR path19[] =
593 {'h','t','t','p',':','/','/','s','e','r','v','e','r',0};
594 static const WCHAR path20[] =
595 {'h','t','t','p','s',':','/','/','s','e','r','v','e','r',':','4','4','3',0};
596 static const WCHAR path21[] =
597 {'h','t','t','p','s',':','/','/','s','e','r','v','e','r',':','8','0',0};
598 static const WCHAR result[] =
599 {'\\','\\','s','e','r','v','e','r','\\','D','a','v','W','W','W','R','o','o','t','\\','p','a','t','h',0};
600 static const WCHAR result2[] =
601 {'\\','\\','h','o','s','t','@','S','S','L','\\','D','a','v','W','W','W','R','o','o','t','\\',
602 'p','a','t','h',0};
603 static const WCHAR result3[] =
604 {'\\','\\','s','e','r','v','e','r','\\','D','a','v','W','W','W','R','o','o','t',0};
605 static const WCHAR result4[] =
606 {'\\','\\','s','e','r','v','e','r','@','8','1','\\','D','a','v','W','W','W','R','o','o','t',0};
607 static const WCHAR result5[] =
608 {'\\','\\','s','e','r','v','e','r','@','S','S','L','@','8','0','\\','D','a','v','W','W','W','R','o','o','t',0};
609 static const WCHAR result6[] =
610 {'\\','\\','s','e','r','v','e','r','@','6','5','5','3','7','\\','D','a','v','W','W','W','R','o','o','t',0};
611 static const WCHAR result7[] =
612 {'\\','\\','s','e','r','v','e','r','@','\\','D','a','v','W','W','W','R','o','o','t','\\','p','a','t','h',0};
613 static const WCHAR result8[] =
614 {'\\','\\','s','e','r','v','e','r','@','S','S','L','\\','D','a','v','W','W','W','R','o','o','t',0};
615 static const WCHAR result9[] =
616 {'\\','\\','s','e','r','v','e','r','@','S','S','L','@','8','0','\\','D','a','v','W','W','W','R','o','o','t',0};
617 static const struct
618 {
619 const WCHAR *path;
620 DWORD size;
621 DWORD ret;
622 const WCHAR *ret_path;
623 DWORD ret_size;
624 }
625 tests[] =
626 {
629 { path3, MAX_PATH, ERROR_SUCCESS, result2, 27 },
637 { path11, MAX_PATH, ERROR_SUCCESS, result3, 20 },
638 { path12, MAX_PATH, ERROR_SUCCESS, result4, 23 },
639 { path13, MAX_PATH, ERROR_SUCCESS, result5, 27 },
641 { path15, MAX_PATH, ERROR_SUCCESS, result6, 26 },
644 { path18, MAX_PATH, ERROR_SUCCESS, result7, 26 },
645 { path19, MAX_PATH, ERROR_SUCCESS, result3, 20 },
646 { path20, MAX_PATH, ERROR_SUCCESS, result8, 24 },
647 { path21, MAX_PATH, ERROR_SUCCESS, result9, 27 },
648 };
650 DWORD i, ret, size;
651
652 if (!pDavGetUNCFromHTTPPath)
653 {
654 win_skip( "DavGetUNCFromHTTPPath is missing\n" );
655 return;
656 }
657
658 if (0) { /* crash */
659 ret = pDavGetUNCFromHTTPPath( NULL, NULL, NULL );
660 ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
661 }
662 ret = pDavGetUNCFromHTTPPath( path, buf, NULL );
663 ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
664
665 size = 0;
666 ret = pDavGetUNCFromHTTPPath( path, NULL, &size );
667 ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
668
669 buf[0] = 0;
670 size = 0;
671 ret = pDavGetUNCFromHTTPPath( path, buf, &size );
672 ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
673
674 if (0) { /* crash */
675 ret = pDavGetUNCFromHTTPPath( path2, buf, NULL );
676 ok( ret == ERROR_INVALID_PARAMETER, "got %u\n", ret );
677 }
678 size = 0;
679 ret = pDavGetUNCFromHTTPPath( path2, NULL, &size );
680 ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret );
681
682 buf[0] = 0;
683 size = 0;
684 ret = pDavGetUNCFromHTTPPath( path2, buf, &size );
685 ok( ret == ERROR_INSUFFICIENT_BUFFER, "got %u\n", ret );
686 ok( size == 25, "got %u\n", size );
687
688 for (i = 0; i < ARRAY_SIZE(tests); i++)
689 {
690 buf[0] = 0;
691 size = tests[i].size;
692 ret = pDavGetUNCFromHTTPPath( tests[i].path, buf, &size );
693 ok( ret == tests[i].ret, "%u: expected %u got %u\n", i, tests[i].ret, ret );
694 if (tests[i].ret_path)
695 {
696 ok( !lstrcmpW( buf, tests[i].ret_path ), "%u: expected %s got %s\n",
697 i, wine_dbgstr_w(tests[i].ret_path), wine_dbgstr_w(buf) );
698 }
699 ok( size == tests[i].ret_size, "%u: expected %u got %u\n", i, tests[i].ret_size, size );
700 }
701}
#define ERROR_BAD_NET_NAME
Definition: winerror.h:159

Referenced by START_TEST().

Variable Documentation

◆ computer_name

WCHAR computer_name[MAX_COMPUTERNAME_LENGTH+1]
static

Definition at line 33 of file access.c.

Referenced by build_systeminfo_tree(), init_access_tests(), and test_LookupAccountName().

◆ DWORD

LPBYTE *static LPBYTE DWORD

Definition at line 61 of file access.c.

◆ LPBYTE

PVOID *static LPBYTE *static LPBYTE *static LPBYTE

Definition at line 64 of file access.c.

◆ LPCWSTR

LPBYTE *static LPCWSTR

Definition at line 62 of file access.c.

◆ LPDWORD

Definition at line 60 of file access.c.

◆ LPWSTR

Definition at line 68 of file access.c.

◆ PDWORD_PTR

Definition at line 67 of file access.c.

◆ sBadNetPath

const WCHAR sBadNetPath[] = {'\\','\\','B','a',' ',' ','p','a','t','h',0}
static

Definition at line 54 of file access.c.

Referenced by run_usergetinfo_tests().

◆ sEmptyStr

const WCHAR sEmptyStr[] = { 0 }
static

Definition at line 57 of file access.c.

Referenced by run_usergetinfo_tests().

◆ sInvalidName

const WCHAR sInvalidName[] = {'\\',0}
static

Definition at line 55 of file access.c.

Referenced by run_usergetinfo_tests().

◆ sInvalidName2

const WCHAR sInvalidName2[] = {'\\','\\',0}
static

Definition at line 56 of file access.c.

Referenced by run_usergetinfo_tests().

◆ sNonexistentUser

const WCHAR sNonexistentUser[]
static
Initial value:
= {'N','o','n','e','x','i','s','t','e','n','t',' ',
'U','s','e','r',0}

Definition at line 35 of file access.c.

Referenced by run_usergetinfo_tests().

◆ sTestUserName

WCHAR sTestUserName[] = {'t', 'e', 's', 't', 'u', 's', 'e', 'r', 0}
static

◆ sTestUserOldPass

WCHAR sTestUserOldPass[] = {'O', 'l', 'd', 'P', 'a', 's', 's', 'W', '0', 'r', 'd', 'S', 'e', 't', '!', '~', 0}
static

Definition at line 53 of file access.c.

Referenced by create_test_user(), and run_userhandling_tests().

◆ sTooLongName

WCHAR sTooLongName[]
static
Initial value:
= {'T','h','i','s',' ','i','s',' ','a',' ','b','a','d',
' ','u','s','e','r','n','a','m','e',0}

Definition at line 37 of file access.c.

Referenced by run_userhandling_tests().

◆ sTooLongPassword

WCHAR sTooLongPassword[]
static
Initial value:
= {'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
'a', 0}

Definition at line 39 of file access.c.

Referenced by run_userhandling_tests().

◆ user_name

WCHAR user_name[UNLEN+1]
static