2 * COPYRIGHT: See COPYING in the top level directory
4 * FILE: reactos/dll/win32/netapi32/wksta_new.c
5 * PURPOSE: Workstation service interface code
7 * PROGRAMMERS: Eric Kohl
10 /* INCLUDES ******************************************************************/
15 WINE_DEFAULT_DEBUG_CHANNEL(netapi32
);
17 /* FUNCTIONS *****************************************************************/
19 void __RPC_FAR
* __RPC_USER
midl_user_allocate(SIZE_T len
)
21 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
25 void __RPC_USER
midl_user_free(void __RPC_FAR
* ptr
)
27 HeapFree(GetProcessHeap(), 0, ptr
);
32 WKSSVC_IDENTIFY_HANDLE_bind(WKSSVC_IDENTIFY_HANDLE pszSystemName
)
34 handle_t hBinding
= NULL
;
35 LPWSTR pszStringBinding
;
38 TRACE("WKSSVC_IDENTIFY_HANDLE_bind() called\n");
40 status
= RpcStringBindingComposeW(NULL
,
48 TRACE("RpcStringBindingCompose returned 0x%x\n", status
);
52 /* Set the binding handle that will be used to bind to the server. */
53 status
= RpcBindingFromStringBindingW(pszStringBinding
,
57 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status
);
60 status
= RpcStringFreeW(&pszStringBinding
);
63 // TRACE("RpcStringFree returned 0x%x\n", status);
71 WKSSVC_IDENTIFY_HANDLE_unbind(WKSSVC_IDENTIFY_HANDLE pszSystemName
,
76 TRACE("WKSSVC_IDENTIFY_HANDLE_unbind() called\n");
78 status
= RpcBindingFree(&hBinding
);
81 TRACE("RpcBindingFree returned 0x%x\n", status
);
87 WKSSVC_IMPERSONATE_HANDLE_bind(WKSSVC_IMPERSONATE_HANDLE pszSystemName
)
89 handle_t hBinding
= NULL
;
90 LPWSTR pszStringBinding
;
93 TRACE("WKSSVC_IMPERSONATE_HANDLE_bind() called\n");
95 status
= RpcStringBindingComposeW(NULL
,
103 TRACE("RpcStringBindingCompose returned 0x%x\n", status
);
107 /* Set the binding handle that will be used to bind to the server. */
108 status
= RpcBindingFromStringBindingW(pszStringBinding
,
112 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status
);
115 status
= RpcStringFreeW(&pszStringBinding
);
118 // TRACE("RpcStringFree returned 0x%x\n", status);
126 WKSSVC_IMPERSONATE_HANDLE_unbind(WKSSVC_IMPERSONATE_HANDLE pszSystemName
,
131 TRACE("WKSSVC_IMPERSONATE_HANDLE_unbind() called\n");
133 status
= RpcBindingFree(&hBinding
);
136 TRACE("RpcBindingFree returned 0x%x\n", status
);
143 NetAddAlternateComputerName(
144 _In_opt_ LPCWSTR Server
,
145 _In_ LPCWSTR AlternateName
,
146 _In_opt_ LPCWSTR DomainAccount
,
147 _In_opt_ LPCWSTR DomainAccountPassword
,
150 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
151 handle_t BindingHandle
;
152 NET_API_STATUS status
;
154 TRACE("NetAddAlternateComputerName(%s %s %s %s 0x%lx)\n",
155 debugstr_w(Server
), debugstr_w(AlternateName
), debugstr_w(DomainAccount
),
156 debugstr_w(DomainAccountPassword
), Reserved
);
159 BindingHandle
= NULL
;
160 EncryptedPassword
= NULL
;
164 status
= NetrAddAlternateComputerName(BindingHandle
,
166 (PWSTR
)AlternateName
,
167 (PWSTR
)DomainAccount
,
171 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
173 status
= I_RpcMapWin32Status(RpcExceptionCode());
184 NetGetJoinInformation(
187 PNETSETUP_JOIN_STATUS type
)
189 NET_API_STATUS status
;
191 TRACE("NetGetJoinInformation(%s %p %p)\n", debugstr_w(Server
),
194 if (Name
== NULL
|| type
== NULL
)
195 return ERROR_INVALID_PARAMETER
;
199 status
= NetrGetJoinInformation((LPWSTR
)Server
,
203 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
205 status
= I_RpcMapWin32Status(RpcExceptionCode());
217 _In_ LPCWSTR lpServer
,
218 _In_ LPCWSTR lpDomain
,
219 _In_ LPCWSTR lpAccountOU
,
220 _In_ LPCWSTR lpAccount
,
221 _In_ LPCWSTR lpPassword
,
222 _In_ DWORD fJoinOptions
)
224 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
225 handle_t BindingHandle
;
226 NET_API_STATUS status
;
228 TRACE("NetJoinDomain(%s %s %s %s 0x%lx)\n",
229 debugstr_w(lpServer
), debugstr_w(lpDomain
), debugstr_w(lpAccountOU
),
230 debugstr_w(lpAccount
), debugstr_w(lpPassword
), fJoinOptions
);
233 BindingHandle
= NULL
;
234 EncryptedPassword
= NULL
;
238 status
= NetrJoinDomain2(BindingHandle
,
246 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
248 status
= I_RpcMapWin32Status(RpcExceptionCode());
258 NetRemoveAlternateComputerName(
259 _In_opt_ LPCWSTR Server
,
260 _In_ LPCWSTR AlternateName
,
261 _In_opt_ LPCWSTR DomainAccount
,
262 _In_opt_ LPCWSTR DomainAccountPassword
,
265 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
266 handle_t BindingHandle
;
267 NET_API_STATUS status
;
269 TRACE("NetRemoveAlternateComputerName(%s %s %s %s 0x%lx)\n",
270 debugstr_w(Server
), debugstr_w(AlternateName
), debugstr_w(DomainAccount
),
271 debugstr_w(DomainAccountPassword
), Reserved
);
274 BindingHandle
= NULL
;
275 EncryptedPassword
= NULL
;
279 status
= NetrRemoveAlternateComputerName(BindingHandle
,
281 (PWSTR
)AlternateName
,
282 (PWSTR
)DomainAccount
,
286 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
288 status
= I_RpcMapWin32Status(RpcExceptionCode());
298 NetRenameMachineInDomain(
299 _In_ LPCWSTR lpServer
,
300 _In_ LPCWSTR lpNewMachineName
,
301 _In_ LPCWSTR lpAccount
,
302 _In_ LPCWSTR lpPassword
,
303 _In_ DWORD fRenameOptions
)
305 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
306 handle_t BindingHandle
;
307 NET_API_STATUS status
;
309 TRACE("NetRenameMachineInDomain(%s %s %s %s 0x%lx)\n",
310 debugstr_w(lpServer
), debugstr_w(lpNewMachineName
), debugstr_w(lpAccount
),
311 debugstr_w(lpPassword
), fRenameOptions
);
314 BindingHandle
= NULL
;
315 EncryptedPassword
= NULL
;
319 status
= NetrRenameMachineInDomain2(BindingHandle
,
321 (PWSTR
)lpNewMachineName
,
326 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
328 status
= I_RpcMapWin32Status(RpcExceptionCode());
338 NetSetPrimaryComputerName(
339 _In_opt_ LPCWSTR Server
,
340 _In_ LPCWSTR PrimaryName
,
341 _In_opt_ LPCWSTR DomainAccount
,
342 _In_opt_ LPCWSTR DomainAccountPassword
,
345 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
346 handle_t BindingHandle
;
347 NET_API_STATUS status
;
349 TRACE("NetSetPrimaryComputerName(%s %s %s %s %lu)\n",
350 debugstr_w(Server
), debugstr_w(PrimaryName
), debugstr_w(DomainAccount
),
351 debugstr_w(DomainAccountPassword
), Reserved
);
354 BindingHandle
= NULL
;
355 EncryptedPassword
= NULL
;
359 status
= NetrSetPrimaryComputerName(BindingHandle
,
362 (PWSTR
)DomainAccount
,
366 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
368 status
= I_RpcMapWin32Status(RpcExceptionCode());
379 _In_ LPCWSTR lpServer
,
380 _In_ LPCWSTR lpAccount
,
381 _In_ LPCWSTR lpPassword
,
382 _In_ DWORD fUnjoinOptions
)
384 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
385 handle_t BindingHandle
;
386 NET_API_STATUS status
;
388 TRACE("NetUnjoinDomain(%s %s %s %s 0x%lx)\n",
389 debugstr_w(lpServer
), debugstr_w(lpAccount
),
390 debugstr_w(lpPassword
), fUnjoinOptions
);
393 BindingHandle
= NULL
;
394 EncryptedPassword
= NULL
;
398 status
= NetrUnjoinDomain2(BindingHandle
,
404 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
406 status
= I_RpcMapWin32Status(RpcExceptionCode());
422 NET_API_STATUS status
;
424 TRACE("NetUseAdd(%s %d %p %p)\n", debugstr_w(UncServerName
),
425 Level
, Buf
, ParmError
);
429 status
= NetrUseAdd(UncServerName
,
434 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
436 status
= I_RpcMapWin32Status(RpcExceptionCode());
451 NET_API_STATUS status
;
453 TRACE("NetUseDel(%s %s %d)\n", debugstr_w(UncServerName
),
454 debugstr_w(UseName
), ForceCond
);
458 status
= NetrUseDel(UncServerName
,
462 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
464 status
= I_RpcMapWin32Status(RpcExceptionCode());
478 DWORD PreferedMaximumSize
,
480 LPDWORD TotalEntries
,
481 LPDWORD ResumeHandle
)
483 USE_ENUM_STRUCT UseEnumInfo
;
484 USE_INFO_0_CONTAINER Container0
;
485 USE_INFO_1_CONTAINER Container1
;
486 USE_INFO_2_CONTAINER Container2
;
487 NET_API_STATUS status
;
489 TRACE("NetUseEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(UncServerName
),
490 Level
, BufPtr
, PreferedMaximumSize
, EntriesRead
, TotalEntries
, ResumeHandle
);
492 UseEnumInfo
.Level
= Level
;
496 UseEnumInfo
.UseInfo
.Level0
= &Container0
;
497 Container0
.EntriesRead
= 0;
498 Container0
.Buffer
= NULL
;
502 UseEnumInfo
.UseInfo
.Level1
= &Container1
;
503 Container1
.EntriesRead
= 0;
504 Container1
.Buffer
= NULL
;
508 UseEnumInfo
.UseInfo
.Level2
= &Container2
;
509 Container2
.EntriesRead
= 0;
510 Container2
.Buffer
= NULL
;
514 return ERROR_INVALID_PARAMETER
;
519 status
= NetrUseEnum(UncServerName
,
524 if (status
== NERR_Success
|| status
== ERROR_MORE_DATA
)
529 *BufPtr
= (LPBYTE
)UseEnumInfo
.UseInfo
.Level0
->Buffer
;
530 *EntriesRead
= UseEnumInfo
.UseInfo
.Level0
->EntriesRead
;
534 *BufPtr
= (LPBYTE
)UseEnumInfo
.UseInfo
.Level1
->Buffer
;
535 *EntriesRead
= UseEnumInfo
.UseInfo
.Level1
->EntriesRead
;
539 *BufPtr
= (LPBYTE
)UseEnumInfo
.UseInfo
.Level2
->Buffer
;
540 *EntriesRead
= UseEnumInfo
.UseInfo
.Level2
->EntriesRead
;
545 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
547 status
= I_RpcMapWin32Status(RpcExceptionCode());
563 NET_API_STATUS status
;
565 TRACE("NetUseGetInfo(%s, %s, %d, %p)\n", debugstr_w(UncServerName
),
566 debugstr_w(UseName
), Level
, BufPtr
);
572 status
= NetrUseGetInfo(UncServerName
,
577 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
579 status
= I_RpcMapWin32Status(RpcExceptionCode());
595 NET_API_STATUS status
;
597 TRACE("NetWkstaGetInfo(%s, %d, %p)\n", debugstr_w(servername
),
601 return ERROR_INVALID_PARAMETER
;
607 status
= NetrWkstaGetInfo(servername
,
609 (LPWKSTA_INFO
)bufptr
);
611 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
613 status
= I_RpcMapWin32Status(RpcExceptionCode());
630 NET_API_STATUS status
;
632 TRACE("NetWkstaSetInfo(%s, %d, %p, %p)\n", debugstr_w(servername
),
633 level
, buffer
, parm_err
);
637 status
= NetrWkstaSetInfo(servername
,
639 (LPWKSTA_INFO
)buffer
,
642 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
644 status
= I_RpcMapWin32Status(RpcExceptionCode());
654 NetWkstaTransportAdd(
660 NET_API_STATUS status
;
662 TRACE("NetWkstaTransportAdd(%s, %d, %p, %p)\n", debugstr_w(servername
),
663 level
, buf
, parm_err
);
667 status
= NetrWkstaTransportAdd(servername
,
669 (LPWKSTA_TRANSPORT_INFO_0
)buf
,
672 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
674 status
= I_RpcMapWin32Status(RpcExceptionCode());
684 NetWkstaTransportDel(
686 LPWSTR transportname
,
689 NET_API_STATUS status
;
691 TRACE("NetWkstaTransportDel(%s, %s, %d)\n", debugstr_w(servername
),
692 debugstr_w(transportname
), ucond
);
696 status
= NetrWkstaTransportDel(servername
,
700 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
702 status
= I_RpcMapWin32Status(RpcExceptionCode());
713 NetWkstaTransportEnum(
719 LPDWORD totalentries
,
720 LPDWORD resumehandle
)
722 WKSTA_TRANSPORT_ENUM_STRUCT TransportEnumInfo
;
723 WKSTA_TRANSPORT_INFO_0_CONTAINER Container0
;
724 NET_API_STATUS status
;
726 TRACE("NetWkstaTransportEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername
),
727 level
, bufptr
, prefmaxlen
, entriesread
, totalentries
, resumehandle
);
729 TransportEnumInfo
.Level
= level
;
733 TransportEnumInfo
.WkstaTransportInfo
.Level0
= &Container0
;
734 Container0
.EntriesRead
= 0;
735 Container0
.Buffer
= NULL
;
739 return ERROR_INVALID_PARAMETER
;
744 status
= NetrWkstaTransportEnum(servername
,
749 if (status
== NERR_Success
|| status
== ERROR_MORE_DATA
)
754 *bufptr
= (LPBYTE
)TransportEnumInfo
.WkstaTransportInfo
.Level0
->Buffer
;
755 *entriesread
= TransportEnumInfo
.WkstaTransportInfo
.Level0
->EntriesRead
;
760 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
762 status
= I_RpcMapWin32Status(RpcExceptionCode());
778 LPDWORD totalentries
,
779 LPDWORD resumehandle
)
781 WKSTA_USER_ENUM_STRUCT UserEnumInfo
;
782 WKSTA_USER_INFO_0_CONTAINER Container0
;
783 WKSTA_USER_INFO_1_CONTAINER Container1
;
784 NET_API_STATUS status
;
786 TRACE("NetWkstaUserEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername
),
787 level
, bufptr
, prefmaxlen
, entriesread
, totalentries
, resumehandle
);
789 UserEnumInfo
.Level
= level
;
793 UserEnumInfo
.WkstaUserInfo
.Level0
= &Container0
;
794 Container0
.EntriesRead
= 0;
795 Container0
.Buffer
= NULL
;
799 UserEnumInfo
.WkstaUserInfo
.Level1
= &Container1
;
800 Container1
.EntriesRead
= 0;
801 Container1
.Buffer
= NULL
;
805 return ERROR_INVALID_PARAMETER
;
810 status
= NetrWkstaUserEnum(servername
,
815 if (status
== NERR_Success
|| status
== ERROR_MORE_DATA
)
820 *bufptr
= (LPBYTE
)UserEnumInfo
.WkstaUserInfo
.Level0
->Buffer
;
821 *entriesread
= UserEnumInfo
.WkstaUserInfo
.Level0
->EntriesRead
;
825 *bufptr
= (LPBYTE
)UserEnumInfo
.WkstaUserInfo
.Level1
->Buffer
;
826 *entriesread
= UserEnumInfo
.WkstaUserInfo
.Level1
->EntriesRead
;
831 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
833 status
= I_RpcMapWin32Status(RpcExceptionCode());
848 NET_API_STATUS status
;
850 TRACE("NetWkstaUserGetInfo(%s, %d, %p)\n", debugstr_w(reserved
),
853 if (reserved
!= NULL
)
854 return ERROR_INVALID_PARAMETER
;
860 status
= NetrWkstaUserGetInfo(NULL
,
862 (LPWKSTA_USER_INFO
)bufptr
);
864 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
866 status
= I_RpcMapWin32Status(RpcExceptionCode());
883 NET_API_STATUS status
;
885 TRACE("NetWkstaSetInfo(%s, %d, %p, %p)\n", debugstr_w(reserved
),
886 level
, buf
, parm_err
);
888 if (reserved
!= NULL
)
889 return ERROR_INVALID_PARAMETER
;
893 status
= NetrWkstaUserSetInfo(NULL
,
895 (LPWKSTA_USER_INFO
)&buf
,
898 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
900 status
= I_RpcMapWin32Status(RpcExceptionCode());