ReactOS 0.4.16-dev-336-gb667d82
access.c
Go to the documentation of this file.
1/*
2 * Copyright 2002 Andriy Palamarchuk
3 *
4 * Conformance test of the access functions.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include <stdarg.h>
22
23#include <windef.h>
24#include <winbase.h>
25#include <winerror.h>
26#include <lmaccess.h>
27#include <lmerr.h>
28#include <lmapibuf.h>
29
30#include "wine/test.h"
31
32static WCHAR user_name[UNLEN + 1];
34
35static const WCHAR sNonexistentUser[] = {'N','o','n','e','x','i','s','t','e','n','t',' ',
36 'U','s','e','r',0};
37static WCHAR sTooLongName[] = {'T','h','i','s',' ','i','s',' ','a',' ','b','a','d',
38 ' ','u','s','e','r','n','a','m','e',0};
39static WCHAR sTooLongPassword[] = {'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
40 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
41 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
42 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
43 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
44 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
45 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
46 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
47 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
48 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
49 'a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h','a','b','c','d','e','f','g','h',
50 'a', 0};
51
52static WCHAR sTestUserName[] = {'t', 'e', 's', 't', 'u', 's', 'e', 'r', 0};
53static WCHAR sTestUserOldPass[] = {'O', 'l', 'd', 'P', 'a', 's', 's', 'W', '0', 'r', 'd', 'S', 'e', 't', '!', '~', 0};
54static const WCHAR sBadNetPath[] = {'\\','\\','B','a',' ',' ','p','a','t','h',0};
55static const WCHAR sInvalidName[] = {'\\',0};
56static const WCHAR sInvalidName2[] = {'\\','\\',0};
57static const WCHAR sEmptyStr[] = { 0 };
58
59static NET_API_STATUS (WINAPI *pNetApiBufferFree)(LPVOID);
60static NET_API_STATUS (WINAPI *pNetApiBufferSize)(LPVOID,LPDWORD);
61static NET_API_STATUS (WINAPI *pNetQueryDisplayInformation)(LPWSTR,DWORD,DWORD,DWORD,DWORD,LPDWORD,PVOID*);
62static NET_API_STATUS (WINAPI *pNetUserGetInfo)(LPCWSTR,LPCWSTR,DWORD,LPBYTE*);
63static NET_API_STATUS (WINAPI *pNetUserModalsGet)(LPCWSTR,DWORD,LPBYTE*);
65static NET_API_STATUS (WINAPI *pNetUserDel)(LPCWSTR,LPCWSTR);
66static NET_API_STATUS (WINAPI *pNetLocalGroupGetInfo)(LPCWSTR,LPCWSTR,DWORD,LPBYTE*);
68static DWORD (WINAPI *pDavGetHTTPFromUNCPath)(LPCWSTR,LPWSTR,LPDWORD);
69static DWORD (WINAPI *pDavGetUNCFromHTTPPath)(LPCWSTR,LPWSTR,LPDWORD);
70
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}
91
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}
106
108{
109 return pNetUserDel(NULL, sTestUserName);
110}
111
112static void run_usergetinfo_tests(void)
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}
180
181/* Checks Level 1 of NetQueryDisplayInformation */
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}
225
226static void run_usermodalsget_tests(void)
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}
237
238static void run_userhandling_tests(void)
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}
327
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}
356
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}
553
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}
702
703
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 trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:20
Definition: bufpool.h:45
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#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
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define MAX_PATH
Definition: compat.h:34
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
#define ERROR_INVALID_NAME
Definition: compat.h:103
#define lstrlenW
Definition: compat.h:750
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
GLuint64EXT * result
Definition: glext.h:11304
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 USER_PRIV_USER
Definition: lmaccess.h:117
#define UF_SCRIPT
Definition: lmaccess.h:23
#define UF_NORMAL_ACCOUNT
Definition: lmaccess.h:30
#define NET_API_STATUS
Definition: lmcons.h:8
#define MAX_PREFERRED_LENGTH
Definition: lmcons.h:48
#define NERR_BadUsername
Definition: lmerr.h:72
#define NERR_WkstaNotStarted
Definition: lmerr.h:26
#define NERR_UserNotFound
Definition: lmerr.h:88
#define NERR_Success
Definition: lmerr.h:5
#define NERR_PasswordTooShort
Definition: lmerr.h:112
#define NERR_UserExists
Definition: lmerr.h:91
#define NERR_GroupNotFound
Definition: lmerr.h:87
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static struct test_info tests[]
BOOL todo
Definition: filedlg.c:313
#define todo_wine
Definition: custom.c:89
static void run_usergetinfo_tests(void)
Definition: access.c:112
static const WCHAR sEmptyStr[]
Definition: access.c:57
static WCHAR sTestUserName[]
Definition: access.c:52
static WCHAR sTestUserOldPass[]
Definition: access.c:53
static void test_DavGetHTTPFromUNCPath(void)
Definition: access.c:357
static LPBYTE *static LPBYTE PDWORD_PTR
Definition: access.c:67
static LPWSTR
Definition: access.c:68
static const WCHAR sInvalidName[]
Definition: access.c:55
static void run_usermodalsget_tests(void)
Definition: access.c:226
static const WCHAR sNonexistentUser[]
Definition: access.c:35
static NET_API_STATUS delete_test_user(void)
Definition: access.c:107
static void run_localgroupgetinfo_tests(void)
Definition: access.c:328
static BOOL init_access_tests(void)
Definition: access.c:71
static PVOID *static LPCWSTR
Definition: access.c:62
static PVOID *static LPBYTE *static LPBYTE *static LPBYTE
Definition: access.c:64
static const WCHAR sInvalidName2[]
Definition: access.c:56
static void run_userhandling_tests(void)
Definition: access.c:238
static void test_DavGetUNCFromHTTPPath(void)
Definition: access.c:554
static LPDWORD
Definition: access.c:60
static WCHAR computer_name[MAX_COMPUTERNAME_LENGTH+1]
Definition: access.c:33
static void run_querydisplayinformation1_tests(void)
Definition: access.c:182
static WCHAR sTooLongPassword[]
Definition: access.c:39
static DWORD
Definition: access.c:61
static WCHAR user_name[UNLEN+1]
Definition: access.c:32
static WCHAR sTooLongName[]
Definition: access.c:37
static NET_API_STATUS create_test_user(void)
Definition: access.c:92
static const WCHAR sBadNetPath[]
Definition: access.c:54
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
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
#define LPVOID
Definition: nt_native.h:45
#define win_skip
Definition: test.h:163
#define UNLEN
Definition: sspi.c:28
LPWSTR lgrpi1_comment
Definition: lmaccess.h:510
LPWSTR lgrpi1_name
Definition: lmaccess.h:509
DWORD usri1_user_id
Definition: lmaccess.h:540
DWORD usri1_next_index
Definition: lmaccess.h:541
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
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
Definition: ps.c:97
unsigned char * LPBYTE
Definition: typedefs.h:53
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:269
#define WINAPI
Definition: msvc.h:6
#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
#define ERROR_BAD_NET_NAME
Definition: winerror.h:159
_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
__wchar_t WCHAR
Definition: xmlstorage.h:180