2 * Copyright 2002 Andriy Palamarchuk
4 * Conformance test of the access functions.
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <wine/test.h>
28 WCHAR user_name[UNLEN + 1];
29 WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1];
31 const WCHAR sAdminUserName[] = {'A','d','m','i','n','i','s','t','r','a','t',
33 const WCHAR sGuestUserName[] = {'G','u','e','s','t',0};
34 const WCHAR sNonexistentUser[] = {'N','o','n','e','x','i','s','t','e','n','t',' ',
36 const WCHAR sBadNetPath[] = {'\\','\\','B','a',' ',' ','p','a','t','h',0};
37 const WCHAR sInvalidName[] = {'\\',0};
38 const WCHAR sInvalidName2[] = {'\\','\\',0};
39 const WCHAR sEmptyStr[] = { 0 };
42 void init_access_tests(void)
47 dwSize = sizeof(user_name);
48 ok(GetUserNameW(user_name, &dwSize), "User Name Retrieved");
51 dwSize = sizeof(computer_name);
52 ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved");
55 void run_usergetinfo_tests(void)
57 PUSER_INFO_0 ui0 = NULL;
58 PUSER_INFO_10 ui10 = NULL;
62 ok(NetUserGetInfo(NULL, sAdminUserName, 0, (LPBYTE *)&ui0) == NERR_Success,
63 "NetUserGetInfo is successful");
64 ok(!lstrcmpW(sAdminUserName, ui0->usri0_name), "This is really user name");
65 NetApiBufferSize(ui0, &dwSize);
66 ok(dwSize >= (sizeof(USER_INFO_0) +
67 (lstrlenW(ui0->usri0_name) + 1) * sizeof(WCHAR)),
68 "Is allocated with NetApiBufferAllocate");
71 ok(NetUserGetInfo(NULL, sAdminUserName, 10, (LPBYTE *)&ui10) == NERR_Success,
72 "NetUserGetInfo is successful");
73 ok(!lstrcmpW(sAdminUserName, ui10->usri10_name), "This is really user name");
74 NetApiBufferSize(ui10, &dwSize);
75 ok(dwSize >= (sizeof(USER_INFO_10) +
76 (lstrlenW(ui10->usri10_name) + 1 +
77 lstrlenW(ui10->usri10_comment) + 1 +
78 lstrlenW(ui10->usri10_usr_comment) + 1 +
79 lstrlenW(ui10->usri10_full_name) + 1) * sizeof(WCHAR)),
80 "Is allocated with NetApiBufferAllocate");
82 NetApiBufferFree(ui0);
83 NetApiBufferFree(ui10);
86 ok(NetUserGetInfo(NULL, sAdminUserName, 10000, (LPBYTE *)&ui0) == ERROR_INVALID_LEVEL,
88 ok(NetUserGetInfo(NULL, sNonexistentUser, 0, (LPBYTE *)&ui0) == NERR_UserNotFound,
91 /* FIXME - Currently Wine can't verify whether the network path is good or bad */
92 ok(NetUserGetInfo(sBadNetPath, sAdminUserName, 0, (LPBYTE *)&ui0) == ERROR_BAD_NETPATH,
95 ok(NetUserGetInfo(sEmptyStr, sAdminUserName, 0, (LPBYTE *)&ui0) == ERROR_BAD_NETPATH,
97 ok(NetUserGetInfo(sInvalidName, sAdminUserName, 0, (LPBYTE *)&ui0) == ERROR_INVALID_NAME,
98 "Invalid Server Name");
99 ok(NetUserGetInfo(sInvalidName2, sAdminUserName, 0, (LPBYTE *)&ui0) == ERROR_INVALID_NAME,
100 "Invalid Server Name");
103 /* checks Level 1 of NetQueryDisplayInformation */
104 void run_querydisplayinformation1_tests(void)
106 PNET_DISPLAY_USER Buffer, rec;
107 DWORD Result, EntryCount;
109 BOOL hasAdmin = FALSE;
110 BOOL hasGuest = FALSE;
114 Result = NetQueryDisplayInformation(
115 NULL, 1, i, 1000, MAX_PREFERRED_LENGTH, &EntryCount,
118 ok((Result == ERROR_SUCCESS) || (Result == ERROR_MORE_DATA),
119 "Information Retrieved");
121 for(; EntryCount > 0; EntryCount--)
123 if (!lstrcmpW(rec->usri1_name, sAdminUserName))
125 ok(!hasAdmin, "One admin user");
126 ok(rec->usri1_flags & UF_SCRIPT, "UF_SCRIPT flag is set");
127 ok(rec->usri1_flags & UF_NORMAL_ACCOUNT, "UF_NORMAL_ACCOUNT flag is set");
130 else if (!lstrcmpW(rec->usri1_name, sGuestUserName))
132 ok(!hasGuest, "One guest record");
133 ok(rec->usri1_flags & UF_SCRIPT, "UF_SCRIPT flag is set");
134 ok(rec->usri1_flags & UF_NORMAL_ACCOUNT, "UF_NORMAL_ACCOUNT flag is set");
138 i = rec->usri1_next_index;
142 NetApiBufferFree(Buffer);
143 } while (Result == ERROR_MORE_DATA);
145 ok(hasAdmin, "Has Administrator account");
146 ok(hasGuest, "Has Guest account");
152 run_usergetinfo_tests();
153 run_querydisplayinformation1_tests();