[NETAPI32]
[reactos.git] / reactos / dll / win32 / netapi32 / wksta_new.c
index 7ca7cdd..0841ef6 100644 (file)
@@ -139,7 +139,48 @@ WKSSVC_IMPERSONATE_HANDLE_unbind(WKSSVC_IMPERSONATE_HANDLE pszSystemName,
 
 
 NET_API_STATUS
 
 
 NET_API_STATUS
-NET_API_FUNCTION
+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
+WINAPI
 NetGetJoinInformation(
     LPCWSTR Server,
     LPWSTR *Name,
 NetGetJoinInformation(
     LPCWSTR Server,
     LPWSTR *Name,
@@ -147,7 +188,7 @@ NetGetJoinInformation(
 {
     NET_API_STATUS status;
 
 {
     NET_API_STATUS status;
 
-    TRACE("NetGetJoinInformation(%s %p %p)\n", wine_dbgstr_w(Server),
+    TRACE("NetGetJoinInformation(%s %p %p)\n", debugstr_w(Server),
           Name, type);
 
     if (Name == NULL || type == NULL)
           Name, type);
 
     if (Name == NULL || type == NULL)
@@ -167,8 +208,465 @@ NetGetJoinInformation(
 
     return status;
 }
 
     return status;
 }
+#endif
+
+
+NET_API_STATUS
+WINAPI
+NetGetJoinableOUs(
+    _In_ LPCWSTR lpServer,
+    _In_ LPCWSTR lpDomain,
+    _In_ LPCWSTR lpAccount,
+    _In_ LPCWSTR lpPassword,
+    _Out_ DWORD *OUCount,
+    _Out_ LPWSTR **OUs)
+{
+    PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
+    handle_t BindingHandle;
+    NET_API_STATUS status;
+
+    TRACE("NetGetJoinableOUs(%s %s %s %s %p %p)\n",
+          debugstr_w(lpServer), debugstr_w(lpDomain), debugstr_w(lpAccount),
+          debugstr_w(lpPassword), OUCount, OUs);
+
+    /* FIXME */
+    BindingHandle = NULL;
+    EncryptedPassword = NULL;
+
+    RpcTryExcept
+    {
+        status = NetrGetJoinableOUs2(BindingHandle,
+                                     (PWSTR)lpServer,
+                                     (PWSTR)lpDomain,
+                                     (PWSTR)lpAccount,
+                                     EncryptedPassword,
+                                     OUCount,
+                                     OUs);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+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(
+    LMSTR UncServerName,
+    DWORD Level,
+    LPBYTE Buf,
+    LPDWORD ParmError)
+{
+    NET_API_STATUS status;
+
+    TRACE("NetUseAdd(%s %d %p %p)\n", debugstr_w(UncServerName),
+          Level, Buf, ParmError);
+
+    RpcTryExcept
+    {
+        status = NetrUseAdd(UncServerName,
+                            Level,
+                            (LPUSE_INFO)Buf,
+                            ParmError);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetUseDel(
+    LMSTR UncServerName,
+    LMSTR UseName,
+    DWORD ForceCond)
+{
+    NET_API_STATUS status;
+
+    TRACE("NetUseDel(%s %s %d)\n", debugstr_w(UncServerName),
+          debugstr_w(UseName), ForceCond);
+
+    RpcTryExcept
+    {
+        status = NetrUseDel(UncServerName,
+                            UseName,
+                            ForceCond);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
 
 
 
 
+NET_API_STATUS
+WINAPI
+NetUseEnum(
+    LMSTR UncServerName,
+    DWORD Level,
+    LPBYTE *BufPtr,
+    DWORD PreferedMaximumSize,
+    LPDWORD EntriesRead,
+    LPDWORD TotalEntries,
+    LPDWORD ResumeHandle)
+{
+    USE_ENUM_STRUCT UseEnumInfo;
+    USE_INFO_0_CONTAINER Container0;
+    USE_INFO_1_CONTAINER Container1;
+    USE_INFO_2_CONTAINER Container2;
+    NET_API_STATUS status;
+
+    TRACE("NetUseEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(UncServerName),
+          Level, BufPtr, PreferedMaximumSize, EntriesRead, TotalEntries, ResumeHandle);
+
+    UseEnumInfo.Level = Level;
+    switch (Level)
+    {
+        case 0:
+            UseEnumInfo.UseInfo.Level0 = &Container0;
+            Container0.EntriesRead = 0;
+            Container0.Buffer = NULL;
+            break;
+
+        case 1:
+            UseEnumInfo.UseInfo.Level1 = &Container1;
+            Container1.EntriesRead = 0;
+            Container1.Buffer = NULL;
+            break;
+
+        case 2:
+            UseEnumInfo.UseInfo.Level2 = &Container2;
+            Container2.EntriesRead = 0;
+            Container2.Buffer = NULL;
+            break;
+
+        default:
+            return ERROR_INVALID_PARAMETER;
+    }
+
+    RpcTryExcept
+    {
+        status = NetrUseEnum(UncServerName,
+                             &UseEnumInfo,
+                             PreferedMaximumSize,
+                             TotalEntries,
+                             ResumeHandle);
+        if (status == NERR_Success || status == ERROR_MORE_DATA)
+        {
+            switch (Level)
+            {
+                case 0:
+                    *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level0->Buffer;
+                    *EntriesRead = UseEnumInfo.UseInfo.Level0->EntriesRead;
+                    break;
+
+                case 1:
+                    *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level1->Buffer;
+                    *EntriesRead = UseEnumInfo.UseInfo.Level1->EntriesRead;
+                    break;
+
+                case 2:
+                    *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level2->Buffer;
+                    *EntriesRead = UseEnumInfo.UseInfo.Level2->EntriesRead;
+                    break;
+            }
+        }
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetValidateName(
+    _In_ LPCWSTR lpServer,
+    _In_ LPCWSTR lpName,
+    _In_ LPCWSTR lpAccount,
+    _In_ LPCWSTR lpPassword,
+    _In_ NETSETUP_NAME_TYPE NameType)
+{
+    PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
+    handle_t BindingHandle;
+    NET_API_STATUS status;
+
+    TRACE("NetValidateName(%s %s %s %s %u)\n",
+          debugstr_w(lpServer), debugstr_w(lpName), debugstr_w(lpAccount),
+          debugstr_w(lpPassword), NameType);
+
+    /* FIXME */
+    BindingHandle = NULL;
+    EncryptedPassword = NULL;
+
+    RpcTryExcept
+    {
+        status = NetrValidateName2(BindingHandle,
+                                   (PWSTR)lpServer,
+                                   (PWSTR)lpName,
+                                   (PWSTR)lpAccount,
+                                   EncryptedPassword,
+                                   NameType);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetUseGetInfo(
+    LMSTR UncServerName,
+    LMSTR UseName,
+    DWORD Level,
+    LPBYTE *BufPtr)
+{
+    NET_API_STATUS status;
+
+    TRACE("NetUseGetInfo(%s, %s, %d, %p)\n", debugstr_w(UncServerName),
+          debugstr_w(UseName), Level, BufPtr);
+
+    *BufPtr = NULL;
+
+    RpcTryExcept
+    {
+        status = NetrUseGetInfo(UncServerName,
+                                UseName,
+                                Level,
+                                (LPUSE_INFO)BufPtr);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+#if 0
 NET_API_STATUS
 WINAPI
 NetWkstaGetInfo(
 NET_API_STATUS
 WINAPI
 NetWkstaGetInfo(
@@ -181,6 +679,9 @@ NetWkstaGetInfo(
     TRACE("NetWkstaGetInfo(%s, %d, %p)\n", debugstr_w(servername),
           level, bufptr);
 
     TRACE("NetWkstaGetInfo(%s, %d, %p)\n", debugstr_w(servername),
           level, bufptr);
 
+    if (bufptr == NULL)
+        return ERROR_INVALID_PARAMETER;
+
     *bufptr = NULL;
 
     RpcTryExcept
     *bufptr = NULL;
 
     RpcTryExcept
@@ -197,6 +698,7 @@ NetWkstaGetInfo(
 
     return status;
 }
 
     return status;
 }
+#endif
 
 
 NET_API_STATUS
 
 
 NET_API_STATUS
@@ -229,10 +731,128 @@ NetWkstaSetInfo(
 }
 
 
 }
 
 
+NET_API_STATUS
+WINAPI
+NetWkstaTransportAdd(
+    LPWSTR servername,
+    DWORD level,
+    LPBYTE buf,
+    LPDWORD parm_err)
+{
+    NET_API_STATUS status;
+
+    TRACE("NetWkstaTransportAdd(%s, %d, %p, %p)\n", debugstr_w(servername),
+          level, buf, parm_err);
+
+    RpcTryExcept
+    {
+        status = NetrWkstaTransportAdd(servername,
+                                       level,
+                                       (LPWKSTA_TRANSPORT_INFO_0)buf,
+                                       parm_err);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+NET_API_STATUS
+WINAPI
+NetWkstaTransportDel(
+    LPWSTR servername,
+    LPWSTR transportname,
+    DWORD ucond)
+{
+    NET_API_STATUS status;
+
+    TRACE("NetWkstaTransportDel(%s, %s, %d)\n", debugstr_w(servername),
+          debugstr_w(transportname), ucond);
+
+    RpcTryExcept
+    {
+        status = NetrWkstaTransportDel(servername,
+                                       transportname,
+                                       ucond);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
+#if 0
+NET_API_STATUS
+WINAPI
+NetWkstaTransportEnum(
+    LPWSTR servername,
+    DWORD level,
+    LPBYTE *bufptr,
+    DWORD prefmaxlen,
+    LPDWORD entriesread,
+    LPDWORD totalentries,
+    LPDWORD resumehandle)
+{
+    WKSTA_TRANSPORT_ENUM_STRUCT TransportEnumInfo;
+    WKSTA_TRANSPORT_INFO_0_CONTAINER Container0;
+    NET_API_STATUS status;
+
+    TRACE("NetWkstaTransportEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername),
+          level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle);
+
+    TransportEnumInfo.Level = level;
+    switch (level)
+    {
+        case 0:
+            TransportEnumInfo.WkstaTransportInfo.Level0 = &Container0;
+            Container0.EntriesRead = 0;
+            Container0.Buffer = NULL;
+            break;
+
+        default:
+            return ERROR_INVALID_PARAMETER;
+    }
+
+    RpcTryExcept
+    {
+        status = NetrWkstaTransportEnum(servername,
+                                        &TransportEnumInfo,
+                                        prefmaxlen,
+                                        totalentries,
+                                        resumehandle);
+        if (status == NERR_Success || status == ERROR_MORE_DATA)
+        {
+            switch (level)
+            {
+                case 0:
+                    *bufptr = (LPBYTE)TransportEnumInfo.WkstaTransportInfo.Level0->Buffer;
+                    *entriesread = TransportEnumInfo.WkstaTransportInfo.Level0->EntriesRead;
+                    break;
+            }
+        }
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        status = I_RpcMapWin32Status(RpcExceptionCode());
+    }
+    RpcEndExcept;
+
+    return status;
+}
+
+
 NET_API_STATUS
 WINAPI
 NetWkstaUserEnum(
 NET_API_STATUS
 WINAPI
 NetWkstaUserEnum(
-    LMSTR servername,
+    LPWSTR servername,
     DWORD level,
     LPBYTE *bufptr,
     DWORD prefmaxlen,
     DWORD level,
     LPBYTE *bufptr,
     DWORD prefmaxlen,
@@ -241,8 +861,8 @@ NetWkstaUserEnum(
     LPDWORD resumehandle)
 {
     WKSTA_USER_ENUM_STRUCT UserEnumInfo;
     LPDWORD resumehandle)
 {
     WKSTA_USER_ENUM_STRUCT UserEnumInfo;
-    WKSTA_USER_INFO_0_CONTAINER Level0;
-    WKSTA_USER_INFO_1_CONTAINER Level1;
+    WKSTA_USER_INFO_0_CONTAINER Container0;
+    WKSTA_USER_INFO_1_CONTAINER Container1;
     NET_API_STATUS status;
 
     TRACE("NetWkstaUserEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername),
     NET_API_STATUS status;
 
     TRACE("NetWkstaUserEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername),
@@ -252,15 +872,15 @@ NetWkstaUserEnum(
     switch (level)
     {
         case 0:
     switch (level)
     {
         case 0:
-            UserEnumInfo.WkstaUserInfo.Level0 = &Level0;
-            UserEnumInfo.WkstaUserInfo.Level0->EntriesRead = 0;
-            UserEnumInfo.WkstaUserInfo.Level0->Buffer = NULL;
+            UserEnumInfo.WkstaUserInfo.Level0 = &Container0;
+            Container0.EntriesRead = 0;
+            Container0.Buffer = NULL;
             break;
 
         case 1:
             break;
 
         case 1:
-            UserEnumInfo.WkstaUserInfo.Level1 = &Level1;
-            UserEnumInfo.WkstaUserInfo.Level1->EntriesRead = 0;
-            UserEnumInfo.WkstaUserInfo.Level1->Buffer = NULL;
+            UserEnumInfo.WkstaUserInfo.Level1 = &Container1;
+            Container1.EntriesRead = 0;
+            Container1.Buffer = NULL;
             break;
 
         default:
             break;
 
         default:
@@ -331,6 +951,7 @@ NetWkstaUserGetInfo(
 
     return status;
 }
 
     return status;
 }
+#endif
 
 
 NET_API_STATUS
 
 
 NET_API_STATUS