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 NetGetJoinInformation(
146 PNETSETUP_JOIN_STATUS type
)
148 NET_API_STATUS status
;
150 TRACE("NetGetJoinInformation(%s %p %p)\n", debugstr_w(Server
),
153 if (Name
== NULL
|| type
== NULL
)
154 return ERROR_INVALID_PARAMETER
;
158 status
= NetrGetJoinInformation((LPWSTR
)Server
,
162 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
164 status
= I_RpcMapWin32Status(RpcExceptionCode());
180 NET_API_STATUS status
;
182 TRACE("NetUseAdd(%s %d %p %p)\n", debugstr_w(UncServerName
),
183 Level
, Buf
, ParmError
);
187 status
= NetrUseAdd(UncServerName
,
192 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
194 status
= I_RpcMapWin32Status(RpcExceptionCode());
209 NET_API_STATUS status
;
211 TRACE("NetUseDel(%s %s %d)\n", debugstr_w(UncServerName
),
212 debugstr_w(UseName
), ForceCond
);
216 status
= NetrUseDel(UncServerName
,
220 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
222 status
= I_RpcMapWin32Status(RpcExceptionCode());
236 DWORD PreferedMaximumSize
,
238 LPDWORD TotalEntries
,
239 LPDWORD ResumeHandle
)
241 USE_ENUM_STRUCT UseEnumInfo
;
242 USE_INFO_0_CONTAINER Container0
;
243 USE_INFO_1_CONTAINER Container1
;
244 USE_INFO_2_CONTAINER Container2
;
245 NET_API_STATUS status
;
247 TRACE("NetUseEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(UncServerName
),
248 Level
, BufPtr
, PreferedMaximumSize
, EntriesRead
, TotalEntries
, ResumeHandle
);
250 UseEnumInfo
.Level
= Level
;
254 UseEnumInfo
.UseInfo
.Level0
= &Container0
;
255 Container0
.EntriesRead
= 0;
256 Container0
.Buffer
= NULL
;
260 UseEnumInfo
.UseInfo
.Level1
= &Container1
;
261 Container1
.EntriesRead
= 0;
262 Container1
.Buffer
= NULL
;
266 UseEnumInfo
.UseInfo
.Level2
= &Container2
;
267 Container2
.EntriesRead
= 0;
268 Container2
.Buffer
= NULL
;
272 return ERROR_INVALID_PARAMETER
;
277 status
= NetrUseEnum(UncServerName
,
282 if (status
== NERR_Success
|| status
== ERROR_MORE_DATA
)
287 *BufPtr
= (LPBYTE
)UseEnumInfo
.UseInfo
.Level0
->Buffer
;
288 *EntriesRead
= UseEnumInfo
.UseInfo
.Level0
->EntriesRead
;
292 *BufPtr
= (LPBYTE
)UseEnumInfo
.UseInfo
.Level1
->Buffer
;
293 *EntriesRead
= UseEnumInfo
.UseInfo
.Level1
->EntriesRead
;
297 *BufPtr
= (LPBYTE
)UseEnumInfo
.UseInfo
.Level2
->Buffer
;
298 *EntriesRead
= UseEnumInfo
.UseInfo
.Level2
->EntriesRead
;
303 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
305 status
= I_RpcMapWin32Status(RpcExceptionCode());
321 NET_API_STATUS status
;
323 TRACE("NetUseGetInfo(%s, %s, %d, %p)\n", debugstr_w(UncServerName
),
324 debugstr_w(UseName
), Level
, BufPtr
);
330 status
= NetrUseGetInfo(UncServerName
,
335 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
337 status
= I_RpcMapWin32Status(RpcExceptionCode());
352 NET_API_STATUS status
;
354 TRACE("NetWkstaGetInfo(%s, %d, %p)\n", debugstr_w(servername
),
361 status
= NetrWkstaGetInfo(servername
,
363 (LPWKSTA_INFO
)bufptr
);
365 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
367 status
= I_RpcMapWin32Status(RpcExceptionCode());
383 NET_API_STATUS status
;
385 TRACE("NetWkstaSetInfo(%s, %d, %p, %p)\n", debugstr_w(servername
),
386 level
, buffer
, parm_err
);
390 status
= NetrWkstaSetInfo(servername
,
392 (LPWKSTA_INFO
)buffer
,
395 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
397 status
= I_RpcMapWin32Status(RpcExceptionCode());
413 LPDWORD totalentries
,
414 LPDWORD resumehandle
)
416 WKSTA_USER_ENUM_STRUCT UserEnumInfo
;
417 WKSTA_USER_INFO_0_CONTAINER Container0
;
418 WKSTA_USER_INFO_1_CONTAINER Container1
;
419 NET_API_STATUS status
;
421 TRACE("NetWkstaUserEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername
),
422 level
, bufptr
, prefmaxlen
, entriesread
, totalentries
, resumehandle
);
424 UserEnumInfo
.Level
= level
;
428 UserEnumInfo
.WkstaUserInfo
.Level0
= &Container0
;
429 Container0
.EntriesRead
= 0;
430 Container0
.Buffer
= NULL
;
434 UserEnumInfo
.WkstaUserInfo
.Level1
= &Container1
;
435 Container1
.EntriesRead
= 0;
436 Container1
.Buffer
= NULL
;
440 return ERROR_INVALID_PARAMETER
;
445 status
= NetrWkstaUserEnum(servername
,
450 if (status
== NERR_Success
|| status
== ERROR_MORE_DATA
)
455 *bufptr
= (LPBYTE
)UserEnumInfo
.WkstaUserInfo
.Level0
->Buffer
;
456 *entriesread
= UserEnumInfo
.WkstaUserInfo
.Level0
->EntriesRead
;
460 *bufptr
= (LPBYTE
)UserEnumInfo
.WkstaUserInfo
.Level1
->Buffer
;
461 *entriesread
= UserEnumInfo
.WkstaUserInfo
.Level1
->EntriesRead
;
466 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
468 status
= I_RpcMapWin32Status(RpcExceptionCode());
483 NET_API_STATUS status
;
485 TRACE("NetWkstaUserGetInfo(%s, %d, %p)\n", debugstr_w(reserved
),
488 if (reserved
!= NULL
)
489 return ERROR_INVALID_PARAMETER
;
495 status
= NetrWkstaUserGetInfo(NULL
,
497 (LPWKSTA_USER_INFO
)bufptr
);
499 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
501 status
= I_RpcMapWin32Status(RpcExceptionCode());
517 NET_API_STATUS status
;
519 TRACE("NetWkstaSetInfo(%s, %d, %p, %p)\n", debugstr_w(reserved
),
520 level
, buf
, parm_err
);
522 if (reserved
!= NULL
)
523 return ERROR_INVALID_PARAMETER
;
527 status
= NetrWkstaUserSetInfo(NULL
,
529 (LPWKSTA_USER_INFO
)&buf
,
532 RpcExcept(EXCEPTION_EXECUTE_HANDLER
)
534 status
= I_RpcMapWin32Status(RpcExceptionCode());