https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3fe3f9acc78e75547fa6b…
commit 3fe3f9acc78e75547fa6bdda8e7cf8a9bf64c1b5
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Sun Dec 8 10:52:37 2019 +0100
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Sun Dec 8 10:52:37 2019 +0100
[NETAPI32] Add RPC binding code to functions that require explicit binding
---
dll/win32/netapi32/wksta_new.c | 136 ++++++++++++++++++++++++++++++++++-------
1 file changed, 113 insertions(+), 23 deletions(-)
diff --git a/dll/win32/netapi32/wksta_new.c b/dll/win32/netapi32/wksta_new.c
index 8cb6157d949..f3516e9f5e5 100644
--- a/dll/win32/netapi32/wksta_new.c
+++ b/dll/win32/netapi32/wksta_new.c
@@ -138,6 +138,70 @@ WKSSVC_IMPERSONATE_HANDLE_unbind(WKSSVC_IMPERSONATE_HANDLE
pszSystemName,
}
+NET_API_STATUS
+NetpBind(
+ LPCWSTR pszServerName,
+ handle_t *pBindingHandle)
+{
+ handle_t hBinding = NULL;
+ LPWSTR pszStringBinding;
+ RPC_STATUS status;
+
+ FIXME("NetpBind(%S)\n", pszServerName);
+
+ *pBindingHandle = NULL;
+
+ status = RpcStringBindingComposeW(NULL,
+ L"ncacn_np",
+ (LPWSTR)pszServerName,
+ L"\\pipe\\wkssvc",
+ NULL,
+ &pszStringBinding);
+ if (status)
+ {
+ FIXME("RpcStringBindingCompose returned 0x%x\n", status);
+ return NetpNtStatusToApiStatus(status);
+ }
+
+ /* Set the binding handle that will be used to bind to the server. */
+ status = RpcBindingFromStringBindingW(pszStringBinding,
+ &hBinding);
+ if (status)
+ {
+ FIXME("RpcBindingFromStringBinding returned 0x%x\n", status);
+ }
+
+ status = RpcStringFreeW(&pszStringBinding);
+ if (status)
+ {
+ FIXME("RpcStringFree returned 0x%x\n", status);
+ }
+
+ *pBindingHandle = hBinding;
+
+ return NetpNtStatusToApiStatus(status);
+}
+
+
+NET_API_STATUS
+NetpUnbind(
+ handle_t BindingHandle)
+{
+ RPC_STATUS status;
+
+ FIXME("NetpUnbind(%p)\n", BindingHandle);
+
+ status = RpcBindingFree(&hBinding);
+ if (status)
+ {
+ TRACE("RpcBindingFree returned 0x%x\n", status);
+ return NetpNtStatusToApiStatus(status);
+ }
+
+ return NERR_Success;
+}
+
+
NET_API_STATUS
WINAPI
NetAddAlternateComputerName(
@@ -318,24 +382,30 @@ NetGetJoinableOUs(
NET_API_STATUS
WINAPI
NetJoinDomain(
- _In_ LPCWSTR lpServer,
+ _In_opt_ LPCWSTR lpServer,
_In_ LPCWSTR lpDomain,
- _In_ LPCWSTR lpAccountOU,
- _In_ LPCWSTR lpAccount,
- _In_ LPCWSTR lpPassword,
+ _In_opt_ LPCWSTR lpAccountOU,
+ _In_opt_ LPCWSTR lpAccount,
+ _In_opt_ LPCWSTR lpPassword,
_In_ DWORD fJoinOptions)
{
- PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
- handle_t BindingHandle;
+ PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
+ handle_t BindingHandle = NULL;
NET_API_STATUS status;
- TRACE("NetJoinDomain(%s %s %s %s 0x%lx)\n",
+ FIXME("NetJoinDomain(%s %s %s %s 0x%lx)\n",
debugstr_w(lpServer), debugstr_w(lpDomain), debugstr_w(lpAccountOU),
debugstr_w(lpAccount), debugstr_w(lpPassword), fJoinOptions);
/* FIXME */
- BindingHandle = NULL;
- EncryptedPassword = NULL;
+
+ status = NetpBind(lpServer,
+ &BindingHandle);
+ if (status != NERR_Success)
+ {
+ ERR("NetpBind() failed (status 0x%lx)\n", status);
+ return status;
+ }
RpcTryExcept
{
@@ -349,10 +419,14 @@ NetJoinDomain(
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
- status = I_RpcMapWin32Status(RpcExceptionCode());
+ RPC_STATUS rpcStatus = RpcExceptionCode();
+ FIXME("Exception 0x%lx\n", rpcStatus);
+ status = I_RpcMapWin32Status(rpcStatus);
}
RpcEndExcept;
+ NetpUnbind(BindingHandle);
+
return status;
}
@@ -481,12 +555,12 @@ NET_API_STATUS
WINAPI
NetUnjoinDomain(
_In_ LPCWSTR lpServer,
- _In_ LPCWSTR lpAccount,
- _In_ LPCWSTR lpPassword,
+ _In_opt_ LPCWSTR lpAccount,
+ _In_opt_ LPCWSTR lpPassword,
_In_ DWORD fUnjoinOptions)
{
- PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
- handle_t BindingHandle;
+ PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
+ handle_t BindingHandle = NULL;
NET_API_STATUS status;
TRACE("NetUnjoinDomain(%s %s %s %s 0x%lx)\n",
@@ -494,8 +568,14 @@ NetUnjoinDomain(
debugstr_w(lpPassword), fUnjoinOptions);
/* FIXME */
- BindingHandle = NULL;
- EncryptedPassword = NULL;
+
+ status = NetpBind(lpServer,
+ &BindingHandle);
+ if (status != NERR_Success)
+ {
+ ERR("NetpBind() failed (status 0x%lx)\n", status);
+ return status;
+ }
RpcTryExcept
{
@@ -511,6 +591,8 @@ NetUnjoinDomain(
}
RpcEndExcept;
+ NetpUnbind(BindingHandle);
+
return status;
}
@@ -691,14 +773,14 @@ NetUseGetInfo(
NET_API_STATUS
WINAPI
NetValidateName(
- _In_ LPCWSTR lpServer,
+ _In_opt_ LPCWSTR lpServer,
_In_ LPCWSTR lpName,
- _In_ LPCWSTR lpAccount,
- _In_ LPCWSTR lpPassword,
+ _In_opt_ LPCWSTR lpAccount,
+ _In_opt_ LPCWSTR lpPassword,
_In_ NETSETUP_NAME_TYPE NameType)
{
- PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
- handle_t BindingHandle;
+ PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
+ handle_t BindingHandle = NULL;
NET_API_STATUS status;
TRACE("NetValidateName(%s %s %s %s %u)\n",
@@ -706,8 +788,14 @@ NetValidateName(
debugstr_w(lpPassword), NameType);
/* FIXME */
- BindingHandle = NULL;
- EncryptedPassword = NULL;
+
+ status = NetpBind(lpServer,
+ &BindingHandle);
+ if (status != NERR_Success)
+ {
+ ERR("NetpBind() failed (status 0x%lx)\n", status);
+ return status;
+ }
RpcTryExcept
{
@@ -724,6 +812,8 @@ NetValidateName(
}
RpcEndExcept;
+ NetpUnbind(BindingHandle);
+
return status;
}