[NETAPI32]

Implement the Directory Service Setup (dssetup) client interface.

svn path=/trunk/; revision=66523
This commit is contained in:
Eric Kohl 2015-03-01 15:41:11 +00:00
parent bbe66391dc
commit dc2aa925db
3 changed files with 133 additions and 111 deletions

View file

@ -5,13 +5,16 @@ include_directories(
add_definitions(-D__WINESRC__)
spec2def(netapi32.dll netapi32.spec ADD_IMPORTLIB)
add_rpc_files(client ${REACTOS_SOURCE_DIR}/include/reactos/idl/wkssvc.idl)
add_rpc_files(client
${REACTOS_SOURCE_DIR}/include/reactos/idl/dssetup.idl
${REACTOS_SOURCE_DIR}/include/reactos/idl/wkssvc.idl)
list(APPEND SOURCE
access.c
apibuf.c
browsr.c
ds.c
dssetup.c
group.c
local_group.c
misc.c
@ -25,6 +28,7 @@ list(APPEND SOURCE
wksta.c
wksta_new.c
netapi32.h
${CMAKE_CURRENT_BINARY_DIR}/dssetup_c.c
${CMAKE_CURRENT_BINARY_DIR}/wkssvc_c.c)
add_library(netapi32 SHARED

View file

@ -65,113 +65,3 @@ VOID WINAPI DsRoleFreeMemory(PVOID Buffer)
TRACE("(%p)\n", Buffer);
HeapFree(GetProcessHeap(), 0, Buffer);
}
/************************************************************
* DsRoleGetPrimaryDomainInformation (NETAPI32.@)
*
* PARAMS
* lpServer [I] Pointer to UNICODE string with ComputerName
* InfoLevel [I] Type of data to retrieve
* Buffer [O] Pointer to to the requested data
*
* RETURNS
*
* NOTES
* When lpServer is NULL, use the local computer
*/
DWORD WINAPI DsRoleGetPrimaryDomainInformation(
LPCWSTR lpServer, DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel,
PBYTE* Buffer)
{
DWORD ret;
FIXME("(%p, %d, %p) stub\n", lpServer, InfoLevel, Buffer);
/* Check some input parameters */
if (!Buffer) return ERROR_INVALID_PARAMETER;
if ((InfoLevel < DsRolePrimaryDomainInfoBasic) || (InfoLevel > DsRoleOperationState)) return ERROR_INVALID_PARAMETER;
*Buffer = NULL;
switch (InfoLevel)
{
case DsRolePrimaryDomainInfoBasic:
{
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
LSA_HANDLE PolicyHandle;
PPOLICY_ACCOUNT_DOMAIN_INFO DomainInfo;
NTSTATUS NtStatus;
int logon_domain_sz;
DWORD size;
PDSROLE_PRIMARY_DOMAIN_INFO_BASIC basic;
ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes));
NtStatus = LsaOpenPolicy(NULL, &ObjectAttributes,
POLICY_VIEW_LOCAL_INFORMATION, &PolicyHandle);
if (NtStatus != STATUS_SUCCESS)
{
TRACE("LsaOpenPolicyFailed with NT status %x\n",
LsaNtStatusToWinError(NtStatus));
return ERROR_OUTOFMEMORY;
}
LsaQueryInformationPolicy(PolicyHandle,
PolicyAccountDomainInformation, (PVOID*)&DomainInfo);
logon_domain_sz = lstrlenW(DomainInfo->DomainName.Buffer) + 1;
LsaClose(PolicyHandle);
size = sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC) +
logon_domain_sz * sizeof(WCHAR);
basic = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (basic)
{
basic->MachineRole = DsRole_RoleStandaloneWorkstation;
basic->DomainNameFlat = (LPWSTR)((LPBYTE)basic +
sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC));
lstrcpyW(basic->DomainNameFlat, DomainInfo->DomainName.Buffer);
ret = ERROR_SUCCESS;
}
else
ret = ERROR_OUTOFMEMORY;
*Buffer = (PBYTE)basic;
LsaFreeMemory(DomainInfo);
}
break;
case DsRoleUpgradeStatus:
{
PDSROLE_UPGRADE_STATUS_INFO buffer;
buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DSROLE_UPGRADE_STATUS_INFO));
if (buffer)
{
buffer->OperationState = 0;
buffer->PreviousServerState = 0;
ret = ERROR_SUCCESS;
}
else
ret = ERROR_OUTOFMEMORY;
*Buffer = (PBYTE)buffer;
}
break;
case DsRoleOperationState:
{
PDSROLE_OPERATION_STATE_INFO buffer;
buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DSROLE_OPERATION_STATE_INFO));
if (buffer)
{
buffer->OperationState = DsRoleOperationIdle;
ret = ERROR_SUCCESS;
}
else
ret = ERROR_OUTOFMEMORY;
*Buffer = (PBYTE)buffer;
}
break;
default:
ret = ERROR_CALL_NOT_IMPLEMENTED;
}
return ret;
}

