[WKSSVC] Implement parts of NetrJoinDomain2 to join a work group

NOTE: We can not connect to a work group yet!
This commit is contained in:
Eric Kohl 2019-12-08 19:18:16 +01:00
parent e85f436a50
commit 989ee70d9d
5 changed files with 108 additions and 2 deletions

View file

@ -4,6 +4,7 @@ add_rpc_files(server ${REACTOS_SOURCE_DIR}/sdk/include/reactos/idl/wkssvc.idl)
spec2def(wkssvc.dll wkssvc.spec ADD_IMPORTLIB)
add_library(wkssvc MODULE
domain.c
rpcserver.c
wkssvc.c
wkssvc.rc

View file

@ -0,0 +1,69 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Services
* FILE: base/services/wkssvc/domain.c
* PURPOSE: Workstation service
* PROGRAMMER: Eric Kohl
*/
/* INCLUDES *****************************************************************/
#include "precomp.h"
WINE_DEFAULT_DEBUG_CHANNEL(wkssvc);
/* FUNCTIONS *****************************************************************/
static
NET_API_STATUS
NetpSetPrimaryDomain(
_In_ LPCWSTR lpWorkgroupName)
{
LSA_OBJECT_ATTRIBUTES ObjectAttributes;
POLICY_PRIMARY_DOMAIN_INFO PrimaryDomainInfo;
LSA_HANDLE PolicyHandle = NULL;
NTSTATUS Status;
ZeroMemory(&ObjectAttributes, sizeof(LSA_OBJECT_ATTRIBUTES));
ObjectAttributes.Length = sizeof(LSA_OBJECT_ATTRIBUTES);
Status = LsaOpenPolicy(NULL,
&ObjectAttributes,
POLICY_TRUST_ADMIN,
&PolicyHandle);
if (!LSA_SUCCESS(Status))
return LsaNtStatusToWinError(Status);
RtlInitUnicodeString(&PrimaryDomainInfo.Name,
lpWorkgroupName);
PrimaryDomainInfo.Sid = NULL;
Status = LsaSetInformationPolicy(PolicyHandle,
PolicyPrimaryDomainInformation,
&PrimaryDomainInfo);
LsaClose(PolicyHandle);
return LsaNtStatusToWinError(Status);
}
NET_API_STATUS
NetpJoinWorkgroup(
_In_ LPCWSTR lpWorkgroupName)
{
NET_API_STATUS status;
FIXME("NetpJoinWorkgroup(%S)\n", lpWorkgroupName);
status = NetpSetPrimaryDomain(lpWorkgroupName);
if (status != NERR_Success)
{
ERR("NetpSetPrimaryDomain failed (Status %lu)\n", status);
return status;
}
return NERR_Success;
}
/* EOF */

View file

@ -7,14 +7,30 @@
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winerror.h>
#include <winreg.h>
#include <winsvc.h>
#include <lmcons.h>
#include <lmerr.h>
#include <lmjoin.h>
#include <lmserver.h>
#include <ntsecapi.h>
//#include <ntstatus.h>
#include <ndk/rtlfuncs.h>
#include <wkssvc_s.h>
#include <wine/debug.h>
/* domain.c */
NET_API_STATUS
NetpJoinWorkgroup(
_In_ LPCWSTR WorkgroupName);
/* rpcserver.c */
DWORD
WINAPI
RpcThreadRoutine(

View file

@ -395,8 +395,26 @@ NetrJoinDomain2(
PJOINPR_ENCRYPTED_USER_PASSWORD Password,
unsigned long Options)
{
UNIMPLEMENTED;
return 0;
NET_API_STATUS status;
FIXME("NetrJoinDomain2(%p %S %S %S %S %p 0x%lx)\n",
RpcBindingHandle, ServerName, DomainNameParam, MachineAccountOU,
AccountName, Password, Options);
if (DomainNameParam == NULL)
return ERROR_INVALID_PARAMETER;
if (Options & NETSETUP_JOIN_DOMAIN)
{
FIXME("NetrJoinDomain2: NETSETUP_JOIN_DOMAIN is not supported yet!\n");
status = ERROR_CALL_NOT_IMPLEMENTED;
}
else
{
status = NetpJoinWorkgroup(DomainNameParam);
}
return status;
}

View file

@ -7,6 +7,7 @@
typedef [handle] wchar_t *WKSSVC_IDENTIFY_HANDLE;
typedef [handle] wchar_t *WKSSVC_IMPERSONATE_HANDLE;
cpp_quote("#ifndef _LMJOIN_H")
typedef enum _NETSETUP_JOIN_STATUS
{
NetSetupUnknownStatus = 0,
@ -14,6 +15,7 @@ typedef enum _NETSETUP_JOIN_STATUS
NetSetupWorkgroupName,
NetSetupDomainName
} NETSETUP_JOIN_STATUS, *PNETSETUP_JOIN_STATUS;
cpp_quote("#endif")
typedef enum _NETSETUP_NAME_TYPE
{