diff --git a/base/services/wkssvc/CMakeLists.txt b/base/services/wkssvc/CMakeLists.txt index d7404cdcb50..c7bb4c8b41a 100644 --- a/base/services/wkssvc/CMakeLists.txt +++ b/base/services/wkssvc/CMakeLists.txt @@ -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 diff --git a/base/services/wkssvc/domain.c b/base/services/wkssvc/domain.c new file mode 100644 index 00000000000..4d39c978fce --- /dev/null +++ b/base/services/wkssvc/domain.c @@ -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 */ diff --git a/base/services/wkssvc/precomp.h b/base/services/wkssvc/precomp.h index 6e66ec76797..c6f841e1eb4 100644 --- a/base/services/wkssvc/precomp.h +++ b/base/services/wkssvc/precomp.h @@ -7,14 +7,30 @@ #include #include #include +#include #include #include +#include +#include +#include #include +#include +//#include +#include #include #include +/* domain.c */ + +NET_API_STATUS +NetpJoinWorkgroup( + _In_ LPCWSTR WorkgroupName); + + +/* rpcserver.c */ + DWORD WINAPI RpcThreadRoutine( diff --git a/base/services/wkssvc/rpcserver.c b/base/services/wkssvc/rpcserver.c index 27b70e57e3d..47f96f8921a 100644 --- a/base/services/wkssvc/rpcserver.c +++ b/base/services/wkssvc/rpcserver.c @@ -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; } diff --git a/sdk/include/reactos/idl/wkssvc.idl b/sdk/include/reactos/idl/wkssvc.idl index af541e463f0..a456795d7dc 100644 --- a/sdk/include/reactos/idl/wkssvc.idl +++ b/sdk/include/reactos/idl/wkssvc.idl @@ -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 {