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 32 static WCHAR user_name[UNLEN + 1]; 33 static WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1]; 34 35 static const WCHAR sNonexistentUser[] = {'N','o','n','e','x','i','s','t','e','n','t',' ', 36 'U','s','e','r',0}; 37 static WCHAR sTooLongName[] = {'T','h','i','s',' ','i','s',' ','a',' ','b','a','d', 38 ' ','u','s','e','r','n','a','m','e',0}; 39 static 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 52 static WCHAR sTestUserName[] = {'t', 'e', 's', 't', 'u', 's', 'e', 'r', 0}; 53 static WCHAR sTestUserOldPass[] = {'O', 'l', 'd', 'P', 'a', 's', 's', 'W', '0', 'r', 'd', 'S', 'e', 't', '!', '~', 0}; 54 static const WCHAR sBadNetPath[] = {'\\','\\','B','a',' ',' ','p','a','t','h',0}; 55 static const WCHAR sInvalidName[] = {'\\',0}; 56 static const WCHAR sInvalidName2[] = {'\\','\\',0}; 57 static const WCHAR sEmptyStr[] = { 0 }; 58 59 static NET_API_STATUS (WINAPI *pNetApiBufferFree)(LPVOID); 60 static NET_API_STATUS (WINAPI *pNetApiBufferSize)(LPVOID,LPDWORD); 61 static NET_API_STATUS (WINAPI *pNetQueryDisplayInformation)(LPWSTR,DWORD,DWORD,DWORD,DWORD,LPDWORD,PVOID*); 62 static NET_API_STATUS (WINAPI *pNetUserGetInfo)(LPCWSTR,LPCWSTR,DWORD,LPBYTE*); 63 static NET_API_STATUS (WINAPI *pNetUserModalsGet)(LPCWSTR,DWORD,LPBYTE*); 64 static NET_API_STATUS (WINAPI *pNetUserAdd)(LPCWSTR,DWORD,LPBYTE,LPDWORD); 65 static NET_API_STATUS (WINAPI *pNetUserDel)(LPCWSTR,LPCWSTR); 66 static NET_API_STATUS (WINAPI *pNetLocalGroupGetInfo)(LPCWSTR,LPCWSTR,DWORD,LPBYTE*); 67 static NET_API_STATUS (WINAPI *pNetLocalGroupGetMembers)(LPCWSTR,LPCWSTR,DWORD,LPBYTE*,DWORD,LPDWORD,LPDWORD,PDWORD_PTR); 68 static DWORD (WINAPI *pDavGetHTTPFromUNCPath)(LPCWSTR,LPWSTR,LPDWORD); 69 static DWORD (WINAPI *pDavGetUNCFromHTTPPath)(LPCWSTR,LPWSTR,LPDWORD); 70 71 static BOOL init_access_tests(void) 72 { 73 DWORD dwSize; 74 BOOL rc; 75 76 user_name[0] = 0; 77 dwSize = sizeof(user_name)/sizeof(WCHAR); 78 rc=GetUserNameW(user_name, &dwSize); 79 if (rc==FALSE && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED) 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; 87 dwSize = sizeof(computer_name)/sizeof(WCHAR); 88 ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved\n"); 89 return TRUE; 90 } 91 92 static NET_API_STATUS create_test_user(void) 93 { 94 USER_INFO_1 usri; 95 96 usri.usri1_name = sTestUserName; 97 usri.usri1_password = sTestUserOldPass; 98 usri.usri1_priv = USER_PRIV_USER; 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 107 static NET_API_STATUS delete_test_user(void) 108 { 109 return pNetUserDel(NULL, sTestUserName); 110 } 111 112 static void run_usergetinfo_tests(void) 113 { 114 NET_API_STATUS rc; 115 PUSER_INFO_0 ui0 = NULL; 116 PUSER_INFO_10 ui10 = NULL; 117 DWORD dwSize; 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 || 163 rc == ERROR_NETWORK_UNREACHABLE || 164 rc == RPC_S_SERVER_UNAVAILABLE || 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 177 if(delete_test_user() != NERR_Success) 178 trace("Deleting the test user failed. You might have to manually delete it.\n"); 179 } 180 181 /* Checks Level 1 of NetQueryDisplayInformation */ 182 static void run_querydisplayinformation1_tests(void) 183 { 184 PNET_DISPLAY_USER Buffer, rec; 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 196 ok((Result == ERROR_SUCCESS) || (Result == ERROR_MORE_DATA), 197 "Information Retrieved\n"); 198 rec = Buffer; 199 for(; EntryCount > 0; EntryCount--) 200 { 201 if (rec->usri1_user_id == DOMAIN_USER_RID_ADMIN) 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 226 static void run_usermodalsget_tests(void) 227 { 228 NET_API_STATUS rc; 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 238 static void run_userhandling_tests(void) 239 { 240 NET_API_STATUS ret; 241 USER_INFO_1 usri; 242 243 usri.usri1_priv = USER_PRIV_USER; 244 usri.usri1_home_dir = NULL; 245 usri.usri1_comment = NULL; 246 usri.usri1_flags = UF_SCRIPT; 247 usri.usri1_script_path = NULL; 248 249 usri.usri1_name = sTooLongName; 250 usri.usri1_password = sTestUserOldPass; 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 268 ok(ret == NERR_BadUsername || 269 broken(ret == NERR_PasswordTooShort), /* NT4 */ 270 "Adding user with too long username returned 0x%08x\n", ret); 271 272 usri.usri1_name = sTestUserName; 273 usri.usri1_password = sTooLongPassword; 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 279 usri.usri1_name = sTooLongName; 280 usri.usri1_password = sTooLongPassword; 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 */ 286 ok(ret == NERR_BadUsername || ret == NERR_PasswordTooShort, 287 "Adding user with too long username/password returned 0x%08x\n", ret); 288 289 usri.usri1_name = sTestUserName; 290 usri.usri1_password = sTestUserOldPass; 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); 296 if(ret == ERROR_ACCESS_DENIED) 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 328 static void run_localgroupgetinfo_tests(void) 329 { 330 NET_API_STATUS status; 331 static const WCHAR admins[] = {'A','d','m','i','n','i','s','t','r','a','t','o','r','s',0}; 332 PLOCALGROUP_INFO_1 lgi = NULL; 333 PLOCALGROUP_MEMBERS_INFO_3 buffer = NULL; 334 DWORD entries_read = 0, total_entries =0; 335 int i; 336 337 status = pNetLocalGroupGetInfo(NULL, admins, 1, (LPBYTE *)&lgi); 338 ok(status == NERR_Success || broken(status == NERR_GroupNotFound), 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 357 static void test_DavGetHTTPFromUNCPath(void) 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 { 454 { path, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 455 { path2, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 456 { path3, MAX_PATH, ERROR_SUCCESS, result, 12 }, 457 { path4, MAX_PATH, ERROR_SUCCESS, result, 12 }, 458 { path5, MAX_PATH, ERROR_SUCCESS, result2, 23 }, 459 { path6, MAX_PATH, ERROR_SUCCESS, result3, 23 }, 460 { path7, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 461 { path8, MAX_PATH, ERROR_SUCCESS, result4, 13 }, 462 { path9, MAX_PATH, ERROR_SUCCESS, result5, 13 }, 463 { path10, MAX_PATH, ERROR_SUCCESS, result5, 13 }, 464 { path11, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 465 { path12, MAX_PATH, ERROR_SUCCESS, result5, 13 }, 466 { path13, MAX_PATH, ERROR_SUCCESS, result6, 16 }, 467 { path14, MAX_PATH, ERROR_SUCCESS, result, 12 }, 468 { path15, MAX_PATH, ERROR_SUCCESS, result7, 17 }, 469 { path16, MAX_PATH, ERROR_SUCCESS, result8, 11 }, 470 { path17, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 471 { path18, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 472 { path19, MAX_PATH, ERROR_SUCCESS, result, 12 }, 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 }, 481 { path28, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 482 }; 483 WCHAR buf[MAX_PATH]; 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 < sizeof(tests)/sizeof(tests[0]); 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 554 static void test_DavGetUNCFromHTTPPath(void) 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 { 627 { path, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 628 { path2, MAX_PATH, ERROR_SUCCESS, result, 25 }, 629 { path3, MAX_PATH, ERROR_SUCCESS, result2, 27 }, 630 { path4, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 631 { path5, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 632 { path6, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 633 { path7, MAX_PATH, ERROR_BAD_NET_NAME, NULL, MAX_PATH }, 634 { path8, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 635 { path9, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 636 { path10, MAX_PATH, ERROR_INVALID_PARAMETER, NULL, MAX_PATH }, 637 { path11, MAX_PATH, ERROR_SUCCESS, result3, 20 }, 638 { path12, MAX_PATH, ERROR_SUCCESS, result4, 23 }, 639 { path13, MAX_PATH, ERROR_SUCCESS, result5, 27 }, 640 { path14, MAX_PATH, ERROR_SUCCESS, result, 25 }, 641 { path15, MAX_PATH, ERROR_SUCCESS, result6, 26 }, 642 { path16, MAX_PATH, ERROR_SUCCESS, result, 25 }, 643 { path17, MAX_PATH, ERROR_BAD_NET_NAME, NULL, MAX_PATH }, 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 }; 649 WCHAR buf[MAX_PATH]; 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 < sizeof(tests)/sizeof(tests[0]); 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 704 START_TEST(access) 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()) { 730 run_userhandling_tests(); 731 run_usergetinfo_tests(); 732 run_querydisplayinformation1_tests(); 733 run_usermodalsget_tests(); 734 run_localgroupgetinfo_tests(); 735 } 736 737 test_DavGetHTTPFromUNCPath(); 738 test_DavGetUNCFromHTTPPath(); 739 FreeLibrary(hnetapi32); 740 } 741