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 lpAccount
,
220 _In_ LPCWSTR lpPassword
,
221 _Out_ DWORD
*OUCount
,
224 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
225 handle_t BindingHandle
;
226 NET_API_STATUS status
;
228 TRACE("NetGetJoinableOUs(%s %s %s %s %p %p)\n",
229 debugstr_w(lpServer
), debugstr_w(lpDomain
), debugstr_w(lpAccount
),
230 debugstr_w(lpPassword
), OUCount
, OUs
);
233 BindingHandle
= NULL
;
234 EncryptedPassword
= NULL
;
238 status
= NetrGetJoinableOUs2(BindingHandle
,
246 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
248 status
= I_RpcMapWin32Status(RpcExceptionCode());
259 _In_ LPCWSTR lpServer
,
260 _In_ LPCWSTR lpDomain
,
261 _In_ LPCWSTR lpAccountOU
,
262 _In_ LPCWSTR lpAccount
,
263 _In_ LPCWSTR lpPassword
,
264 _In_ DWORD fJoinOptions
)
266 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
267 handle_t BindingHandle
;
268 NET_API_STATUS status
;
270 TRACE("NetJoinDomain(%s %s %s %s 0x%lx)\n",
271 debugstr_w(lpServer
), debugstr_w(lpDomain
), debugstr_w(lpAccountOU
),
272 debugstr_w(lpAccount
), debugstr_w(lpPassword
), fJoinOptions
);
275 BindingHandle
= NULL
;
276 EncryptedPassword
= NULL
;
280 status
= NetrJoinDomain2(BindingHandle
,
288 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
290 status
= I_RpcMapWin32Status(RpcExceptionCode());
300 NetRemoveAlternateComputerName(
301 _In_opt_ LPCWSTR Server
,
302 _In_ LPCWSTR AlternateName
,
303 _In_opt_ LPCWSTR DomainAccount
,
304 _In_opt_ LPCWSTR DomainAccountPassword
,
307 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
308 handle_t BindingHandle
;
309 NET_API_STATUS status
;
311 TRACE("NetRemoveAlternateComputerName(%s %s %s %s 0x%lx)\n",
312 debugstr_w(Server
), debugstr_w(AlternateName
), debugstr_w(DomainAccount
),
313 debugstr_w(DomainAccountPassword
), Reserved
);
316 BindingHandle
= NULL
;
317 EncryptedPassword
= NULL
;
321 status
= NetrRemoveAlternateComputerName(BindingHandle
,
323 (PWSTR
)AlternateName
,
324 (PWSTR
)DomainAccount
,
328 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
330 status
= I_RpcMapWin32Status(RpcExceptionCode());
340 NetRenameMachineInDomain(
341 _In_ LPCWSTR lpServer
,
342 _In_ LPCWSTR lpNewMachineName
,
343 _In_ LPCWSTR lpAccount
,
344 _In_ LPCWSTR lpPassword
,
345 _In_ DWORD fRenameOptions
)
347 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
348 handle_t BindingHandle
;
349 NET_API_STATUS status
;
351 TRACE("NetRenameMachineInDomain(%s %s %s %s 0x%lx)\n",
352 debugstr_w(lpServer
), debugstr_w(lpNewMachineName
), debugstr_w(lpAccount
),
353 debugstr_w(lpPassword
), fRenameOptions
);
356 BindingHandle
= NULL
;
357 EncryptedPassword
= NULL
;
361 status
= NetrRenameMachineInDomain2(BindingHandle
,
363 (PWSTR
)lpNewMachineName
,
368 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
370 status
= I_RpcMapWin32Status(RpcExceptionCode());
380 NetSetPrimaryComputerName(
381 _In_opt_ LPCWSTR Server
,
382 _In_ LPCWSTR PrimaryName
,
383 _In_opt_ LPCWSTR DomainAccount
,
384 _In_opt_ LPCWSTR DomainAccountPassword
,
387 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
388 handle_t BindingHandle
;
389 NET_API_STATUS status
;
391 TRACE("NetSetPrimaryComputerName(%s %s %s %s %lu)\n",
392 debugstr_w(Server
), debugstr_w(PrimaryName
), debugstr_w(DomainAccount
),
393 debugstr_w(DomainAccountPassword
), Reserved
);
396 BindingHandle
= NULL
;
397 EncryptedPassword
= NULL
;
401 status
= NetrSetPrimaryComputerName(BindingHandle
,
404 (PWSTR
)DomainAccount
,
408 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
410 status
= I_RpcMapWin32Status(RpcExceptionCode());
421 _In_ LPCWSTR lpServer
,
422 _In_ LPCWSTR lpAccount
,
423 _In_ LPCWSTR lpPassword
,
424 _In_ DWORD fUnjoinOptions
)
426 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
427 handle_t BindingHandle
;
428 NET_API_STATUS status
;
430 TRACE("NetUnjoinDomain(%s %s %s %s 0x%lx)\n",
431 debugstr_w(lpServer
), debugstr_w(lpAccount
),
432 debugstr_w(lpPassword
), fUnjoinOptions
);
435 BindingHandle
= NULL
;
436 EncryptedPassword
= NULL
;
440 status
= NetrUnjoinDomain2(BindingHandle
,
446 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
448 status
= I_RpcMapWin32Status(RpcExceptionCode());
464 NET_API_STATUS status
;
466 TRACE("NetUseAdd(%s %d %p %p)\n", debugstr_w(UncServerName
),
467 Level
, Buf
, ParmError
);
471 status
= NetrUseAdd(UncServerName
,
476 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
478 status
= I_RpcMapWin32Status(RpcExceptionCode());
493 NET_API_STATUS status
;
495 TRACE("NetUseDel(%s %s %d)\n", debugstr_w(UncServerName
),
496 debugstr_w(UseName
), ForceCond
);
500 status
= NetrUseDel(UncServerName
,
504 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
506 status
= I_RpcMapWin32Status(RpcExceptionCode());
520 DWORD PreferedMaximumSize
,
522 LPDWORD TotalEntries
,
523 LPDWORD ResumeHandle
)
525 USE_ENUM_STRUCT UseEnumInfo
;
526 USE_INFO_0_CONTAINER Container0
;
527 USE_INFO_1_CONTAINER Container1
;
528 USE_INFO_2_CONTAINER Container2
;
529 NET_API_STATUS status
;
531 TRACE("NetUseEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(UncServerName
),
532 Level
, BufPtr
, PreferedMaximumSize
, EntriesRead
, TotalEntries
, ResumeHandle
);
534 UseEnumInfo
.Level
= Level
;
538 UseEnumInfo
.UseInfo
.Level0
= &Container0
;
539 Container0
.EntriesRead
= 0;
540 Container0
.Buffer
= NULL
;
544 UseEnumInfo
.UseInfo
.Level1
= &Container1
;
545 Container1
.EntriesRead
= 0;
546 Container1
.Buffer
= NULL
;
550 UseEnumInfo
.UseInfo
.Level2
= &Container2
;
551 Container2
.EntriesRead
= 0;
552 Container2
.Buffer
= NULL
;
556 return ERROR_INVALID_PARAMETER
;
561 status
= NetrUseEnum(UncServerName
,
566 if (status
== NERR_Success
|| status
== ERROR_MORE_DATA
)
571 *BufPtr
= (LPBYTE
)UseEnumInfo
.UseInfo
.Level0
->Buffer
;
572 *EntriesRead
= UseEnumInfo
.UseInfo
.Level0
->EntriesRead
;
576 *BufPtr
= (LPBYTE
)UseEnumInfo
.UseInfo
.Level1
->Buffer
;
577 *EntriesRead
= UseEnumInfo
.UseInfo
.Level1
->EntriesRead
;
581 *BufPtr
= (LPBYTE
)UseEnumInfo
.UseInfo
.Level2
->Buffer
;
582 *EntriesRead
= UseEnumInfo
.UseInfo
.Level2
->EntriesRead
;
587 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
589 status
= I_RpcMapWin32Status(RpcExceptionCode());
600 _In_ LPCWSTR lpServer
,
602 _In_ LPCWSTR lpAccount
,
603 _In_ LPCWSTR lpPassword
,
604 _In_ NETSETUP_NAME_TYPE NameType
)
606 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword
;
607 handle_t BindingHandle
;
608 NET_API_STATUS status
;
610 TRACE("NetValidateName(%s %s %s %s %u)\n",
611 debugstr_w(lpServer
), debugstr_w(lpName
), debugstr_w(lpAccount
),
612 debugstr_w(lpPassword
), NameType
);
615 BindingHandle
= NULL
;
616 EncryptedPassword
= NULL
;
620 status
= NetrValidateName2(BindingHandle
,
627 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
629 status
= I_RpcMapWin32Status(RpcExceptionCode());
645 NET_API_STATUS status
;
647 TRACE("NetUseGetInfo(%s, %s, %d, %p)\n", debugstr_w(UncServerName
),
648 debugstr_w(UseName
), Level
, BufPtr
);
654 status
= NetrUseGetInfo(UncServerName
,
659 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
661 status
= I_RpcMapWin32Status(RpcExceptionCode());
677 NET_API_STATUS status
;
679 TRACE("NetWkstaGetInfo(%s, %d, %p)\n", debugstr_w(servername
),
683 return ERROR_INVALID_PARAMETER
;
689 status
= NetrWkstaGetInfo(servername
,
691 (LPWKSTA_INFO
)bufptr
);
693 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
695 status
= I_RpcMapWin32Status(RpcExceptionCode());
712 NET_API_STATUS status
;
714 TRACE("NetWkstaSetInfo(%s, %d, %p, %p)\n", debugstr_w(servername
),
715 level
, buffer
, parm_err
);
719 status
= NetrWkstaSetInfo(servername
,
721 (LPWKSTA_INFO
)buffer
,
724 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
726 status
= I_RpcMapWin32Status(RpcExceptionCode());
736 NetWkstaTransportAdd(
742 NET_API_STATUS status
;
744 TRACE("NetWkstaTransportAdd(%s, %d, %p, %p)\n", debugstr_w(servername
),
745 level
, buf
, parm_err
);
749 status
= NetrWkstaTransportAdd(servername
,
751 (LPWKSTA_TRANSPORT_INFO_0
)buf
,
754 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
756 status
= I_RpcMapWin32Status(RpcExceptionCode());
766 NetWkstaTransportDel(
768 LPWSTR transportname
,
771 NET_API_STATUS status
;
773 TRACE("NetWkstaTransportDel(%s, %s, %d)\n", debugstr_w(servername
),
774 debugstr_w(transportname
), ucond
);
778 status
= NetrWkstaTransportDel(servername
,
782 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
784 status
= I_RpcMapWin32Status(RpcExceptionCode());
795 NetWkstaTransportEnum(
801 LPDWORD totalentries
,
802 LPDWORD resumehandle
)
804 WKSTA_TRANSPORT_ENUM_STRUCT TransportEnumInfo
;
805 WKSTA_TRANSPORT_INFO_0_CONTAINER Container0
;
806 NET_API_STATUS status
;
808 TRACE("NetWkstaTransportEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername
),
809 level
, bufptr
, prefmaxlen
, entriesread
, totalentries
, resumehandle
);
811 TransportEnumInfo
.Level
= level
;
815 TransportEnumInfo
.WkstaTransportInfo
.Level0
= &Container0
;
816 Container0
.EntriesRead
= 0;
817 Container0
.Buffer
= NULL
;
821 return ERROR_INVALID_PARAMETER
;
826 status
= NetrWkstaTransportEnum(servername
,
831 if (status
== NERR_Success
|| status
== ERROR_MORE_DATA
)
836 *bufptr
= (LPBYTE
)TransportEnumInfo
.WkstaTransportInfo
.Level0
->Buffer
;
837 *entriesread
= TransportEnumInfo
.WkstaTransportInfo
.Level0
->EntriesRead
;
842 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
844 status
= I_RpcMapWin32Status(RpcExceptionCode());
860 LPDWORD totalentries
,
861 LPDWORD resumehandle
)
863 WKSTA_USER_ENUM_STRUCT UserEnumInfo
;
864 WKSTA_USER_INFO_0_CONTAINER Container0
;
865 WKSTA_USER_INFO_1_CONTAINER Container1
;
866 NET_API_STATUS status
;
868 TRACE("NetWkstaUserEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername
),
869 level
, bufptr
, prefmaxlen
, entriesread
, totalentries
, resumehandle
);
871 UserEnumInfo
.Level
= level
;
875 UserEnumInfo
.WkstaUserInfo
.Level0
= &Container0
;
876 Container0
.EntriesRead
= 0;
877 Container0
.Buffer
= NULL
;
881 UserEnumInfo
.WkstaUserInfo
.Level1
= &Container1
;
882 Container1
.EntriesRead
= 0;
883 Container1
.Buffer
= NULL
;
887 return ERROR_INVALID_PARAMETER
;
892 status
= NetrWkstaUserEnum(servername
,
897 if (status
== NERR_Success
|| status
== ERROR_MORE_DATA
)
902 *bufptr
= (LPBYTE
)UserEnumInfo
.WkstaUserInfo
.Level0
->Buffer
;
903 *entriesread
= UserEnumInfo
.WkstaUserInfo
.Level0
->EntriesRead
;
907 *bufptr
= (LPBYTE
)UserEnumInfo
.WkstaUserInfo
.Level1
->Buffer
;
908 *entriesread
= UserEnumInfo
.WkstaUserInfo
.Level1
->EntriesRead
;
913 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
915 status
= I_RpcMapWin32Status(RpcExceptionCode());
930 NET_API_STATUS status
;
932 TRACE("NetWkstaUserGetInfo(%s, %d, %p)\n", debugstr_w(reserved
),
935 if (reserved
!= NULL
)
936 return ERROR_INVALID_PARAMETER
;
942 status
= NetrWkstaUserGetInfo(NULL
,
944 (LPWKSTA_USER_INFO
)bufptr
);
946 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
948 status
= I_RpcMapWin32Status(RpcExceptionCode());
965 NET_API_STATUS status
;
967 TRACE("NetWkstaSetInfo(%s, %d, %p, %p)\n", debugstr_w(reserved
),
968 level
, buf
, parm_err
);
970 if (reserved
!= NULL
)
971 return ERROR_INVALID_PARAMETER
;
975 status
= NetrWkstaUserSetInfo(NULL
,
977 (LPWKSTA_USER_INFO
)&buf
,
980 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
982 status
= I_RpcMapWin32Status(RpcExceptionCode());