Author: ekohl
Date: Tue Sep 26 07:32:49 2017
New Revision: 75970
URL:
http://svn.reactos.org/svn/reactos?rev=75970&view=rev
Log:
[NETAPI]
Add proper client implementations for NetQueryDisplayInformation() and
NetGetDisplayInformationIndex().
Added:
trunk/reactos/dll/win32/netapi32/display.c (with props)
Removed:
trunk/reactos/dll/win32/netapi32/access.c
Modified:
trunk/reactos/dll/win32/netapi32/CMakeLists.txt
trunk/reactos/dll/win32/netapi32/netapi32.spec
Modified: trunk/reactos/dll/win32/netapi32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netapi32/CMakeLi…
==============================================================================
--- trunk/reactos/dll/win32/netapi32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netapi32/CMakeLists.txt [iso-8859-1] Tue Sep 26 07:32:49 2017
@@ -14,9 +14,9 @@
${REACTOS_SOURCE_DIR}/sdk/include/reactos/idl/wkssvc.idl)
list(APPEND SOURCE
- access.c
apibuf.c
browser.c
+ display.c
dssetup.c
group.c
local_group.c
Removed: trunk/reactos/dll/win32/netapi32/access.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netapi32/access.…
==============================================================================
--- trunk/reactos/dll/win32/netapi32/access.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netapi32/access.c (removed)
@@ -1,248 +0,0 @@
-/*
- * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-#include "netapi32.h"
-
-WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
-
-/************************************************************
- * ACCESS_QueryAdminDisplayInformation
- *
- * Creates a buffer with information for the Admin User
- */
-static void ACCESS_QueryAdminDisplayInformation(PNET_DISPLAY_USER *buf, PDWORD pdwSize)
-{
- static 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) + 1;
- 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 = DOMAIN_USER_RID_ADMIN;
- usr->usri1_next_index = 0;
-}
-
-/************************************************************
- * ACCESS_QueryGuestDisplayInformation
- *
- * Creates a buffer with information for the Guest User
- */
-static void ACCESS_QueryGuestDisplayInformation(PNET_DISPLAY_USER *buf, PDWORD pdwSize)
-{
- static 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) + 1;
- 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 = DOMAIN_USER_RID_GUEST;
- usr->usri1_next_index = 0;
-}
-
-/************************************************************
- * Copies NET_DISPLAY_USER record.
- */
-static void ACCESS_CopyDisplayUser(const NET_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(
- LPCWSTR ServerName, DWORD Level, DWORD Index, DWORD EntriesRequested,
- DWORD PreferredMaximumLength, LPDWORD ReturnedEntryCount,
- PVOID *SortedBuffer)
-{
- TRACE("(%s, %d, %d, %d, %d, %p, %p)\n", debugstr_w(ServerName),
- Level, Index, EntriesRequested, PreferredMaximumLength,
- ReturnedEntryCount, SortedBuffer);
-
- if(!NETAPI_IsLocalComputer(ServerName))
- {
- FIXME("Only implemented on local computer, but requested for "
- "remote server %s\n", debugstr_w(ServerName));
- return 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 %d partially implemented\n", Level);
- *ReturnedEntryCount = records;
- comment_sz = 1;
- full_name_sz = 1;
-
- /* get data */
- dwSize = UNLEN + 1;
- NetApiBufferAllocate(dwSize * sizeof(WCHAR), (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),
- SortedBuffer);
- inf = *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 %d is not implemented\n", Level);
- break;
- }
-
- default:
- TRACE("Invalid level %d is specified\n", Level);
- return ERROR_INVALID_LEVEL;
- }
- return NERR_Success;
-}
Added: trunk/reactos/dll/win32/netapi32/display.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netapi32/display…
==============================================================================
--- trunk/reactos/dll/win32/netapi32/display.c (added)
+++ trunk/reactos/dll/win32/netapi32/display.c [iso-8859-1] Tue Sep 26 07:32:49 2017
@@ -0,0 +1,208 @@
+/*
+ * PROJECT: NetAPI DLL
+ * LICENSE: GPL-2.0 (
https://spdx.org/licenses/GPL-2.0)
+ * PURPOSE: SAM service interface code
+ * COPYRIGHT: Copyright 2017 Eric Kohl (eric.kohl(a)reactos.org)
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include "netapi32.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
+
+/* FUNCTIONS *****************************************************************/
+
+/* PUBLIC FUNCTIONS **********************************************************/
+
+NET_API_STATUS
+WINAPI
+NetQueryDisplayInformation(
+ _In_ LPCWSTR ServerName,
+ _In_ DWORD Level,
+ _In_ DWORD Index,
+ _In_ DWORD EntriesRequested,
+ _In_ DWORD PreferredMaximumLength,
+ _Out_ LPDWORD ReturnedEntryCount,
+ _Out_ PVOID *SortedBuffer)
+{
+ UNICODE_STRING ServerNameString;
+ SAM_HANDLE ServerHandle = NULL;
+ SAM_HANDLE DomainHandle = NULL;
+ DOMAIN_DISPLAY_INFORMATION DisplayInformation;
+ DWORD LocalTotalBytesAvailable;
+ DWORD LocalTotalBytesReturned;
+ DWORD LocalReturnedEntryCount;
+ PVOID LocalSortedBuffer;
+ NET_API_STATUS ApiStatus = NERR_Success;
+ NTSTATUS Status;
+
+ TRACE("NetQueryDisplayInformation(%s, %ld, %ld, %ld, %ld, %p, %p)\n",
+ debugstr_w(ServerName), Level, Index, EntriesRequested,
+ PreferredMaximumLength, ReturnedEntryCount, SortedBuffer);
+
+ *ReturnedEntryCount = 0;
+ *SortedBuffer = NULL;
+
+ switch (Level)
+ {
+ case 1:
+ DisplayInformation = DomainDisplayUser;
+ break;
+
+ case 2:
+ DisplayInformation = DomainDisplayMachine;
+ break;
+
+ case 3:
+ DisplayInformation = DomainDisplayGroup;
+ break;
+
+ default:
+ return ERROR_INVALID_LEVEL;
+ }
+
+ if (ServerName != NULL)
+ RtlInitUnicodeString(&ServerNameString, ServerName);
+
+ /* Connect to the SAM Server */
+ Status = SamConnect((ServerName != NULL) ? &ServerNameString : NULL,
+ &ServerHandle,
+ SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamConnect failed (Status %08lx)\n", Status);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* Open the Account Domain */
+ Status = OpenAccountDomain(ServerHandle,
+ (ServerName != NULL) ? &ServerNameString : NULL,
+ DOMAIN_LIST_ACCOUNTS,
+ &DomainHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("OpenAccountDomain failed (Status %08lx)\n", Status);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* Query the information */
+ Status = SamQueryDisplayInformation(DomainHandle,
+ DisplayInformation,
+ Index,
+ EntriesRequested,
+ PreferredMaximumLength,
+ &LocalTotalBytesAvailable,
+ &LocalTotalBytesReturned,
+ &LocalReturnedEntryCount,
+ &LocalSortedBuffer);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamQueryDisplayInformation failed (Status %08lx)\n", Status);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* FIXME */
+
+done:
+ if (DomainHandle != NULL)
+ SamCloseHandle(DomainHandle);
+
+ if (ServerHandle != NULL)
+ SamCloseHandle(ServerHandle);
+
+ return ApiStatus;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetGetDisplayInformationIndex(
+ _In_ LPCWSTR ServerName,
+ _In_ DWORD Level,
+ _In_ LPCWSTR Prefix,
+ _Out_ LPDWORD Index)
+{
+ UNICODE_STRING ServerNameString, PrefixString;
+ SAM_HANDLE ServerHandle = NULL;
+ SAM_HANDLE DomainHandle = NULL;
+ DOMAIN_DISPLAY_INFORMATION DisplayInformation;
+ NET_API_STATUS ApiStatus = NERR_Success;
+ NTSTATUS Status;
+
+ TRACE("NetGetDisplayInformationIndex(%s %ld %s %p)\n",
+ debugstr_w(ServerName), Level, debugstr_w(Prefix), Index);
+
+ switch (Level)
+ {
+ case 1:
+ DisplayInformation = DomainDisplayUser;
+ break;
+
+ case 2:
+ DisplayInformation = DomainDisplayMachine;
+ break;
+
+ case 3:
+ DisplayInformation = DomainDisplayGroup;
+ break;
+
+ default:
+ return ERROR_INVALID_LEVEL;
+ }
+
+ if (ServerName != NULL)
+ RtlInitUnicodeString(&ServerNameString, ServerName);
+
+ /* Connect to the SAM Server */
+ Status = SamConnect((ServerName != NULL) ? &ServerNameString : NULL,
+ &ServerHandle,
+ SAM_SERVER_CONNECT | SAM_SERVER_LOOKUP_DOMAIN,
+ NULL);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamConnect failed (Status %08lx)\n", Status);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ /* Open the Account Domain */
+ Status = OpenAccountDomain(ServerHandle,
+ (ServerName != NULL) ? &ServerNameString : NULL,
+ DOMAIN_LIST_ACCOUNTS,
+ &DomainHandle);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("OpenAccountDomain failed (Status %08lx)\n", Status);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ goto done;
+ }
+
+ RtlInitUnicodeString(&PrefixString, Prefix);
+
+ /* Get the index */
+ Status = SamGetDisplayEnumerationIndex(DomainHandle,
+ DisplayInformation,
+ &PrefixString,
+ Index);
+ if (!NT_SUCCESS(Status))
+ {
+ ERR("SamGetDisplayEnumerationIndex failed (Status %08lx)\n", Status);
+ ApiStatus = NetpNtStatusToApiStatus(Status);
+ }
+
+done:
+ if (DomainHandle != NULL)
+ SamCloseHandle(DomainHandle);
+
+ if (ServerHandle != NULL)
+ SamCloseHandle(ServerHandle);
+
+ return ApiStatus;
+}
+
+/* EOF */
Propchange: trunk/reactos/dll/win32/netapi32/display.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/dll/win32/netapi32/netapi32.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netapi32/netapi3…
==============================================================================
--- trunk/reactos/dll/win32/netapi32/netapi32.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netapi32/netapi32.spec [iso-8859-1] Tue Sep 26 07:32:49 2017
@@ -149,7 +149,7 @@
@ stdcall NetFileGetInfo(wstr long long ptr)
@ stdcall NetGetAnyDCName(wstr wstr ptr)
@ stdcall NetGetDCName(wstr wstr ptr)
-@ stub NetGetDisplayInformationIndex
+@ stdcall NetGetDisplayInformationIndex(wstr long wstr ptr)
@ stdcall NetGetJoinInformation(wstr ptr ptr)
@ stdcall NetGetJoinableOUs(wstr wstr wstr wstr ptr ptr)
@ stdcall NetGroupAdd(wstr long ptr ptr)