diff --git a/dlls/netapi32/Makefile.in b/dlls/netapi32/Makefile.in index 90c3c851604..31c8304cb33 100644 --- a/dlls/netapi32/Makefile.in +++ b/dlls/netapi32/Makefile.in @@ -10,7 +10,9 @@ LDDLLFLAGS = @LDDLLFLAGS@ SYMBOLFILE = $(MODULE).tmp.o C_SRCS = \ + access.c \ apibuf.c \ + browsr.c \ netapi32.c \ wksta.c diff --git a/dlls/netapi32/access.c b/dlls/netapi32/access.c new file mode 100644 index 00000000000..f7580340b49 --- /dev/null +++ b/dlls/netapi32/access.c @@ -0,0 +1,428 @@ +/* + * Copyright 2002 Andriy Palamarchuk + * + * netapi32 access functions + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include "netapi32_misc.h" +#include "wine/debug.h" +#include "wine/unicode.h" + +WINE_DEFAULT_DEBUG_CHANNEL(netapi32); + +const WCHAR sAdminUserName[] = {'A','d','m','i','n','i','s','t','r','a','t', + 'o','r',0}; +const WCHAR sGuestUserName[] = {'G','u','e','s','t',0}; + +/************************************************************ + * NETAPI_ValidateServername + * + * Validates server name + */ +NET_API_STATUS NETAPI_ValidateServername(LPCWSTR ServerName) +{ + if (ServerName) + { + if (ServerName[0] == 0) + return ERROR_BAD_NETPATH; + else if ( + ((ServerName[0] == '\\') && + (ServerName[1] != '\\')) + || + ((ServerName[0] == '\\') && + (ServerName[1] == '\\') && + (ServerName[2] == 0)) + ) + return ERROR_INVALID_NAME; + } + return NERR_Success; +} + +/************************************************************ + * NETAPI_IsKnownUser + * + * Checks whether the user name indicates current user. + */ +BOOL NETAPI_IsKnownUser(LPCWSTR UserName) +{ + DWORD dwSize = UNLEN + 1; + BOOL Result; + LPWSTR buf; + + if (!lstrcmpW(UserName, sAdminUserName) || + !lstrcmpW(UserName, sGuestUserName)) + return TRUE; + NetApiBufferAllocate(dwSize * sizeof(WCHAR), (LPVOID *) &buf); + Result = GetUserNameW(buf, &dwSize); + + Result = Result && !lstrcmpW(UserName, buf); + NetApiBufferFree(buf); + + return Result; +} + +#define NETAPI_ForceKnownUser(UserName, FailureCode) \ + if (!NETAPI_IsKnownUser(UserName)) \ + { \ + FIXME("Can't find information for user %s\n", \ + debugstr_w(UserName)); \ + return FailureCode; \ + } + +/************************************************************ + * NetUserGetInfo (NETAPI32.@) + */ +NET_API_STATUS WINAPI +NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, + LPBYTE* bufptr) +{ + NET_API_STATUS status; + TRACE("(%s, %s, %ld, %p)\n", debugstr_w(servername), debugstr_w(username), + level, bufptr); + status = NETAPI_ValidateServername(servername); + if (status != NERR_Success) + return status; + NETAPI_ForceLocalComputer(servername, NERR_InvalidComputer); + NETAPI_ForceKnownUser(username, NERR_UserNotFound); + + switch (level) + { + case 0: + { + PUSER_INFO_0 ui; + int name_sz; + + name_sz = lstrlenW(username) + 1; + + /* set up buffer */ + NetApiBufferAllocate(sizeof(USER_INFO_0) + name_sz * sizeof(WCHAR), + (LPVOID *) bufptr); + + ui = (PUSER_INFO_0) *bufptr; + ui->usri0_name = (LPWSTR) (*bufptr + sizeof(USER_INFO_0)); + + /* get data */ + lstrcpyW(ui->usri0_name, username); + break; + } + + case 10: + { + PUSER_INFO_10 ui; + PUSER_INFO_0 ui0; + NET_API_STATUS status; + /* sizes of the field buffers in WCHARS */ + int name_sz, comment_sz, usr_comment_sz, full_name_sz; + + comment_sz = 1; + usr_comment_sz = 1; + full_name_sz = 1; + + /* get data */ + status = NetUserGetInfo(servername, username, 0, (LPBYTE *) &ui0); + if (status != NERR_Success) + { + NetApiBufferFree(ui0); + return status; + } + name_sz = lstrlenW(ui0->usri0_name) + 1; + + /* set up buffer */ + NetApiBufferAllocate(sizeof(USER_INFO_10) + + (name_sz + comment_sz + usr_comment_sz + + full_name_sz) * sizeof(WCHAR), + (LPVOID *) bufptr); + ui = (PUSER_INFO_10) *bufptr; + ui->usri10_name = (LPWSTR) (*bufptr + sizeof(USER_INFO_10)); + ui->usri10_comment = (LPWSTR) ( + ((PBYTE) ui->usri10_name) + name_sz * sizeof(WCHAR)); + ui->usri10_usr_comment = (LPWSTR) ( + ((PBYTE) ui->usri10_comment) + comment_sz * sizeof(WCHAR)); + ui->usri10_full_name = (LPWSTR) ( + ((PBYTE) ui->usri10_usr_comment) + usr_comment_sz * sizeof(WCHAR)); + + /* set data */ + lstrcpyW(ui->usri10_name, ui0->usri0_name); + NetApiBufferFree(ui0); + ui->usri10_comment[0] = 0; + ui->usri10_usr_comment[0] = 0; + ui->usri10_full_name[0] = 0; + break; + } + + case 1: + case 2: + case 3: + case 4: + case 11: + case 20: + case 23: + case 1003: + case 1005: + case 1006: + case 1007: + case 1008: + case 1009: + case 1010: + case 1011: + case 1012: + case 1013: + case 1014: + case 1017: + case 1018: + case 1020: + case 1023: + case 1024: + case 1025: + case 1051: + case 1052: + case 1053: + { + FIXME("Level %ld is not implemented\n", level); + break; + } + default: + ERR("Invalid level %ld is specified\n", level); + return ERROR_INVALID_LEVEL; + } + return NERR_Success; +} + +/************************************************************ + * ACCESS_QueryAdminDisplayInformation + * + * Creates a buffer with information for the Admin User + */ +void ACCESS_QueryAdminDisplayInformation(PNET_DISPLAY_USER *buf, PDWORD pdwSize) +{ + const WCHAR sAdminUserName[] = { + 'A','d','m','i','n','i','s','t','r','a','t','o','r',0}; + + /* sizes of the field buffers in WCHARS */ + int name_sz, comment_sz, full_name_sz; + PNET_DISPLAY_USER usr; + + /* set up buffer */ + name_sz = lstrlenW(sAdminUserName); + comment_sz = 1; + full_name_sz = 1; + + *pdwSize = sizeof(NET_DISPLAY_USER); + *pdwSize += (name_sz + comment_sz + full_name_sz) * sizeof(WCHAR); + NetApiBufferAllocate(*pdwSize, (LPVOID *) buf); + + usr = *buf; + usr->usri1_name = (LPWSTR) ((PBYTE) usr + sizeof(NET_DISPLAY_USER)); + usr->usri1_comment = (LPWSTR) ( + ((PBYTE) usr->usri1_name) + name_sz * sizeof(WCHAR)); + usr->usri1_full_name = (LPWSTR) ( + ((PBYTE) usr->usri1_comment) + comment_sz * sizeof(WCHAR)); + + /* set data */ + lstrcpyW(usr->usri1_name, sAdminUserName); + usr->usri1_comment[0] = 0; + usr->usri1_flags = UF_SCRIPT | UF_NORMAL_ACCOUNT | UF_DONT_EXPIRE_PASSWD; + usr->usri1_full_name[0] = 0; + usr->usri1_user_id = 500; + usr->usri1_next_index = 0; +} + +/************************************************************ + * ACCESS_QueryGuestDisplayInformation + * + * Creates a buffer with information for the Guest User + */ +void ACCESS_QueryGuestDisplayInformation(PNET_DISPLAY_USER *buf, PDWORD pdwSize) +{ + const WCHAR sGuestUserName[] = { + 'G','u','e','s','t',0 }; + + /* sizes of the field buffers in WCHARS */ + int name_sz, comment_sz, full_name_sz; + PNET_DISPLAY_USER usr; + + /* set up buffer */ + name_sz = lstrlenW(sGuestUserName); + comment_sz = 1; + full_name_sz = 1; + + *pdwSize = sizeof(NET_DISPLAY_USER); + *pdwSize += (name_sz + comment_sz + full_name_sz) * sizeof(WCHAR); + NetApiBufferAllocate(*pdwSize, (LPVOID *) buf); + + usr = *buf; + usr->usri1_name = (LPWSTR) ((PBYTE) usr + sizeof(NET_DISPLAY_USER)); + usr->usri1_comment = (LPWSTR) ( + ((PBYTE) usr->usri1_name) + name_sz * sizeof(WCHAR)); + usr->usri1_full_name = (LPWSTR) ( + ((PBYTE) usr->usri1_comment) + comment_sz * sizeof(WCHAR)); + + /* set data */ + lstrcpyW(usr->usri1_name, sGuestUserName); + usr->usri1_comment[0] = 0; + usr->usri1_flags = UF_ACCOUNTDISABLE | UF_SCRIPT | UF_NORMAL_ACCOUNT | + UF_DONT_EXPIRE_PASSWD; + usr->usri1_full_name[0] = 0; + usr->usri1_user_id = 500; + usr->usri1_next_index = 0; +} + +/************************************************************ + * NetQueryDisplayInformation (NETAPI32.@) + * Copies NET_DISPLAY_USER record. + */ +void ACCESS_CopyDisplayUser(PNET_DISPLAY_USER dest, LPWSTR *dest_buf, + PNET_DISPLAY_USER src) +{ + LPWSTR str = *dest_buf; + + src->usri1_name = str; + lstrcpyW(src->usri1_name, dest->usri1_name); + str = (LPWSTR) ( + ((PBYTE) str) + (lstrlenW(str) + 1) * sizeof(WCHAR)); + + src->usri1_comment = str; + lstrcpyW(src->usri1_comment, dest->usri1_comment); + str = (LPWSTR) ( + ((PBYTE) str) + (lstrlenW(str) + 1) * sizeof(WCHAR)); + + src->usri1_flags = dest->usri1_flags; + + src->usri1_full_name = str; + lstrcpyW(src->usri1_full_name, dest->usri1_full_name); + str = (LPWSTR) ( + ((PBYTE) str) + (lstrlenW(str) + 1) * sizeof(WCHAR)); + + src->usri1_user_id = dest->usri1_user_id; + src->usri1_next_index = dest->usri1_next_index; + *dest_buf = str; +} + +/************************************************************ + * NetQueryDisplayInformation (NETAPI32.@) + * + * The buffer structure: + * - array of fixed size record of the level type + * - strings, referenced by the record of the level type + */ +NET_API_STATUS WINAPI +NetQueryDisplayInformation( + LPWSTR ServerName, DWORD Level, DWORD Index, DWORD EntriesRequested, + DWORD PreferredMaximumLength, LPDWORD ReturnedEntryCount, + PVOID *SortedBuffer) +{ + TRACE("(%s, %ld, %ld, %ld, %ld, %p, %p)\n", debugstr_w(ServerName), + Level, Index, EntriesRequested, PreferredMaximumLength, + ReturnedEntryCount, SortedBuffer); + NETAPI_ForceLocalComputer(ServerName, ERROR_ACCESS_DENIED); + switch (Level) + { + case 1: + { + /* current record */ + PNET_DISPLAY_USER inf; + /* current available strings buffer */ + LPWSTR str; + PNET_DISPLAY_USER admin, guest; + DWORD admin_size, guest_size; + LPWSTR name = NULL; + DWORD dwSize; + + /* sizes of the field buffers in WCHARS */ + int name_sz, comment_sz, full_name_sz; + + /* number of the records, returned in SortedBuffer + 3 - for current user, Administrator and Guest users + */ + int records = 3; + + FIXME("Level %ld partially implemented\n", Level); + *ReturnedEntryCount = records; + comment_sz = 1; + full_name_sz = 1; + + /* get data */ + dwSize = UNLEN + 1; + NetApiBufferAllocate(dwSize, (LPVOID *) &name); + if (!GetUserNameW(name, &dwSize)) + { + NetApiBufferFree(name); + return ERROR_ACCESS_DENIED; + } + name_sz = dwSize; + ACCESS_QueryAdminDisplayInformation(&admin, &admin_size); + ACCESS_QueryGuestDisplayInformation(&guest, &guest_size); + + /* set up buffer */ + dwSize = sizeof(NET_DISPLAY_USER) * records; + dwSize += (name_sz + comment_sz + full_name_sz) * sizeof(WCHAR); + + NetApiBufferAllocate(dwSize + + admin_size - sizeof(NET_DISPLAY_USER) + + guest_size - sizeof(NET_DISPLAY_USER), + (LPVOID *) SortedBuffer); + inf = (PNET_DISPLAY_USER) *SortedBuffer; + str = (LPWSTR) ((PBYTE) inf + sizeof(NET_DISPLAY_USER) * records); + inf->usri1_name = str; + str = (LPWSTR) ( + ((PBYTE) str) + name_sz * sizeof(WCHAR)); + inf->usri1_comment = str; + str = (LPWSTR) ( + ((PBYTE) str) + comment_sz * sizeof(WCHAR)); + inf->usri1_full_name = str; + str = (LPWSTR) ( + ((PBYTE) str) + full_name_sz * sizeof(WCHAR)); + + /* set data */ + lstrcpyW(inf->usri1_name, name); + NetApiBufferFree(name); + inf->usri1_comment[0] = 0; + inf->usri1_flags = + UF_SCRIPT | UF_NORMAL_ACCOUNT | UF_DONT_EXPIRE_PASSWD; + inf->usri1_full_name[0] = 0; + inf->usri1_user_id = 0; + inf->usri1_next_index = 0; + + inf++; + ACCESS_CopyDisplayUser(admin, &str, inf); + NetApiBufferFree(admin); + + inf++; + ACCESS_CopyDisplayUser(guest, &str, inf); + NetApiBufferFree(guest); + break; + } + + case 2: + case 3: + { + FIXME("Level %ld is not implemented\n", Level); + break; + } + + default: + ERR("Invalid level %ld is specified\n", Level); + return ERROR_INVALID_LEVEL; + } + return NERR_Success; +} diff --git a/dlls/netapi32/apibuf.c b/dlls/netapi32/apibuf.c index f2ea20837ae..8e9e1ee879f 100644 --- a/dlls/netapi32/apibuf.c +++ b/dlls/netapi32/apibuf.c @@ -83,12 +83,3 @@ NET_API_STATUS WINAPI NetApiBufferSize(LPVOID Buffer, LPDWORD ByteCount) return NERR_Success; } - -/************************************************************ - * NetapipBufferAllocate (NETAPI32.@) - */ -NET_API_STATUS WINAPI NetapipBufferAllocate(DWORD ByteCount, LPVOID* Buffer) -{ - TRACE("(%ld, %p)\n", ByteCount, Buffer); - return NetApiBufferAllocate(ByteCount, Buffer); -} diff --git a/dlls/netapi32/browsr.c b/dlls/netapi32/browsr.c new file mode 100644 index 00000000000..d969c4577ac --- /dev/null +++ b/dlls/netapi32/browsr.c @@ -0,0 +1,47 @@ +/* + * Copyright 2002 Andriy Palamarchuk + * + * netapi32 browser functions + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(netapi32); + +/************************************************************ + * I_BrowserSetNetlogonState (NETAPI32.@) + */ +NET_API_STATUS WINAPI I_BrowserSetNetlogonState( + LPWSTR ServerName, LPWSTR DomainName, LPWSTR EmulatedServerName, + DWORD Role) +{ + return ERROR_NOT_SUPPORTED; +} + +/************************************************************ + * I_BrowserQueryEmulatedDomains (NETAPI32.@) + */ +NET_API_STATUS WINAPI I_BrowserQueryEmulatedDomains( + LPWSTR ServerName, PBROWSER_EMULATED_DOMAIN *EmulatedDomains, + LPDWORD EntriesRead) +{ + return ERROR_NOT_SUPPORTED; +} diff --git a/dlls/netapi32/netapi32.spec b/dlls/netapi32/netapi32.spec index b065f1b370e..9a31f31bde0 100644 --- a/dlls/netapi32/netapi32.spec +++ b/dlls/netapi32/netapi32.spec @@ -2,13 +2,13 @@ init NETAPI32_LibMain @ stub I_BrowserDebugCall @ stub I_BrowserDebugTrace -@ stub I_BrowserQueryEmulatedDomains +@ stdcall I_BrowserQueryEmulatedDomains(wstr ptr ptr) I_BrowserQueryEmulatedDomains @ stub I_BrowserQueryOtherDomains @ stub I_BrowserQueryStatistics @ stub I_BrowserResetNetlogonState @ stub I_BrowserResetStatistics @ stub I_BrowserServerEnum -@ stub I_BrowserSetNetlogonState +@ stdcall I_BrowserSetNetlogonState(wstr wstr wstr long) I_BrowserSetNetlogonState @ stub I_NetAccountDeltas @ stub I_NetAccountSync @ stub I_NetDatabaseDeltas @@ -103,7 +103,7 @@ init NETAPI32_LibMain @ stub NetMessageNameDel @ stub NetMessageNameEnum @ stub NetMessageNameGetInfo -@ stub NetQueryDisplayInformation +@ stdcall NetQueryDisplayInformation(wstr long long long long ptr ptr) NetQueryDisplayInformation @ stub NetRemoteComputerSupports @ stub NetRemoteTOD @ stub NetReplExportDirAdd @@ -190,7 +190,7 @@ init NETAPI32_LibMain @ stub NetUserDel @ stub NetUserEnum @ stub NetUserGetGroups -@ stub NetUserGetInfo +@ stdcall NetUserGetInfo(wstr wstr long ptr) NetUserGetInfo @ stub NetUserGetLocalGroups @ stub NetUserModalsGet @ stub NetUserModalsSet @@ -204,7 +204,7 @@ init NETAPI32_LibMain @ stub NetWkstaUserEnum @ stdcall NetWkstaUserGetInfo(wstr long ptr) NetWkstaUserGetInfo @ stub NetWkstaUserSetInfo -@ stdcall NetapipBufferAllocate(long ptr) NetapipBufferAllocate +@ stdcall NetapipBufferAllocate(long ptr) NetApiBufferAllocate @ stdcall Netbios(ptr) Netbios @ stub NetpAccessCheck @ stub NetpAccessCheckAndAudit @@ -221,7 +221,7 @@ init NETAPI32_LibMain @ stub NetpCreateSecurityObject @ stub NetpDbgDisplayServerInfo @ stub NetpDbgPrint -@ stub NetpDeleteSecurityObject +@ forward NetpDeleteSecurityObject ntdll.RtlDeleteSecurityObject @ stdcall NetpGetComputerName(ptr) NetpGetComputerName @ stub NetpGetConfigBool @ stub NetpGetConfigDword @@ -231,7 +231,7 @@ init NETAPI32_LibMain @ stub NetpGetFileSecurity @ stub NetpGetPrivilege @ stub NetpHexDump -@ stub NetpInitOemString +@ forward NetpInitOemString ntdll.RtlInitAnsiString @ stub NetpIsRemote @ stub NetpIsUncComputerNameValid @ stub NetpLocalTimeZoneOffset diff --git a/dlls/netapi32/netapi32_misc.h b/dlls/netapi32/netapi32_misc.h new file mode 100644 index 00000000000..92cbc26d07a --- /dev/null +++ b/dlls/netapi32/netapi32_misc.h @@ -0,0 +1,35 @@ +/* + * Copyright 2002 Andriy Palamarchuk + * + * netapi32 internal functions. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, writ +e to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __WINE_NETAPI32_MISC_H +#define __WINE_NETAPI32_MISC_H + +extern BOOL NETAPI_IsLocalComputer(LPCWSTR ServerName); + +#define NETAPI_ForceLocalComputer(ServerName, FailureCode) \ + if (!NETAPI_IsLocalComputer(ServerName)) \ + { \ + FIXME("Action Implemented for local computer only. " \ + "Requested for server %s\n", debugstr_w(ServerName)); \ + return FailureCode; \ + } + +#endif diff --git a/dlls/netapi32/tests/.cvsignore b/dlls/netapi32/tests/.cvsignore index b2daf40bcc3..cf9ee3dfd4a 100644 --- a/dlls/netapi32/tests/.cvsignore +++ b/dlls/netapi32/tests/.cvsignore @@ -1,4 +1,5 @@ Makefile +access.ok apibuf.ok netapi32_test.exe.spec.c testlist.c diff --git a/dlls/netapi32/tests/Makefile.in b/dlls/netapi32/tests/Makefile.in index 75987889a98..d474fd5b9b1 100644 --- a/dlls/netapi32/tests/Makefile.in +++ b/dlls/netapi32/tests/Makefile.in @@ -3,9 +3,10 @@ TOPOBJDIR = ../../.. SRCDIR = @srcdir@ VPATH = @srcdir@ TESTDLL = netapi32.dll -IMPORTS = netapi32 +IMPORTS = netapi32 advapi32 CTESTS = \ + access.c \ apibuf.c \ wksta.c diff --git a/dlls/netapi32/tests/access.c b/dlls/netapi32/tests/access.c new file mode 100644 index 00000000000..7e2c7075c35 --- /dev/null +++ b/dlls/netapi32/tests/access.c @@ -0,0 +1,154 @@ +/* + * Copyright 2002 Andriy Palamarchuk + * + * Conformance test of the access functions. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include + +WCHAR user_name[UNLEN + 1]; +WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1]; + +const WCHAR sAdminUserName[] = {'A','d','m','i','n','i','s','t','r','a','t', + 'o','r',0}; +const WCHAR sGuestUserName[] = {'G','u','e','s','t',0}; +const WCHAR sNonexistentUser[] = {'N','o','n','e','x','i','s','t','e','n','t',' ', + 'U','s','e','r',0}; +const WCHAR sBadNetPath[] = {'\\','\\','B','a',' ',' ','p','a','t','h',0}; +const WCHAR sInvalidName[] = {'\\',0}; +const WCHAR sInvalidName2[] = {'\\','\\',0}; +const WCHAR sEmptyStr[] = { 0 }; + + +void init_access_tests(void) +{ + DWORD dwSize; + + user_name[0] = 0; + dwSize = sizeof(user_name); + ok(GetUserNameW(user_name, &dwSize), "User Name Retrieved"); + + computer_name[0] = 0; + dwSize = sizeof(computer_name); + ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved"); +} + +void run_usergetinfo_tests(void) +{ + PUSER_INFO_0 ui0 = NULL; + PUSER_INFO_10 ui10 = NULL; + DWORD dwSize; + + /* Level 0 */ + ok(NetUserGetInfo(NULL, sAdminUserName, 0, (LPBYTE *)&ui0) == NERR_Success, + "NetUserGetInfo is successful"); + ok(!lstrcmpW(sAdminUserName, ui0->usri0_name), "This is really user name"); + NetApiBufferSize(ui0, &dwSize); + ok(dwSize >= (sizeof(USER_INFO_0) + + (lstrlenW(ui0->usri0_name) + 1) * sizeof(WCHAR)), + "Is allocated with NetApiBufferAllocate"); + + /* Level 10 */ + ok(NetUserGetInfo(NULL, sAdminUserName, 10, (LPBYTE *)&ui10) == NERR_Success, + "NetUserGetInfo is successful"); + ok(!lstrcmpW(sAdminUserName, ui10->usri10_name), "This is really user name"); + NetApiBufferSize(ui10, &dwSize); + ok(dwSize >= (sizeof(USER_INFO_10) + + (lstrlenW(ui10->usri10_name) + 1 + + lstrlenW(ui10->usri10_comment) + 1 + + lstrlenW(ui10->usri10_usr_comment) + 1 + + lstrlenW(ui10->usri10_full_name) + 1) * sizeof(WCHAR)), + "Is allocated with NetApiBufferAllocate"); + + NetApiBufferFree(ui0); + NetApiBufferFree(ui10); + + /* errors handling */ + ok(NetUserGetInfo(NULL, sAdminUserName, 10000, (LPBYTE *)&ui0) == ERROR_INVALID_LEVEL, + "Invalid Level"); + ok(NetUserGetInfo(NULL, sNonexistentUser, 0, (LPBYTE *)&ui0) == NERR_UserNotFound, + "Invalid User Name"); + todo_wine { + /* FIXME - Currently Wine can't verify whether the network path is good or bad */ + ok(NetUserGetInfo(sBadNetPath, sAdminUserName, 0, (LPBYTE *)&ui0) == ERROR_BAD_NETPATH, + "Bad Network Path"); + } + ok(NetUserGetInfo(sEmptyStr, sAdminUserName, 0, (LPBYTE *)&ui0) == ERROR_BAD_NETPATH, + "Bad Network Path"); + ok(NetUserGetInfo(sInvalidName, sAdminUserName, 0, (LPBYTE *)&ui0) == ERROR_INVALID_NAME, + "Invalid Server Name"); + ok(NetUserGetInfo(sInvalidName2, sAdminUserName, 0, (LPBYTE *)&ui0) == ERROR_INVALID_NAME, + "Invalid Server Name"); +} + +/* checks Level 1 of NetQueryDisplayInformation */ +void run_querydisplayinformation1_tests(void) +{ + PNET_DISPLAY_USER Buffer, rec; + DWORD Result, EntryCount; + DWORD i = 0; + BOOL hasAdmin = FALSE; + BOOL hasGuest = FALSE; + + do + { + Result = NetQueryDisplayInformation( + NULL, 1, i, 1000, MAX_PREFERRED_LENGTH, &EntryCount, + (PVOID *)&Buffer); + + ok((Result == ERROR_SUCCESS) || (Result == ERROR_MORE_DATA), + "Information Retrieved"); + rec = Buffer; + for(; EntryCount > 0; EntryCount--) + { + if (!lstrcmpW(rec->usri1_name, sAdminUserName)) + { + ok(!hasAdmin, "One admin user"); + ok(rec->usri1_flags & UF_SCRIPT, "UF_SCRIPT flag is set"); + ok(rec->usri1_flags & UF_NORMAL_ACCOUNT, "UF_NORMAL_ACCOUNT flag is set"); + hasAdmin = TRUE; + } + else if (!lstrcmpW(rec->usri1_name, sGuestUserName)) + { + ok(!hasGuest, "One guest record"); + ok(rec->usri1_flags & UF_SCRIPT, "UF_SCRIPT flag is set"); + ok(rec->usri1_flags & UF_NORMAL_ACCOUNT, "UF_NORMAL_ACCOUNT flag is set"); + hasGuest = TRUE; + } + + i = rec->usri1_next_index; + rec++; + } + + NetApiBufferFree(Buffer); + } while (Result == ERROR_MORE_DATA); + + ok(hasAdmin, "Has Administrator account"); + ok(hasGuest, "Has Guest account"); +} + +START_TEST(access) +{ + init_access_tests(); + run_usergetinfo_tests(); + run_querydisplayinformation1_tests(); +} diff --git a/dlls/netapi32/tests/wksta.c b/dlls/netapi32/tests/wksta.c index 3f95aab79b2..42079f46241 100644 --- a/dlls/netapi32/tests/wksta.c +++ b/dlls/netapi32/tests/wksta.c @@ -29,6 +29,22 @@ typedef NET_API_STATUS (WINAPI *NetpGetComputerName_func)(LPWSTR *Buffer); +WCHAR user_name[UNLEN + 1]; +WCHAR computer_name[MAX_COMPUTERNAME_LENGTH + 1]; + +void init_wksta_tests(void) +{ + DWORD dwSize; + + user_name[0] = 0; + dwSize = sizeof(user_name); + ok(GetUserNameW(user_name, &dwSize), "User Name Retrieved"); + + computer_name[0] = 0; + dwSize = sizeof(computer_name); + ok(GetComputerNameW(computer_name, &dwSize), "Computer Name Retrieved"); +} + void run_get_comp_name_tests(void) { HANDLE hnetapi32 = GetModuleHandleA("netapi32.dll"); @@ -41,13 +57,13 @@ void run_get_comp_name_tests(void) if (pNetpGetComputerName) { ok((*pNetpGetComputerName)(&ws) == NERR_Success, "Computer name is retrieved"); - ok(ws[0] != 0, "Some value is populated to the buffer"); + ok(!lstrcmpW(computer_name, ws), "This is really computer name"); NetApiBufferFree(ws); } } } -void run_usergetinfo_tests(void) +void run_wkstausergetinfo_tests(void) { LPWKSTA_USER_INFO_0 ui0 = NULL; LPWKSTA_USER_INFO_1 ui1 = NULL; @@ -57,7 +73,7 @@ void run_usergetinfo_tests(void) /* Level 0 */ ok(NetWkstaUserGetInfo(NULL, 0, (LPBYTE *)&ui0) == NERR_Success, "NetWkstaUserGetInfo is successful"); - ok(lstrlenW(ui0->wkui0_username) >= 1, "Buffer is not empty"); + ok(!lstrcmpW(user_name, ui0->wkui0_username), "This is really user name"); NetApiBufferSize(ui0, &dwSize); ok(dwSize >= (sizeof(WKSTA_USER_INFO_0) + lstrlenW(ui0->wkui0_username) * sizeof(WCHAR)), @@ -66,7 +82,6 @@ void run_usergetinfo_tests(void) /* Level 1 */ ok(NetWkstaUserGetInfo(NULL, 1, (LPBYTE *)&ui1) == NERR_Success, "NetWkstaUserGetInfo is successful"); - ok(lstrlenW(ui1->wkui1_username) >= 1, "Buffer is not empty"); ok(lstrcmpW(ui1->wkui1_username, ui0->wkui0_username) == 0, "the same name as returned for level 0"); NetApiBufferSize(ui1, &dwSize); @@ -98,5 +113,7 @@ void run_usergetinfo_tests(void) START_TEST(wksta) { + init_wksta_tests(); run_get_comp_name_tests(); + run_wkstausergetinfo_tests(); } diff --git a/dlls/netapi32/wksta.c b/dlls/netapi32/wksta.c index f94857dd3df..ffac3e276a8 100644 --- a/dlls/netapi32/wksta.c +++ b/dlls/netapi32/wksta.c @@ -18,25 +18,54 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "winbase.h" -#include "nb30.h" -#include "lmwksta.h" -#include "lmapibuf.h" -#include "lmerr.h" -#include "winerror.h" -#include "winternl.h" -#include "ntsecapi.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(netapi32); +/************************************************************ + * NETAPI_IsLocalComputer + * + * Checks whether the server name indicates local machine. + */ +BOOL NETAPI_IsLocalComputer(LPCWSTR ServerName) +{ + if (!ServerName) + { + return TRUE; + } + else + { + DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1; + BOOL Result; + LPWSTR buf; + + NetApiBufferAllocate(dwSize * sizeof(WCHAR), (LPVOID *) &buf); + Result = GetComputerNameW(buf, &dwSize); + if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\')) + ServerName += 2; + Result = Result && !lstrcmpW(ServerName, buf); + NetApiBufferFree(buf); + + return Result; + } +} + /************************************************************ * NetWkstaUserGetInfo (NETAPI32.@) */ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, PBYTE* bufptr) { - TRACE("(%s, %ld, %p): stub\n", debugstr_w(reserved), level, bufptr); + TRACE("(%s, %ld, %p)\n", debugstr_w(reserved), level, bufptr); switch (level) { case 0: @@ -46,20 +75,29 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, /* set up buffer */ NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_0) + dwSize * sizeof(WCHAR), - (LPVOID *) &bufptr); + (LPVOID *) bufptr); - ui = (WKSTA_USER_INFO_0 *) *bufptr; + ui = (PWKSTA_USER_INFO_0) *bufptr; ui->wkui0_username = (LPWSTR) (*bufptr + sizeof(WKSTA_USER_INFO_0)); /* get data */ - if (GetUserNameW(ui->wkui0_username, &dwSize)) + if (!GetUserNameW(ui->wkui0_username, &dwSize)) + { + NetApiBufferFree(ui); return ERROR_NOT_ENOUGH_MEMORY; + } else - return NERR_Success; + NetApiBufferReallocate( + *bufptr, sizeof(WKSTA_USER_INFO_0) + + (lstrlenW(ui->wkui0_username) + 1) * sizeof(WCHAR), + (LPVOID *) bufptr); + break; } + case 1: { PWKSTA_USER_INFO_1 ui; + PWKSTA_USER_INFO_0 ui0; DWORD dwSize; LSA_OBJECT_ATTRIBUTES ObjectAttributes; LSA_HANDLE PolicyHandle; @@ -70,10 +108,14 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, int username_sz, logon_domain_sz, oth_domains_sz, logon_server_sz; FIXME("Level 1 processing is partially implemented\n"); - username_sz = UNLEN + 1; oth_domains_sz = 1; logon_server_sz = 1; + /* get some information first to estimate size of the buffer */ + ui0 = NULL; + NetWkstaUserGetInfo(NULL, 0, (PBYTE *) &ui0); + username_sz = lstrlenW(ui0->wkui0_username) + 1; + ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes)); NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes, POLICY_VIEW_LOCAL_INFORMATION, @@ -82,9 +124,9 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, { ERR("LsaOpenPolicyFailed with NT status %lx\n", LsaNtStatusToWinError(NtStatus)); + NetApiBufferFree(ui0); return ERROR_NOT_ENOUGH_MEMORY; } - LsaQueryInformationPolicy(PolicyHandle, PolicyAccountDomainInformation, (PVOID*) &DomainInfo); logon_domain_sz = lstrlenW(DomainInfo->DomainName.Buffer) + 1; @@ -94,7 +136,7 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1) + (username_sz + logon_domain_sz + oth_domains_sz + logon_server_sz) * sizeof(WCHAR), - (LPVOID *) &bufptr); + (LPVOID *) bufptr); ui = (WKSTA_USER_INFO_1 *) *bufptr; ui->wkui1_username = (LPWSTR) (*bufptr + sizeof(WKSTA_USER_INFO_1)); ui->wkui1_logon_domain = (LPWSTR) ( @@ -108,14 +150,17 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, /* get data */ dwSize = username_sz; - if (GetUserNameW(ui->wkui1_username, &dwSize)) - return ERROR_NOT_ENOUGH_MEMORY; + lstrcpyW(ui->wkui1_username, ui0->wkui0_username); + NetApiBufferFree(ui0); + lstrcpynW(ui->wkui1_logon_domain, DomainInfo->DomainName.Buffer, logon_domain_sz); + LsaFreeMemory(DomainInfo); + /* FIXME. Not implemented. Populated with empty strings */ ui->wkui1_oth_domains[0] = 0; ui->wkui1_logon_server[0] = 0; - return NERR_Success; + break; } case 1101: { @@ -127,19 +172,20 @@ NET_API_STATUS WINAPI NetWkstaUserGetInfo(LPWSTR reserved, DWORD level, /* set up buffer */ NetApiBufferAllocate(sizeof(WKSTA_USER_INFO_1101) + dwSize * sizeof(WCHAR), - (LPVOID *) &bufptr); + (LPVOID *) bufptr); ui = (PWKSTA_USER_INFO_1101) *bufptr; ui->wkui1101_oth_domains = (LPWSTR)(ui + 1); /* get data */ ui->wkui1101_oth_domains[0] = 0; - return NERR_Success; + break; } default: ERR("Invalid level %ld is specified\n", level); return ERROR_INVALID_LEVEL; } + return NERR_Success; } /************************************************************ @@ -151,5 +197,16 @@ NET_API_STATUS WINAPI NetpGetComputerName(LPWSTR *Buffer) TRACE("(%p)\n", Buffer); NetApiBufferAllocate(dwSize * sizeof(WCHAR), (LPVOID *) Buffer); - return !GetComputerNameW(*Buffer, &dwSize); + if (GetComputerNameW(*Buffer, &dwSize)) + { + NetApiBufferReallocate( + *Buffer, dwSize * sizeof(WCHAR), + (LPVOID *) Buffer); + return NERR_Success; + } + else + { + NetApiBufferFree(*Buffer); + return ERROR_NOT_ENOUGH_MEMORY; + } } diff --git a/include/Makefile.in b/include/Makefile.in index 1b8ff81fbbd..348382e2844 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -44,6 +44,7 @@ INSTALLED_INCLUDES = \ lm.h \ lmaccess.h \ lmapibuf.h \ + lmbrowsr.h \ lmcons.h \ lmerr.h \ lmwksta.h \ diff --git a/include/lm.h b/include/lm.h index 7ae35976b52..87a46e1e8d6 100644 --- a/include/lm.h +++ b/include/lm.h @@ -23,6 +23,7 @@ #include #include +#include #include #include #include diff --git a/include/lmaccess.h b/include/lmaccess.h index 2c808f71bb6..2e661cb904a 100644 --- a/include/lmaccess.h +++ b/include/lmaccess.h @@ -1,7 +1,7 @@ /* * Copyright 2002 Andriy Palamarchuk * - * User API. + * User information Net API. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,14 +18,368 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __WINE_LMAPIBUF_H -#define __WINE_LMAPIBUF_H +#ifndef __WINE_LMACCESS_H +#define __WINE_LMACCESS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#define UF_SCRIPT 0x000001 +#define UF_ACCOUNTDISABLE 0x000002 +#define UF_HOMEDIR_REQUIRED 0x000008 +#define UF_LOCKOUT 0x000010 +#define UF_PASSWD_NOTREQD 0x000020 +#define UF_PASSWD_CANT_CHANGE 0x000040 +#define UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED 0x000080 +#define UF_TEMP_DUPLICATE_ACCOUNT 0x000100 +#define UF_NORMAL_ACCOUNT 0x000200 +#define UF_INTERDOMAIN_TRUST_ACCOUNT 0x000800 +#define UF_WORKSTATION_TRUST_ACCOUNT 0x001000 +#define UF_SERVER_TRUST_ACCOUNT 0x002000 +#define UF_DONT_EXPIRE_PASSWD 0x010000 +#define UF_MNS_LOGON_ACCOUNT 0x020000 +#define UF_SMARTCARD_REQUIRED 0x040000 +#define UF_TRUSTED_FOR_DELEGATION 0x080000 +#define UF_NOT_DELEGATED 0x100000 +#define UF_USE_DES_KEY_ONLY 0x200000 +#define UF_DONT_REQUIRE_PREAUTH 0x400000 +#define UF_PASSWORD_EXPIRED 0x800000 + + +#define UF_MACHINE_ACCOUNT_MASK ( \ + UF_INTERDOMAIN_TRUST_ACCOUNT | \ + UF_WORKSTATION_TRUST_ACCOUNT | \ + UF_SERVER_TRUST_ACCOUNT) + +#define UF_ACCOUNT_TYPE_MASK ( \ + UF_TEMP_DUPLICATE_ACCOUNT | \ + UF_NORMAL_ACCOUNT | \ + UF_INTERDOMAIN_TRUST_ACCOUNT | \ + UF_WORKSTATION_TRUST_ACCOUNT | \ + UF_SERVER_TRUST_ACCOUNT) + +#define UF_SETTABLE_BITS ( \ + UF_SCRIPT | \ + UF_ACCOUNTDISABLE | \ + UF_LOCKOUT | \ + UF_HOMEDIR_REQUIRED | \ + UF_PASSWD_NOTREQD | \ + UF_PASSWD_CANT_CHANGE | \ + UF_ACCOUNT_TYPE_MASK | \ + UF_DONT_EXPIRE_PASSWD | \ + UF_MNS_LOGON_ACCOUNT |\ + UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED |\ + UF_SMARTCARD_REQUIRED | \ + UF_TRUSTED_FOR_DELEGATION | \ + UF_NOT_DELEGATED | \ + UF_USE_DES_KEY_ONLY | \ + UF_DONT_REQUIRE_PREAUTH |\ + UF_PASSWORD_EXPIRED) + +#if defined(__GNUC__) +# define GROUP_SPECIALGRP_USERS (const WCHAR []){ 'U','S','E','R','S',0 } +#elif defined(_MSC_VER) +# define GROUP_SPECIALGRP_USERS L"USERS" +#else +static const WCHAR GROUP_SPECIALGRP_USERS[] = { 'U','S','E','R','S',0 }; +#endif + +#if defined(__GNUC__) +# define GROUP_SPECIALGRP_ADMINS (const WCHAR []){ 'A','D','M','I','N','S',0 } +#elif defined(_MSC_VER) +# define GROUP_SPECIALGRP_ADMINS L"ADMINS" +#else +static const WCHAR GROUP_SPECIALGRP_ADMINS[] = { 'A','D','M','I','N','S',0 }; +#endif + +#if defined(__GNUC__) +# define GROUP_SPECIALGRP_GUESTS (const WCHAR []){ 'G','U','E','S','T','S',0 } +#elif defined(_MSC_VER) +# define GROUP_SPECIALGRP_GUESTS L"GUESTS" +#else +static const WCHAR GROUP_SPECIALGRP_GUESTS[] = { 'G','U','E','S','T','S',0 }; +#endif + +#if defined(__GNUC__) +# define GROUP_SPECIALGRP_LOCAL (const WCHAR []){ 'L','O','C','A','L',0 } +#elif defined(_MSC_VER) +# define GROUP_SPECIALGRP_LOCAL L"LOCAL" +#else +static const WCHAR GROUP_SPECIALGRP_LOCAL[] = { 'L','O','C','A','L',0 }; +#endif + +/* NetGetUserInfo structures */ +typedef struct _USER_INFO_0 { + LPWSTR usri0_name; +} USER_INFO_0, *PUSER_INFO_0, *LPUSER_INFO_0; + +typedef struct _USER_INFO_1 { + LPWSTR usri1_name; + LPWSTR usri1_password; + DWORD usri1_password_age; + DWORD usri1_priv; + LPWSTR usri1_home_dir; + LPWSTR usri1_comment; + DWORD usri1_flags; + LPWSTR usri1_script_path; +} USER_INFO_1, *PUSER_INFO_1, *LPUSER_INFO_1; + +typedef struct _USER_INFO_2 { + LPWSTR usri2_name; + LPWSTR usri2_password; + DWORD usri2_password_age; + DWORD usri2_priv; + LPWSTR usri2_home_dir; + LPWSTR usri2_comment; + DWORD usri2_flags; + LPWSTR usri2_script_path; + DWORD usri2_auth_flags; + LPWSTR usri2_full_name; + LPWSTR usri2_usr_comment; + LPWSTR usri2_parms; + LPWSTR usri2_workstations; + DWORD usri2_last_logon; + DWORD usri2_last_logoff; + DWORD usri2_acct_expires; + DWORD usri2_max_storage; + DWORD usri2_units_per_week; + PBYTE usri2_logon_hours; + DWORD usri2_bad_pw_count; + DWORD usri2_num_logons; + LPWSTR usri2_logon_server; + DWORD usri2_country_code; + DWORD usri2_code_page; +} USER_INFO_2, *PUSER_INFO_2, *LPUSER_INFO_2; + +typedef struct _USER_INFO_3 { + LPWSTR usri3_name; + LPWSTR usri3_password; + DWORD usri3_password_age; + DWORD usri3_priv; + LPWSTR usri3_home_dir; + LPWSTR usri3_comment; + DWORD usri3_flags; + LPWSTR usri3_script_path; + DWORD usri3_auth_flags; + LPWSTR usri3_full_name; + LPWSTR usri3_usr_comment; + LPWSTR usri3_parms; + LPWSTR usri3_workstations; + DWORD usri3_last_logon; + DWORD usri3_last_logoff; + DWORD usri3_acct_expires; + DWORD usri3_max_storage; + DWORD usri3_units_per_week; + PBYTE usri3_logon_hours; + DWORD usri3_bad_pw_count; + DWORD usri3_num_logons; + LPWSTR usri3_logon_server; + DWORD usri3_country_code; + DWORD usri3_code_page; + DWORD usri3_user_id; + DWORD usri3_primary_group_id; + LPWSTR usri3_profile; + LPWSTR usri3_home_dir_drive; + DWORD usri3_password_expired; +} USER_INFO_3, *PUSER_INFO_3, *LPUSER_INFO_3; + +typedef struct _USER_INFO_4 { + LPWSTR usri4_name; + LPWSTR usri4_password; + DWORD usri4_password_age; + DWORD usri4_priv; + LPWSTR usri4_home_dir; + LPWSTR usri4_comment; + DWORD usri4_flags; + LPWSTR usri4_script_path; + DWORD usri4_auth_flags; + LPWSTR usri4_full_name; + LPWSTR usri4_usr_comment; + LPWSTR usri4_parms; + LPWSTR usri4_workstations; + DWORD usri4_last_logon; + DWORD usri4_last_logoff; + DWORD usri4_acct_expires; + DWORD usri4_max_storage; + DWORD usri4_units_per_week; + PBYTE usri4_logon_hours; + DWORD usri4_bad_pw_count; + DWORD usri4_num_logons; + LPWSTR usri4_logon_server; + DWORD usri4_country_code; + DWORD usri4_code_page; + PSID usri4_user_sid; + DWORD usri4_primary_group_id; + LPWSTR usri4_profile; + LPWSTR usri4_home_dir_drive; + DWORD usri4_password_expired; +} USER_INFO_4, *PUSER_INFO_4, *LPUSER_INFO_4; typedef struct _USER_INFO_10 { - LPWSTR usri10_name; - LPWSTR usri10_comment; - LPWSTR usri10_usr_comment; - LPWSTR usri10_full_name; + LPWSTR usri10_name; + LPWSTR usri10_comment; + LPWSTR usri10_usr_comment; + LPWSTR usri10_full_name; } USER_INFO_10, *PUSER_INFO_10, *LPUSER_INFO_10; +typedef struct _USER_INFO_11 { + LPWSTR usri11_name; + LPWSTR usri11_comment; + LPWSTR usri11_usr_comment; + LPWSTR usri11_full_name; + DWORD usri11_priv; + DWORD usri11_auth_flags; + DWORD usri11_password_age; + LPWSTR usri11_home_dir; + LPWSTR usri11_parms; + DWORD usri11_last_logon; + DWORD usri11_last_logoff; + DWORD usri11_bad_pw_count; + DWORD usri11_num_logons; + LPWSTR usri11_logon_server; + DWORD usri11_country_code; + LPWSTR usri11_workstations; + DWORD usri11_max_storage; + DWORD usri11_units_per_week; + PBYTE usri11_logon_hours; + DWORD usri11_code_page; +} USER_INFO_11, *PUSER_INFO_11, *LPUSER_INFO_11; + +typedef struct _USER_INFO_20 { + LPWSTR usri20_name; + LPWSTR usri20_full_name; + LPWSTR usri20_comment; + DWORD usri20_flags; + DWORD usri20_user_id; +} USER_INFO_20, *PUSER_INFO_20, *LPUSER_INFO_20; + +typedef struct _USER_INFO_23 { + LPWSTR usri23_name; + LPWSTR usri23_full_name; + LPWSTR usri23_comment; + DWORD usri23_flags; + PSID usri23_user_sid; +} USER_INFO_23, *PUSER_INFO_23, *LPUSER_INFO_23; + +typedef struct _USER_INFO_1003 { + LPWSTR usri1003_password; +} USER_INFO_1003, *PUSER_INFO_1003, *LPUSER_INFO_1003; + +typedef struct _USER_INFO_1005 { + DWORD usri1005_priv; +} USER_INFO_1005, *PUSER_INFO_1005, *LPUSER_INFO_1005; + +typedef struct _USER_INFO_1006 { + LPWSTR usri1006_home_dir; +} USER_INFO_1006, *PUSER_INFO_1006, *LPUSER_INFO_1006; + +typedef struct _USER_INFO_1007 { + LPWSTR usri1007_comment; +} USER_INFO_1007, *PUSER_INFO_1007, *LPUSER_INFO_1007; + +typedef struct _USER_INFO_1008 { + DWORD usri1008_flags; +} USER_INFO_1008, *PUSER_INFO_1008, *LPUSER_INFO_1008; + +typedef struct _USER_INFO_1009 { + LPWSTR usri1009_script_path; +} USER_INFO_1009, *PUSER_INFO_1009, *LPUSER_INFO_1009; + +typedef struct _USER_INFO_1010 { + DWORD usri1010_auth_flags; +} USER_INFO_1010, *PUSER_INFO_1010, *LPUSER_INFO_1010; + +typedef struct _USER_INFO_1011 { + LPWSTR usri1011_full_name; +} USER_INFO_1011, *PUSER_INFO_1011, *LPUSER_INFO_1011; + +typedef struct _USER_INFO_1012 { + LPWSTR usri1012_usr_comment; +} USER_INFO_1012, *PUSER_INFO_1012, *LPUSER_INFO_1012; + +typedef struct _USER_INFO_1013 { + LPWSTR usri1013_parms; +} USER_INFO_1013, *PUSER_INFO_1013, *LPUSER_INFO_1013; + +typedef struct _USER_INFO_1014 { + LPWSTR usri1014_workstations; +} USER_INFO_1014, *PUSER_INFO_1014, *LPUSER_INFO_1014; + +typedef struct _USER_INFO_1017 { + DWORD usri1017_acct_expires; +} USER_INFO_1017, *PUSER_INFO_1017, *LPUSER_INFO_1017; + +typedef struct _USER_INFO_1018 { + DWORD usri1018_max_storage; +} USER_INFO_1018, *PUSER_INFO_1018, *LPUSER_INFO_1018; + +typedef struct _USER_INFO_1020 { + DWORD usri1020_units_per_week; + LPBYTE usri1020_logon_hours; +} USER_INFO_1020, *PUSER_INFO_1020, *LPUSER_INFO_1020; + +typedef struct _USER_INFO_1023 { + LPWSTR usri1023_logon_server; +} USER_INFO_1023, *PUSER_INFO_1023, *LPUSER_INFO_1023; + +typedef struct _USER_INFO_1024 { + DWORD usri1024_country_code; +} USER_INFO_1024, *PUSER_INFO_1024, *LPUSER_INFO_1024; + +typedef struct _USER_INFO_1025 { + DWORD usri1025_code_page; +} USER_INFO_1025, *PUSER_INFO_1025, *LPUSER_INFO_1025; + +typedef struct _USER_INFO_1051 { + DWORD usri1051_primary_group_id; +} USER_INFO_1051, *PUSER_INFO_1051, *LPUSER_INFO_1051; + +typedef struct _USER_INFO_1052 { + LPWSTR usri1052_profile; +} USER_INFO_1052, *PUSER_INFO_1052, *LPUSER_INFO_1052; + +typedef struct _USER_INFO_1053 { + LPWSTR usri1053_home_dir_drive; +} USER_INFO_1053, *PUSER_INFO_1053, *LPUSER_INFO_1053; + +typedef struct _NET_DISPLAY_USER { + LPWSTR usri1_name; + LPWSTR usri1_comment; + DWORD usri1_flags; + LPWSTR usri1_full_name; + DWORD usri1_user_id; + DWORD usri1_next_index; +} NET_DISPLAY_USER, *PNET_DISPLAY_USER; + +typedef struct _NET_DISPLAY_MACHINE { + LPWSTR usri2_name; + LPWSTR usri2_comment; + DWORD usri2_flags; + DWORD usri2_user_id; + DWORD usri2_next_index; +} NET_DISPLAY_MACHINE, *PNET_DISPLAY_MACHINE; + +typedef struct _NET_DISPLAY_GROUP { + LPWSTR grpi3_name; + LPWSTR grpi3_comment; + DWORD grpi3_group_id; + DWORD grpi3_attributes; + DWORD grpi3_next_index; +} NET_DISPLAY_GROUP, *PNET_DISPLAY_GROUP; + +NET_API_STATUS WINAPI NetUserGetInfo(LPCWSTR servername, LPCWSTR username, + DWORD level, LPBYTE* bufptr); + +NET_API_STATUS WINAPI NetQueryDisplayInformation( + LPWSTR ServerName, DWORD Level, DWORD Index, DWORD EntriesRequested, + DWORD PreferredMaximumLength, LPDWORD ReturnedEntryCount, + PVOID *SortedBuffer); + +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/lmbrowsr.h b/include/lmbrowsr.h new file mode 100644 index 00000000000..9e6abf632ca --- /dev/null +++ b/include/lmbrowsr.h @@ -0,0 +1,47 @@ +/* + * Copyright 2002 Andriy Palamarchuk + * + * Browser NET API calls + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __WINE_LMBROWSR_H +#define __WINE_LMBROWSR_H + + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _BROWSER_EMULATED_DOMAIN { + LPWSTR DomainName; + LPWSTR EmulatedServerName; + DWORD Role; +} BROWSER_EMULATED_DOMAIN, *PBROWSER_EMULATED_DOMAIN; + +NET_API_STATUS WINAPI I_BrowserSetNetlogonState( + LPWSTR ServerName, LPWSTR DomainName, LPWSTR EmulatedServerName, + DWORD Role); + +NET_API_STATUS WINAPI I_BrowserQueryEmulatedDomains( + LPWSTR ServerName, PBROWSER_EMULATED_DOMAIN *EmulatedDomains, + LPDWORD EntriesRead); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/lmcons.h b/include/lmcons.h index 943b95e74c1..5f30a8c7413 100644 --- a/include/lmcons.h +++ b/include/lmcons.h @@ -23,6 +23,8 @@ #define NET_API_STATUS DWORD +#define MAX_PREFERRED_LENGTH ((DWORD) -1) + /* Lan manager API defines */ #define UNLEN 256 /* Maximum user name length */ diff --git a/include/lmerr.h b/include/lmerr.h index 0f606dab90a..e6849c9c499 100644 --- a/include/lmerr.h +++ b/include/lmerr.h @@ -23,8 +23,11 @@ #define NERR_Success 0 -#define NERR_BASE 2100 +#define NERR_BASE 2100 -#define MAX_NERR (NERR_BASE+899) +#define NERR_UserNotFound (NERR_BASE + 121) +#define NERR_InvalidComputer (NERR_BASE + 251) + +#define MAX_NERR (NERR_BASE + 899) #endif