[NETAPI32]
authorEric Kohl <eric.kohl@reactos.org>
Wed, 14 Jun 2017 09:50:54 +0000 (09:50 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Wed, 14 Jun 2017 09:50:54 +0000 (09:50 +0000)
Implement NetAddAlternateComputerName, NetJoinDomain, NetRemoveAlternateComputerName, NetRenameMachineInDomain, NetSetPrimaryComputerName and NetUnjoinDomain. These functions call their counterparts in the workstation service.

svn path=/trunk/; revision=75032

reactos/dll/win32/netapi32/netapi32.spec
reactos/dll/win32/netapi32/wksta_new.c

index 751163e..e491d02 100644 (file)
@@ -99,7 +99,7 @@
 @ stub I_NetlogonComputeClientDigest
 @ stub I_NetlogonComputeServerDigest
 @ stub I_NetlogonGetTrustRid
 @ stub I_NetlogonComputeClientDigest
 @ stub I_NetlogonComputeServerDigest
 @ stub I_NetlogonGetTrustRid
-@ stub NetAddAlternateComputerName
+@ stdcall NetAddAlternateComputerName(wstr wstr wstr wstr long)
 @ stdcall NetAlertRaise(wstr ptr long)
 @ stdcall NetAlertRaiseEx(wstr ptr long wstr)
 @ stdcall NetApiBufferAllocate(long ptr)
 @ stdcall NetAlertRaise(wstr ptr long)
 @ stdcall NetAlertRaiseEx(wstr ptr long wstr)
 @ stdcall NetApiBufferAllocate(long ptr)
 @ stdcall NetGroupGetUsers(wstr wstr long ptr long ptr ptr ptr)
 @ stdcall NetGroupSetInfo(wstr wstr long ptr ptr)
 @ stdcall NetGroupSetUsers(wstr wstr long ptr long)
 @ stdcall NetGroupGetUsers(wstr wstr long ptr long ptr ptr ptr)
 @ stdcall NetGroupSetInfo(wstr wstr long ptr ptr)
 @ stdcall NetGroupSetUsers(wstr wstr long ptr long)
-@ stub NetJoinDomain
+@ stdcall NetJoinDomain(wstr wstr wstr wstr wstr long)
 @ stdcall NetLocalGroupAdd(wstr long ptr ptr)
 @ stdcall NetLocalGroupAddMember(wstr wstr ptr)
 @ stdcall NetLocalGroupAddMembers(wstr wstr long ptr long)
 @ stdcall NetLocalGroupAdd(wstr long ptr ptr)
 @ stdcall NetLocalGroupAddMember(wstr wstr ptr)
 @ stdcall NetLocalGroupAddMembers(wstr wstr long ptr long)
 @ stub NetRegisterDomainNameChangeNotification
 @ stub NetRemoteComputerSupports
 @ stdcall NetRemoteTOD(wstr ptr)
 @ stub NetRegisterDomainNameChangeNotification
 @ stub NetRemoteComputerSupports
 @ stdcall NetRemoteTOD(wstr ptr)
-@ stub NetRemoveAlternateComputerName
-@ stub NetRenameMachineInDomain
+@ stdcall NetRemoveAlternateComputerName(wstr wstr wstr wstr long)
+@ stdcall NetRenameMachineInDomain(wstr wstr wstr wstr long)
 @ stub NetReplExportDirAdd
 @ stub NetReplExportDirDel
 @ stub NetReplExportDirEnum
 @ stub NetReplExportDirAdd
 @ stub NetReplExportDirDel
 @ stub NetReplExportDirEnum
 @ stdcall NetSessionDel(wstr wstr wstr)
 @ stdcall NetSessionEnum(wstr wstr wstr long ptr long ptr ptr ptr)
 @ stdcall NetSessionGetInfo(wstr wstr wstr long ptr)
 @ stdcall NetSessionDel(wstr wstr wstr)
 @ stdcall NetSessionEnum(wstr wstr wstr long ptr long ptr ptr ptr)
 @ stdcall NetSessionGetInfo(wstr wstr wstr long ptr)
-@ stub NetSetPrimaryComputerName
+@ stdcall NetSetPrimaryComputerName(wstr wstr wstr wstr long)
 @ stdcall NetShareAdd(wstr long ptr ptr)
 @ stdcall NetShareCheck(wstr wstr ptr)
 @ stdcall NetShareDel(wstr wstr long)
 @ stdcall NetShareAdd(wstr long ptr ptr)
 @ stdcall NetShareCheck(wstr wstr ptr)
 @ stdcall NetShareDel(wstr wstr long)
 @ stdcall NetShareGetInfo(wstr wstr long ptr)
 @ stdcall NetShareSetInfo(wstr wstr long ptr ptr)
 @ stdcall NetStatisticsGet(wstr wstr long long ptr)
 @ stdcall NetShareGetInfo(wstr wstr long ptr)
 @ stdcall NetShareSetInfo(wstr wstr long ptr ptr)
 @ stdcall NetStatisticsGet(wstr wstr long long ptr)
-@ stub NetUnjoinDomain
+@ stdcall NetUnjoinDomain(wstr wstr wstr long)
 @ stub NetUnregisterDomainNameChangeNotification
 @ stdcall NetUseAdd(wstr long ptr ptr)
 @ stdcall NetUseDel(wstr wstr long)
 @ stub NetUnregisterDomainNameChangeNotification
 @ stdcall NetUseAdd(wstr long ptr ptr)
 @ stdcall NetUseDel(wstr wstr long)
index 3878dbe..951a385 100644 (file)
@@ -138,9 +138,49 @@ WKSSVC_IMPERSONATE_HANDLE_unbind(WKSSVC_IMPERSONATE_HANDLE pszSystemName,
 }
 
 
 }
 
 