View file

@ -0,0 +1,128 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: NetAPI DLL
* FILE: reactos/dll/win32/netapi32/dssetup.c
* PURPOSE: Directory Service Setup interface code
* PROGRAMMERS: Eric Kohl
*/
/* INCLUDES ******************************************************************/
#include "netapi32.h"
#include <rpc.h>
#include "dssetup_c.h"
WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
/* FUNCTIONS *****************************************************************/
static
RPC_STATUS
DsSetupBind(
LPWSTR lpServerName,
handle_t *hBinding)
{
LPWSTR pszStringBinding;
RPC_STATUS status;
TRACE("DsSetupBind() called\n");
*hBinding = NULL;
status = RpcStringBindingComposeW(NULL,
L"ncacn_np",
lpServerName,
L"\\pipe\\lsarpc",
NULL,
&pszStringBinding);
if (status)
{
TRACE("RpcStringBindingCompose returned 0x%x\n", status);
return status;
}
/* Set the binding handle that will be used to bind to the server. */
status = RpcBindingFromStringBindingW(pszStringBinding,
hBinding);
if (status)
{
TRACE("RpcBindingFromStringBinding returned 0x%x\n", status);
}
status = RpcStringFreeW(&pszStringBinding);
if (status)
{
TRACE("RpcStringFree returned 0x%x\n", status);
}
return status;
}
static
void
DsSetupUnbind(
handle_t hBinding)
{
RPC_STATUS status;
TRACE("DsSetupUnbind()\n");
status = RpcBindingFree(&hBinding);
if (status)
{
TRACE("RpcBindingFree returned 0x%x\n", status);
}
}
DWORD
WINAPI
DsRoleGetPrimaryDomainInformation(
LPCWSTR lpServer,
DSROLE_PRIMARY_DOMAIN_INFO_LEVEL InfoLevel,
PBYTE* Buffer)
{
handle_t hBinding = NULL;
NET_API_STATUS status;
TRACE("DsRoleGetPrimaryDomainInformation(%p, %d, %p)\n",
lpServer, InfoLevel, Buffer);
/* Check some input parameters */
if (!Buffer)
return ERROR_INVALID_PARAMETER;
if ((InfoLevel < DsRolePrimaryDomainInfoBasic) || (InfoLevel > DsRoleOperationState))
return ERROR_INVALID_PARAMETER;
*Buffer = NULL;
status = DsSetupBind((LPWSTR)lpServer, &hBinding);
if (status)
{
TRACE("DsSetupBind() failed (Status %lu\n)", status);
return status;
}
RpcTryExcept
{
status = DsRolerGetPrimaryDomainInformation(hBinding,
InfoLevel,
(PDSROLER_PRIMARY_DOMAIN_INFORMATION *)Buffer);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
status = I_RpcMapWin32Status(RpcExceptionCode());
}
RpcEndExcept;
if (hBinding != NULL)
DsSetupUnbind(hBinding);
return status;
}
/* EOF */