https://git.reactos.org/?p=reactos.git;a=commitdiff;h=989ee70d9d56a88ef2540…
commit 989ee70d9d56a88ef2540f083689302e3ec7051c
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun Dec 8 19:18:16 2019 +0100
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun Dec 8 19:19:27 2019 +0100
[WKSSVC] Implement parts of NetrJoinDomain2 to join a work group
NOTE: We can not connect to a work group yet!
---
base/services/wkssvc/CMakeLists.txt | 1 +
base/services/wkssvc/domain.c | 69 +++++++++++++++++++++++++++++++++++++
base/services/wkssvc/precomp.h | 16 +++++++++
base/services/wkssvc/rpcserver.c | 22 ++++++++++--
sdk/include/reactos/idl/wkssvc.idl | 2 ++
5 files changed, 108 insertions(+), 2 deletions(-)
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 <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(
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
{