+NET_API_STATUS
+WINAPI
+NetAddAlternateComputerName(
+    _In_opt_ LPCWSTR Server,
+    _In_ LPCWSTR AlternateName,
+    _In_opt_ LPCWSTR DomainAccount,
+    _In_opt_ LPCWSTR DomainAccountPassword,
+    _In_ ULONG Reserved)
+{
+    PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
+    handle_t BindingHandle;
+    NET_API_STATUS status;
+
+    TRACE("NetAddAlternateComputerName(%s %s %s %s 0x%lx)\n",
+          debugstr_w(Server), debugstr_w(AlternateName), debugstr_w(DomainAccount),
+          debugstr_w(DomainAccountPassword), Reserved);
+
+    /* FIXME */
+    BindingHandle = NULL;
+    EncryptedPassword = NULL;
+
+    RpcTryExcept
+    {
+        status = NetrAddAlternateComputerName(BindingHandle,
+                                              (PWSTR)Server,
+                                              (PWSTR)AlternateName,
+                                              (PWSTR)DomainAccount,
+                                              EncryptedPassword,
+                                              Reserved);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
 #if 0
 NET_API_STATUS
 #if 0
 NET_API_STATUS
-NET_API_FUNCTION
+WINAPI
 NetGetJoinInformation(
     LPCWSTR Server,
     LPWSTR *Name,
 NetGetJoinInformation(
     LPCWSTR Server,
     LPWSTR *Name,
@@ -171,6 +211,206 @@ NetGetJoinInformation(
 #endif
 
 
 #endif
 
 
+NET_API_STATUS
+WINAPI
+NetJoinDomain(
+    _In_ LPCWSTR lpServer,
+    _In_ LPCWSTR lpDomain,
+    _In_ LPCWSTR lpAccountOU,
+    _In_ LPCWSTR lpAccount,
+    _In_ LPCWSTR lpPassword,
+    _In_ DWORD fJoinOptions)
+{
+    PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
+    handle_t BindingHandle;
+    NET_API_STATUS status;
+
+    TRACE("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;
+
+    RpcTryExcept
+    {
+        status = NetrJoinDomain2(BindingHandle,
+                                 (PWSTR)lpServer,
+                                 (PWSTR)lpDomain,
+                                 (PWSTR)lpAccountOU,
+                                 (PWSTR)lpAccount,
+                                 EncryptedPassword,
+                                 fJoinOptions);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetRemoveAlternateComputerName(
+    _In_opt_ LPCWSTR Server,
+    _In_ LPCWSTR AlternateName,
+    _In_opt_ LPCWSTR DomainAccount,
+    _In_opt_ LPCWSTR DomainAccountPassword,
+    _In_ ULONG Reserved)
+{
+    PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
+    handle_t BindingHandle;
+    NET_API_STATUS status;
+
+    TRACE("NetRemoveAlternateComputerName(%s %s %s %s 0x%lx)\n",
+          debugstr_w(Server), debugstr_w(AlternateName), debugstr_w(DomainAccount),
+          debugstr_w(DomainAccountPassword), Reserved);
+
+    /* FIXME */
+    BindingHandle = NULL;
+    EncryptedPassword = NULL;
+
+    RpcTryExcept
+    {
+        status = NetrRemoveAlternateComputerName(BindingHandle,
+                                                 (PWSTR)Server,
+                                                 (PWSTR)AlternateName,
+                                                 (PWSTR)DomainAccount,
+                                                 EncryptedPassword,
+                                                 Reserved);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetRenameMachineInDomain(
+    _In_ LPCWSTR lpServer,
+    _In_ LPCWSTR lpNewMachineName,
+    _In_ LPCWSTR lpAccount,
+    _In_ LPCWSTR lpPassword,
+    _In_ DWORD fRenameOptions)
+{
+    PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
+    handle_t BindingHandle;
+    NET_API_STATUS status;
+
+    TRACE("NetRenameMachineInDomain(%s %s %s %s 0x%lx)\n",
+          debugstr_w(lpServer), debugstr_w(lpNewMachineName), debugstr_w(lpAccount),
+          debugstr_w(lpPassword), fRenameOptions);
+
+    /* FIXME */
+    BindingHandle = NULL;
+    EncryptedPassword = NULL;
+
+    RpcTryExcept
+    {
+        status = NetrRenameMachineInDomain2(BindingHandle,
+                                            (PWSTR)lpServer,
+                                            (PWSTR)lpNewMachineName,
+                                            (PWSTR)lpAccount,
+                                            EncryptedPassword,
+                                            fRenameOptions);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetSetPrimaryComputerName(
+    _In_opt_ LPCWSTR Server,
+    _In_ LPCWSTR PrimaryName,
+    _In_opt_ LPCWSTR DomainAccount,
+    _In_opt_ LPCWSTR DomainAccountPassword,
+    _In_ ULONG Reserved)
+{
+    PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
+    handle_t BindingHandle;
+    NET_API_STATUS status;
+
+    TRACE("NetSetPrimaryComputerName(%s %s %s %s %lu)\n",
+          debugstr_w(Server), debugstr_w(PrimaryName), debugstr_w(DomainAccount),
+          debugstr_w(DomainAccountPassword), Reserved);
+
+    /* FIXME */
+    BindingHandle = NULL;
+    EncryptedPassword = NULL;
+
+    RpcTryExcept
+    {
+        status = NetrSetPrimaryComputerName(BindingHandle,
+                                            (PWSTR)Server,
+                                            (PWSTR)PrimaryName,
+                                            (PWSTR)DomainAccount,
+                                            EncryptedPassword,
+                                            Reserved);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetUnjoinDomain(
+    _In_ LPCWSTR lpServer,
+    _In_ LPCWSTR lpAccount,
+    _In_ LPCWSTR lpPassword,
+    _In_ DWORD fUnjoinOptions)
+{
+    PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
+    handle_t BindingHandle;
+    NET_API_STATUS status;
+
+    TRACE("NetUnjoinDomain(%s %s %s %s 0x%lx)\n",
+          debugstr_w(lpServer), debugstr_w(lpAccount),
+          debugstr_w(lpPassword), fUnjoinOptions);
+
+    /* FIXME */
+    BindingHandle = NULL;
+    EncryptedPassword = NULL;
+
+    RpcTryExcept
+    {
+        status = NetrUnjoinDomain2(BindingHandle,
+                                   (PWSTR)lpServer,
+                                   (PWSTR)lpAccount,
+                                   EncryptedPassword,
+                                   fUnjoinOptions);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
 NET_API_STATUS
 WINAPI
 NetUseAdd(
 NET_API_STATUS
 WINAPI
 NetUseAdd(