Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209/* * 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@reactos.org) */
/* INCLUDES ******************************************************************/
#include "netapi32.h"
WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
/* FUNCTIONS *****************************************************************/
/* PUBLIC FUNCTIONS **********************************************************/
NET_API_STATUSWINAPINetQueryDisplayInformation( _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_STATUSWINAPINetGetDisplayInformationIndex( _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 */