1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: NetAPI DLL
4 * FILE: reactos/dll/win32/netapi32/wksta_new.c
5 * PURPOSE: Workstation service interface code
6 *
7 * PROGRAMMERS: Eric Kohl
8 */
9
10 /* INCLUDES ******************************************************************/
11
12 #include "netapi32.h"
13 #include "wkssvc_c.h"
14
15 WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
16
17 /* FUNCTIONS *****************************************************************/
18
midl_user_allocate(SIZE_T len)19 void __RPC_FAR * __RPC_USER midl_user_allocate(SIZE_T len)
20 {
21 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
22 }
23
24
midl_user_free(void __RPC_FAR * ptr)25 void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
26 {
27 HeapFree(GetProcessHeap(), 0, ptr);
28 }
29
30
31 handle_t __RPC_USER
WKSSVC_IDENTIFY_HANDLE_bind(WKSSVC_IDENTIFY_HANDLE pszSystemName)32 WKSSVC_IDENTIFY_HANDLE_bind(WKSSVC_IDENTIFY_HANDLE pszSystemName)
33 {
34 handle_t hBinding = NULL;
35 LPWSTR pszStringBinding;
36 RPC_STATUS status;
37
38 TRACE("WKSSVC_IDENTIFY_HANDLE_bind() called\n");
39
40 status = RpcStringBindingComposeW(NULL,
41 L"ncacn_np",
42 pszSystemName,
43 L"\\pipe\\wkssvc",
44 NULL,
45 &pszStringBinding);
46 if (status)
47 {
48 TRACE("RpcStringBindingCompose returned 0x%x\n", status);
49 return NULL;
50 }
51
52 /* Set the binding handle that will be used to bind to the server. */
53 status = RpcBindingFromStringBindingW(pszStringBinding,
54 &hBinding);
55 if (status)
56 {
57 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status);
58 }
59
60 status = RpcStringFreeW(&pszStringBinding);
61 if (status)
62 {
63 // TRACE("RpcStringFree returned 0x%x\n", status);
64 }
65
66 return hBinding;
67 }
68
69
70 void __RPC_USER
WKSSVC_IDENTIFY_HANDLE_unbind(WKSSVC_IDENTIFY_HANDLE pszSystemName,handle_t hBinding)71 WKSSVC_IDENTIFY_HANDLE_unbind(WKSSVC_IDENTIFY_HANDLE pszSystemName,
72 handle_t hBinding)
73 {
74 RPC_STATUS status;
75
76 TRACE("WKSSVC_IDENTIFY_HANDLE_unbind() called\n");
77
78 status = RpcBindingFree(&hBinding);
79 if (status)
80 {
81 TRACE("RpcBindingFree returned 0x%x\n", status);
82 }
83 }
84
85
86 handle_t __RPC_USER
WKSSVC_IMPERSONATE_HANDLE_bind(WKSSVC_IMPERSONATE_HANDLE pszSystemName)87 WKSSVC_IMPERSONATE_HANDLE_bind(WKSSVC_IMPERSONATE_HANDLE pszSystemName)
88 {
89 handle_t hBinding = NULL;
90 LPWSTR pszStringBinding;
91 RPC_STATUS status;
92
93 TRACE("WKSSVC_IMPERSONATE_HANDLE_bind() called\n");
94
95 status = RpcStringBindingComposeW(NULL,
96 L"ncacn_np",
97 pszSystemName,
98 L"\\pipe\\wkssvc",
99 NULL,
100 &pszStringBinding);
101 if (status)
102 {
103 TRACE("RpcStringBindingCompose returned 0x%x\n", status);
104 return NULL;
105 }
106
107 /* Set the binding handle that will be used to bind to the server. */
108 status = RpcBindingFromStringBindingW(pszStringBinding,
109 &hBinding);
110 if (status)
111 {
112 TRACE("RpcBindingFromStringBinding returned 0x%x\n", status);
113 }
114
115 status = RpcStringFreeW(&pszStringBinding);
116 if (status)
117 {
118 // TRACE("RpcStringFree returned 0x%x\n", status);
119 }
120
121 return hBinding;
122 }
123
124
125 void __RPC_USER
WKSSVC_IMPERSONATE_HANDLE_unbind(WKSSVC_IMPERSONATE_HANDLE pszSystemName,handle_t hBinding)126 WKSSVC_IMPERSONATE_HANDLE_unbind(WKSSVC_IMPERSONATE_HANDLE pszSystemName,
127 handle_t hBinding)
128 {
129 RPC_STATUS status;
130
131 TRACE("WKSSVC_IMPERSONATE_HANDLE_unbind() called\n");
132
133 status = RpcBindingFree(&hBinding);
134 if (status)
135 {
136 TRACE("RpcBindingFree returned 0x%x\n", status);
137 }
138 }
139
140
141 NET_API_STATUS
NetpBind(LPCWSTR pszServerName,handle_t * pBindingHandle)142 NetpBind(
143 LPCWSTR pszServerName,
144 handle_t *pBindingHandle)
145 {
146 handle_t hBinding = NULL;
147 LPWSTR pszStringBinding;
148 RPC_STATUS status;
149
150 FIXME("NetpBind(%S)\n", pszServerName);
151
152 *pBindingHandle = NULL;
153
154 status = RpcStringBindingComposeW(NULL,
155 L"ncacn_np",
156 (LPWSTR)pszServerName,
157 L"\\pipe\\wkssvc",
158 NULL,
159 &pszStringBinding);
160 if (status)
161 {
162 FIXME("RpcStringBindingCompose returned 0x%x\n", status);
163 return NetpNtStatusToApiStatus(status);
164 }
165
166 /* Set the binding handle that will be used to bind to the server. */
167 status = RpcBindingFromStringBindingW(pszStringBinding,
168 &hBinding);
169 if (status)
170 {
171 FIXME("RpcBindingFromStringBinding returned 0x%x\n", status);
172 }
173
174 status = RpcStringFreeW(&pszStringBinding);
175 if (status)
176 {
177 FIXME("RpcStringFree returned 0x%x\n", status);
178 }
179
180 *pBindingHandle = hBinding;
181
182 return NetpNtStatusToApiStatus(status);
183 }
184
185
186 NET_API_STATUS
NetpUnbind(handle_t BindingHandle)187 NetpUnbind(
188 handle_t BindingHandle)
189 {
190 RPC_STATUS status;
191
192 FIXME("NetpUnbind(%p)\n", BindingHandle);
193
194 status = RpcBindingFree(&wkssvc_hBinding);
195 if (status)
196 {
197 TRACE("RpcBindingFree returned 0x%x\n", status);
198 return NetpNtStatusToApiStatus(status);
199 }
200
201 return NERR_Success;
202 }
203
204
205 NET_API_STATUS
206 WINAPI
NetAddAlternateComputerName(_In_opt_ LPCWSTR Server,_In_ LPCWSTR AlternateName,_In_opt_ LPCWSTR DomainAccount,_In_opt_ LPCWSTR DomainAccountPassword,_In_ ULONG Reserved)207 NetAddAlternateComputerName(
208 _In_opt_ LPCWSTR Server,
209 _In_ LPCWSTR AlternateName,
210 _In_opt_ LPCWSTR DomainAccount,
211 _In_opt_ LPCWSTR DomainAccountPassword,
212 _In_ ULONG Reserved)
213 {
214 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
215 handle_t BindingHandle = NULL;
216 NET_API_STATUS status;
217
218 TRACE("NetAddAlternateComputerName(%s %s %s %s 0x%lx)\n",
219 debugstr_w(Server), debugstr_w(AlternateName), debugstr_w(DomainAccount),
220 debugstr_w(DomainAccountPassword), Reserved);
221
222 /* FIXME */
223
224 status = NetpBind(Server,
225 &BindingHandle);
226 if (status != NERR_Success)
227 {
228 ERR("NetpBind() failed (status 0x%lx)\n", status);
229 return status;
230 }
231
232 RpcTryExcept
233 {
234 status = NetrAddAlternateComputerName(BindingHandle,
235 (PWSTR)Server,
236 (PWSTR)AlternateName,
237 (PWSTR)DomainAccount,
238 EncryptedPassword,
239 Reserved);
240 }
241 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
242 {
243 status = I_RpcMapWin32Status(RpcExceptionCode());
244 }
245 RpcEndExcept;
246
247 NetpUnbind(BindingHandle);
248
249 return status;
250 }
251
252
253 NET_API_STATUS
254 WINAPI
NetEnumerateComputerNames(_In_opt_ LPCWSTR Server,_In_ NET_COMPUTER_NAME_TYPE NameType,_In_ ULONG Reserved,_Out_ PDWORD EntryCount,_Out_ LPWSTR ** ComputerNames)255 NetEnumerateComputerNames(
256 _In_opt_ LPCWSTR Server,
257 _In_ NET_COMPUTER_NAME_TYPE NameType,
258 _In_ ULONG Reserved,
259 _Out_ PDWORD EntryCount,
260 _Out_ LPWSTR **ComputerNames)
261 {
262 PNET_COMPUTER_NAME_ARRAY ComputerNameArray = NULL;
263 ULONG BufferSize, i;
264 PWSTR *NameBuffer = NULL, Ptr;
265 NET_API_STATUS status;
266
267 TRACE("NetEnumerateComputerNames(%s %lu %lu %p %p)\n",
268 debugstr_w(Server), NameType, Reserved, EntryCount, ComputerNames);
269
270 RpcTryExcept
271 {
272 status = NetrEnumerateComputerNames((PWSTR)Server,
273 NameType,
274 Reserved,
275 &ComputerNameArray);
276 if (status == NERR_Success)
277 {
278 *EntryCount = ComputerNameArray->EntryCount;
279
280 BufferSize = 0;
281 for (i = 0; i < ComputerNameArray->EntryCount; i++)
282 {
283 BufferSize += ComputerNameArray->ComputerNames[i].Length + sizeof(WCHAR) + sizeof(PWSTR);
284 }
285
286 status = NetApiBufferAllocate(BufferSize, (PVOID*)&NameBuffer);
287 if (status == NERR_Success)
288 {
289 ZeroMemory(NameBuffer, BufferSize);
290
291 Ptr = (PWSTR)((ULONG_PTR)NameBuffer + ComputerNameArray->EntryCount * sizeof(PWSTR));
292 for (i = 0; i < ComputerNameArray->EntryCount; i++)
293 {
294 NameBuffer[i] = Ptr;
295 CopyMemory(Ptr,
296 ComputerNameArray->ComputerNames[i].Buffer,
297 ComputerNameArray->ComputerNames[i].Length);
298 Ptr = (PWSTR)((ULONG_PTR)Ptr + ComputerNameArray->ComputerNames[i].Length + sizeof(WCHAR));
299 }
300
301 *ComputerNames = NameBuffer;
302 }
303 }
304 }
305 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
306 {
307 status = I_RpcMapWin32Status(RpcExceptionCode());
308 }
309 RpcEndExcept;
310
311 return status;
312 }
313
314
315 NET_API_STATUS
316 WINAPI
NetGetJoinInformation(_In_ LPCWSTR lpServer,_Out_ LPWSTR * lpNameBuffer,_Out_ PNETSETUP_JOIN_STATUS BufferType)317 NetGetJoinInformation(
318 _In_ LPCWSTR lpServer,
319 _Out_ LPWSTR *lpNameBuffer,
320 _Out_ PNETSETUP_JOIN_STATUS BufferType)
321 {
322 NET_API_STATUS status = NERR_Success;
323
324 TRACE("NetGetJoinInformation(%s %p %p)\n",
325 debugstr_w(lpServer), lpNameBuffer, BufferType);
326
327 if (lpNameBuffer == NULL || BufferType == NULL)
328 return ERROR_INVALID_PARAMETER;
329
330 /* Disabled because of CORE-17679 */
331 #if 0
332 *lpNameBuffer = NULL;
333 RpcTryExcept
334 {
335 status = NetrGetJoinInformation((LPWSTR)lpServer,
336 lpNameBuffer,
337 BufferType);
338 }
339 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
340 {
341 status = I_RpcMapWin32Status(RpcExceptionCode());
342 }
343 RpcEndExcept;
344 #endif
345
346 *lpNameBuffer = NULL;
347 *BufferType = NetSetupUnknownStatus;
348
349 return status;
350 }
351
352
353 NET_API_STATUS
354 WINAPI
NetGetJoinableOUs(_In_opt_ LPCWSTR lpServer,_In_ LPCWSTR lpDomain,_In_opt_ LPCWSTR lpAccount,_In_opt_ LPCWSTR lpPassword,_Out_ DWORD * OUCount,_Out_ LPWSTR ** OUs)355 NetGetJoinableOUs(
356 _In_opt_ LPCWSTR lpServer,
357 _In_ LPCWSTR lpDomain,
358 _In_opt_ LPCWSTR lpAccount,
359 _In_opt_ LPCWSTR lpPassword,
360 _Out_ DWORD *OUCount,
361 _Out_ LPWSTR **OUs)
362 {
363 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
364 handle_t BindingHandle = NULL;
365 NET_API_STATUS status;
366
367 TRACE("NetGetJoinableOUs(%s %s %s %s %p %p)\n",
368 debugstr_w(lpServer), debugstr_w(lpDomain), debugstr_w(lpAccount),
369 debugstr_w(lpPassword), OUCount, OUs);
370
371 /* FIXME */
372
373 status = NetpBind(lpServer,
374 &BindingHandle);
375 if (status != NERR_Success)
376 {
377 ERR("NetpBind() failed (status 0x%lx)\n", status);
378 return status;
379 }
380
381 RpcTryExcept
382 {
383 status = NetrGetJoinableOUs2(BindingHandle,
384 (PWSTR)lpServer,
385 (PWSTR)lpDomain,
386 (PWSTR)lpAccount,
387 EncryptedPassword,
388 OUCount,
389 OUs);
390 }
391 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
392 {
393 status = I_RpcMapWin32Status(RpcExceptionCode());
394 }
395 RpcEndExcept;
396
397 NetpUnbind(BindingHandle);
398
399 return status;
400 }
401
402
403 NET_API_STATUS
404 WINAPI
NetJoinDomain(_In_opt_ LPCWSTR lpServer,_In_ LPCWSTR lpDomain,_In_opt_ LPCWSTR lpAccountOU,_In_opt_ LPCWSTR lpAccount,_In_opt_ LPCWSTR lpPassword,_In_ DWORD fJoinOptions)405 NetJoinDomain(
406 _In_opt_ LPCWSTR lpServer,
407 _In_ LPCWSTR lpDomain,
408 _In_opt_ LPCWSTR lpAccountOU,
409 _In_opt_ LPCWSTR lpAccount,
410 _In_opt_ LPCWSTR lpPassword,
411 _In_ DWORD fJoinOptions)
412 {
413 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
414 handle_t BindingHandle = NULL;
415 NET_API_STATUS status;
416
417 FIXME("NetJoinDomain(%s %s %s %s 0x%lx)\n",
418 debugstr_w(lpServer), debugstr_w(lpDomain), debugstr_w(lpAccountOU),
419 debugstr_w(lpAccount), debugstr_w(lpPassword), fJoinOptions);
420
421 /* FIXME */
422
423 status = NetpBind(lpServer,
424 &BindingHandle);
425 if (status != NERR_Success)
426 {
427 ERR("NetpBind() failed (status 0x%lx)\n", status);
428 return status;
429 }
430
431 RpcTryExcept
432 {
433 status = NetrJoinDomain2(BindingHandle,
434 (PWSTR)lpServer,
435 (PWSTR)lpDomain,
436 (PWSTR)lpAccountOU,
437 (PWSTR)lpAccount,
438 EncryptedPassword,
439 fJoinOptions);
440 }
441 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
442 {
443 RPC_STATUS rpcStatus = RpcExceptionCode();
444 FIXME("Exception 0x%lx\n", rpcStatus);
445 status = I_RpcMapWin32Status(rpcStatus);
446 }
447 RpcEndExcept;
448
449 NetpUnbind(BindingHandle);
450
451 return status;
452 }
453
454
455 NET_API_STATUS
456 WINAPI
NetRemoveAlternateComputerName(_In_opt_ LPCWSTR Server,_In_ LPCWSTR AlternateName,_In_opt_ LPCWSTR DomainAccount,_In_opt_ LPCWSTR DomainAccountPassword,_In_ ULONG Reserved)457 NetRemoveAlternateComputerName(
458 _In_opt_ LPCWSTR Server,
459 _In_ LPCWSTR AlternateName,
460 _In_opt_ LPCWSTR DomainAccount,
461 _In_opt_ LPCWSTR DomainAccountPassword,
462 _In_ ULONG Reserved)
463 {
464 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
465 handle_t BindingHandle = NULL;
466 NET_API_STATUS status;
467
468 TRACE("NetRemoveAlternateComputerName(%s %s %s %s 0x%lx)\n",
469 debugstr_w(Server), debugstr_w(AlternateName), debugstr_w(DomainAccount),
470 debugstr_w(DomainAccountPassword), Reserved);
471
472 /* FIXME */
473
474 status = NetpBind(Server,
475 &BindingHandle);
476 if (status != NERR_Success)
477 {
478 ERR("NetpBind() failed (status 0x%lx)\n", status);
479 return status;
480 }
481
482 RpcTryExcept
483 {
484 status = NetrRemoveAlternateComputerName(BindingHandle,
485 (PWSTR)Server,
486 (PWSTR)AlternateName,
487 (PWSTR)DomainAccount,
488 EncryptedPassword,
489 Reserved);
490 }
491 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
492 {
493 status = I_RpcMapWin32Status(RpcExceptionCode());
494 }
495 RpcEndExcept;
496
497 NetpUnbind(BindingHandle);
498
499 return status;
500 }
501
502
503 NET_API_STATUS
504 WINAPI
NetRenameMachineInDomain(_In_opt_ LPCWSTR lpServer,_In_opt_ LPCWSTR lpNewMachineName,_In_opt_ LPCWSTR lpAccount,_In_opt_ LPCWSTR lpPassword,_In_ DWORD fRenameOptions)505 NetRenameMachineInDomain(
506 _In_opt_ LPCWSTR lpServer,
507 _In_opt_ LPCWSTR lpNewMachineName,
508 _In_opt_ LPCWSTR lpAccount,
509 _In_opt_ LPCWSTR lpPassword,
510 _In_ DWORD fRenameOptions)
511 {
512 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
513 handle_t BindingHandle = NULL;
514 NET_API_STATUS status;
515
516 TRACE("NetRenameMachineInDomain(%s %s %s %s 0x%lx)\n",
517 debugstr_w(lpServer), debugstr_w(lpNewMachineName), debugstr_w(lpAccount),
518 debugstr_w(lpPassword), fRenameOptions);
519
520 /* FIXME */
521
522 status = NetpBind(lpServer,
523 &BindingHandle);
524 if (status != NERR_Success)
525 {
526 ERR("NetpBind() failed (status 0x%lx)\n", status);
527 return status;
528 }
529
530 RpcTryExcept
531 {
532 status = NetrRenameMachineInDomain2(BindingHandle,
533 (PWSTR)lpServer,
534 (PWSTR)lpNewMachineName,
535 (PWSTR)lpAccount,
536 EncryptedPassword,
537 fRenameOptions);
538 }
539 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
540 {
541 status = I_RpcMapWin32Status(RpcExceptionCode());
542 }
543 RpcEndExcept;
544
545 NetpUnbind(BindingHandle);
546
547 return status;
548 }
549
550
551 NET_API_STATUS
552 WINAPI
NetSetPrimaryComputerName(_In_opt_ LPCWSTR Server,_In_ LPCWSTR PrimaryName,_In_opt_ LPCWSTR DomainAccount,_In_opt_ LPCWSTR DomainAccountPassword,_In_ ULONG Reserved)553 NetSetPrimaryComputerName(
554 _In_opt_ LPCWSTR Server,
555 _In_ LPCWSTR PrimaryName,
556 _In_opt_ LPCWSTR DomainAccount,
557 _In_opt_ LPCWSTR DomainAccountPassword,
558 _In_ ULONG Reserved)
559 {
560 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
561 handle_t BindingHandle = NULL;
562 NET_API_STATUS status;
563
564 TRACE("NetSetPrimaryComputerName(%s %s %s %s %lu)\n",
565 debugstr_w(Server), debugstr_w(PrimaryName), debugstr_w(DomainAccount),
566 debugstr_w(DomainAccountPassword), Reserved);
567
568 /* FIXME */
569
570 status = NetpBind(Server,
571 &BindingHandle);
572 if (status != NERR_Success)
573 {
574 ERR("NetpBind() failed (status 0x%lx)\n", status);
575 return status;
576 }
577
578 RpcTryExcept
579 {
580 status = NetrSetPrimaryComputerName(BindingHandle,
581 (PWSTR)Server,
582 (PWSTR)PrimaryName,
583 (PWSTR)DomainAccount,
584 EncryptedPassword,
585 Reserved);
586 }
587 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
588 {
589 status = I_RpcMapWin32Status(RpcExceptionCode());
590 }
591 RpcEndExcept;
592
593 NetpUnbind(BindingHandle);
594
595 return status;
596 }
597
598
599 NET_API_STATUS
600 WINAPI
NetUnjoinDomain(_In_opt_ LPCWSTR lpServer,_In_opt_ LPCWSTR lpAccount,_In_opt_ LPCWSTR lpPassword,_In_ DWORD fUnjoinOptions)601 NetUnjoinDomain(
602 _In_opt_ LPCWSTR lpServer,
603 _In_opt_ LPCWSTR lpAccount,
604 _In_opt_ LPCWSTR lpPassword,
605 _In_ DWORD fUnjoinOptions)
606 {
607 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
608 handle_t BindingHandle = NULL;
609 NET_API_STATUS status;
610
611 TRACE("NetUnjoinDomain(%s %s %s %s 0x%lx)\n",
612 debugstr_w(lpServer), debugstr_w(lpAccount),
613 debugstr_w(lpPassword), fUnjoinOptions);
614
615 /* FIXME */
616
617 status = NetpBind(lpServer,
618 &BindingHandle);
619 if (status != NERR_Success)
620 {
621 ERR("NetpBind() failed (status 0x%lx)\n", status);
622 return status;
623 }
624
625 RpcTryExcept
626 {
627 status = NetrUnjoinDomain2(BindingHandle,
628 (PWSTR)lpServer,
629 (PWSTR)lpAccount,
630 EncryptedPassword,
631 fUnjoinOptions);
632 }
633 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
634 {
635 status = I_RpcMapWin32Status(RpcExceptionCode());
636 }
637 RpcEndExcept;
638
639 NetpUnbind(BindingHandle);
640
641 return status;
642 }
643
644
645 NET_API_STATUS
646 WINAPI
NetUseAdd(_In_ LMSTR UncServerName,_In_ DWORD Level,_In_ LPBYTE Buf,_Out_ LPDWORD ParmError)647 NetUseAdd(
648 _In_ LMSTR UncServerName,
649 _In_ DWORD Level,
650 _In_ LPBYTE Buf,
651 _Out_ LPDWORD ParmError)
652 {
653 NET_API_STATUS status;
654
655 TRACE("NetUseAdd(%s %d %p %p)\n", debugstr_w(UncServerName),
656 Level, Buf, ParmError);
657
658 RpcTryExcept
659 {
660 status = NetrUseAdd(UncServerName,
661 Level,
662 (LPUSE_INFO)Buf,
663 ParmError);
664 }
665 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
666 {
667 status = I_RpcMapWin32Status(RpcExceptionCode());
668 }
669 RpcEndExcept;
670
671 return status;
672 }
673
674
675 NET_API_STATUS
676 WINAPI
NetUseDel(_In_ LMSTR UncServerName,_In_ LMSTR UseName,_In_ DWORD ForceCond)677 NetUseDel(
678 _In_ LMSTR UncServerName,
679 _In_ LMSTR UseName,
680 _In_ DWORD ForceCond)
681 {
682 NET_API_STATUS status;
683
684 TRACE("NetUseDel(%s %s %d)\n", debugstr_w(UncServerName),
685 debugstr_w(UseName), ForceCond);
686
687 RpcTryExcept
688 {
689 status = NetrUseDel(UncServerName,
690 UseName,
691 ForceCond);
692 }
693 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
694 {
695 status = I_RpcMapWin32Status(RpcExceptionCode());
696 }
697 RpcEndExcept;
698
699 return status;
700 }
701
702
703 NET_API_STATUS
704 WINAPI
NetUseEnum(_In_ LMSTR UncServerName,_In_ DWORD Level,_Out_ LPBYTE * BufPtr,_In_ DWORD PreferedMaximumSize,_Out_ LPDWORD EntriesRead,_Out_ LPDWORD TotalEntries,_Inout_ LPDWORD ResumeHandle)705 NetUseEnum(
706 _In_ LMSTR UncServerName,
707 _In_ DWORD Level,
708 _Out_ LPBYTE *BufPtr,
709 _In_ DWORD PreferedMaximumSize,
710 _Out_ LPDWORD EntriesRead,
711 _Out_ LPDWORD TotalEntries,
712 _Inout_ LPDWORD ResumeHandle)
713 {
714 USE_ENUM_STRUCT UseEnumInfo;
715 USE_INFO_0_CONTAINER Container0;
716 USE_INFO_1_CONTAINER Container1;
717 USE_INFO_2_CONTAINER Container2;
718 NET_API_STATUS status;
719
720 TRACE("NetUseEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(UncServerName),
721 Level, BufPtr, PreferedMaximumSize, EntriesRead, TotalEntries, ResumeHandle);
722
723 UseEnumInfo.Level = Level;
724 switch (Level)
725 {
726 case 0:
727 UseEnumInfo.UseInfo.Level0 = &Container0;
728 Container0.EntriesRead = 0;
729 Container0.Buffer = NULL;
730 break;
731
732 case 1:
733 UseEnumInfo.UseInfo.Level1 = &Container1;
734 Container1.EntriesRead = 0;
735 Container1.Buffer = NULL;
736 break;
737
738 case 2:
739 UseEnumInfo.UseInfo.Level2 = &Container2;
740 Container2.EntriesRead = 0;
741 Container2.Buffer = NULL;
742 break;
743
744 default:
745 return ERROR_INVALID_PARAMETER;
746 }
747
748 RpcTryExcept
749 {
750 status = NetrUseEnum(UncServerName,
751 &UseEnumInfo,
752 PreferedMaximumSize,
753 TotalEntries,
754 ResumeHandle);
755 if (status == NERR_Success || status == ERROR_MORE_DATA)
756 {
757 switch (Level)
758 {
759 case 0:
760 *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level0->Buffer;
761 *EntriesRead = UseEnumInfo.UseInfo.Level0->EntriesRead;
762 break;
763
764 case 1:
765 *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level1->Buffer;
766 *EntriesRead = UseEnumInfo.UseInfo.Level1->EntriesRead;
767 break;
768
769 case 2:
770 *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level2->Buffer;
771 *EntriesRead = UseEnumInfo.UseInfo.Level2->EntriesRead;
772 break;
773 }
774 }
775 }
776 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
777 {
778 status = I_RpcMapWin32Status(RpcExceptionCode());
779 }
780 RpcEndExcept;
781
782 return status;
783 }
784
785
786 NET_API_STATUS
787 WINAPI
NetUseGetInfo(_In_ LMSTR UncServerName,_In_ LMSTR UseName,_In_ DWORD Level,_Out_ LPBYTE * BufPtr)788 NetUseGetInfo(
789 _In_ LMSTR UncServerName,
790 _In_ LMSTR UseName,
791 _In_ DWORD Level,
792 _Out_ LPBYTE *BufPtr)
793 {
794 NET_API_STATUS status;
795
796 TRACE("NetUseGetInfo(%s, %s, %d, %p)\n", debugstr_w(UncServerName),
797 debugstr_w(UseName), Level, BufPtr);
798
799 *BufPtr = NULL;
800
801 RpcTryExcept
802 {
803 status = NetrUseGetInfo(UncServerName,
804 UseName,
805 Level,
806 (LPUSE_INFO)BufPtr);
807 }
808 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
809 {
810 status = I_RpcMapWin32Status(RpcExceptionCode());
811 }
812 RpcEndExcept;
813
814 return status;
815 }
816
817
818 NET_API_STATUS
819 WINAPI
NetValidateName(_In_opt_ LPCWSTR lpServer,_In_ LPCWSTR lpName,_In_opt_ LPCWSTR lpAccount,_In_opt_ LPCWSTR lpPassword,_In_ NETSETUP_NAME_TYPE NameType)820 NetValidateName(
821 _In_opt_ LPCWSTR lpServer,
822 _In_ LPCWSTR lpName,
823 _In_opt_ LPCWSTR lpAccount,
824 _In_opt_ LPCWSTR lpPassword,
825 _In_ NETSETUP_NAME_TYPE NameType)
826 {
827 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
828 handle_t BindingHandle = NULL;
829 NET_API_STATUS status;
830
831 TRACE("NetValidateName(%s %s %s %s %u)\n",
832 debugstr_w(lpServer), debugstr_w(lpName), debugstr_w(lpAccount),
833 debugstr_w(lpPassword), NameType);
834
835 /* FIXME */
836
837 status = NetpBind(lpServer,
838 &BindingHandle);
839 if (status != NERR_Success)
840 {
841 ERR("NetpBind() failed (status 0x%lx)\n", status);
842 return status;
843 }
844
845 RpcTryExcept
846 {
847 status = NetrValidateName2(BindingHandle,
848 (PWSTR)lpServer,
849 (PWSTR)lpName,
850 (PWSTR)lpAccount,
851 EncryptedPassword,
852 NameType);
853 }
854 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
855 {
856 status = I_RpcMapWin32Status(RpcExceptionCode());
857 }
858 RpcEndExcept;
859
860 NetpUnbind(BindingHandle);
861
862 return status;
863 }
864
865
866 NET_API_STATUS
867 WINAPI
NetWkstaGetInfo(_In_ LPWSTR servername,_In_ DWORD level,_Out_ LPBYTE * bufptr)868 NetWkstaGetInfo(
869 _In_ LPWSTR servername,
870 _In_ DWORD level,
871 _Out_ LPBYTE *bufptr)
872 {
873 NET_API_STATUS status;
874
875 TRACE("NetWkstaGetInfo(%s, %d, %p)\n",
876 debugstr_w(servername), level, bufptr);
877
878 if (bufptr == NULL)
879 return ERROR_INVALID_PARAMETER;
880
881 *bufptr = NULL;
882
883 RpcTryExcept
884 {
885 status = NetrWkstaGetInfo(servername,
886 level,
887 (LPWKSTA_INFO*)bufptr);
888 }
889 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
890 {
891 status = I_RpcMapWin32Status(RpcExceptionCode());
892 }
893 RpcEndExcept;
894
895 return status;
896 }
897
898
899 NET_API_STATUS
900 WINAPI
NetWkstaSetInfo(_In_ LPWSTR servername,_In_ DWORD level,_In_ LPBYTE buffer,_Out_ LPDWORD parm_err)901 NetWkstaSetInfo(
902 _In_ LPWSTR servername,
903 _In_ DWORD level,
904 _In_ LPBYTE buffer,
905 _Out_ LPDWORD parm_err)
906 {
907 NET_API_STATUS status;
908
909 TRACE("NetWkstaSetInfo(%s, %d, %p, %p)\n",
910 debugstr_w(servername), level, buffer, parm_err);
911
912 RpcTryExcept
913 {
914 status = NetrWkstaSetInfo(servername,
915 level,
916 (LPWKSTA_INFO)buffer,
917 parm_err);
918 }
919 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
920 {
921 status = I_RpcMapWin32Status(RpcExceptionCode());
922 }
923 RpcEndExcept;
924
925 return status;
926 }
927
928
929 NET_API_STATUS
930 WINAPI
NetWkstaTransportAdd(_In_opt_ LPWSTR servername,_In_ DWORD level,_In_ LPBYTE buf,_Out_ LPDWORD parm_err)931 NetWkstaTransportAdd(
932 _In_opt_ LPWSTR servername,
933 _In_ DWORD level,
934 _In_ LPBYTE buf,
935 _Out_ LPDWORD parm_err)
936 {
937 NET_API_STATUS status;
938
939 TRACE("NetWkstaTransportAdd(%s, %d, %p, %p)\n", debugstr_w(servername),
940 level, buf, parm_err);
941
942 RpcTryExcept
943 {
944 status = NetrWkstaTransportAdd(servername,
945 level,
946 (LPWKSTA_TRANSPORT_INFO_0)buf,
947 parm_err);
948 }
949 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
950 {
951 status = I_RpcMapWin32Status(RpcExceptionCode());
952 }
953 RpcEndExcept;
954
955 return status;
956 }
957
958
959 NET_API_STATUS
960 WINAPI
NetWkstaTransportDel(_In_opt_ LPWSTR servername,_In_ LPWSTR transportname,_In_ DWORD ucond)961 NetWkstaTransportDel(
962 _In_opt_ LPWSTR servername,
963 _In_ LPWSTR transportname,
964 _In_ DWORD ucond)
965 {
966 NET_API_STATUS status;
967
968 TRACE("NetWkstaTransportDel(%s, %s, %d)\n", debugstr_w(servername),
969 debugstr_w(transportname), ucond);
970
971 RpcTryExcept
972 {
973 status = NetrWkstaTransportDel(servername,
974 transportname,
975 ucond);
976 }
977 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
978 {
979 status = I_RpcMapWin32Status(RpcExceptionCode());
980 }
981 RpcEndExcept;
982
983 return status;
984 }
985
986
987 #if 0
988 NET_API_STATUS
989 WINAPI
990 NetWkstaTransportEnum(
991 _In_opt_ LPWSTR servername,
992 _In_ DWORD level,
993 _Out_ LPBYTE *bufptr,
994 _In_ DWORD prefmaxlen,
995 _Out_ LPDWORD entriesread,
996 _Out_ LPDWORD totalentries,
997 _Inout_ LPDWORD resumehandle)
998 {
999 WKSTA_TRANSPORT_ENUM_STRUCT TransportEnumInfo;
1000 WKSTA_TRANSPORT_INFO_0_CONTAINER Container0;
1001 NET_API_STATUS status;
1002
1003 TRACE("NetWkstaTransportEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername),
1004 level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle);
1005
1006 TransportEnumInfo.Level = level;
1007 switch (level)
1008 {
1009 case 0:
1010 TransportEnumInfo.WkstaTransportInfo.Level0 = &Container0;
1011 Container0.EntriesRead = 0;
1012 Container0.Buffer = NULL;
1013 break;
1014
1015 default:
1016 return ERROR_INVALID_PARAMETER;
1017 }
1018
1019 RpcTryExcept
1020 {
1021 status = NetrWkstaTransportEnum(servername,
1022 &TransportEnumInfo,
1023 prefmaxlen,
1024 totalentries,
1025 resumehandle);
1026 if (status == NERR_Success || status == ERROR_MORE_DATA)
1027 {
1028 switch (level)
1029 {
1030 case 0:
1031 *bufptr = (LPBYTE)TransportEnumInfo.WkstaTransportInfo.Level0->Buffer;
1032 *entriesread = TransportEnumInfo.WkstaTransportInfo.Level0->EntriesRead;
1033 break;
1034 }
1035 }
1036 }
1037 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1038 {
1039 status = I_RpcMapWin32Status(RpcExceptionCode());
1040 }
1041 RpcEndExcept;
1042
1043 return status;
1044 }
1045 #endif
1046
1047
1048 NET_API_STATUS
1049 WINAPI
NetWkstaUserEnum(_In_ LPWSTR servername,_In_ DWORD level,_Out_ LPBYTE * bufptr,_In_ DWORD prefmaxlen,_Out_ LPDWORD entriesread,_Out_ LPDWORD totalentries,_Inout_ LPDWORD resumehandle)1050 NetWkstaUserEnum(
1051 _In_ LPWSTR servername,
1052 _In_ DWORD level,
1053 _Out_ LPBYTE *bufptr,
1054 _In_ DWORD prefmaxlen,
1055 _Out_ LPDWORD entriesread,
1056 _Out_ LPDWORD totalentries,
1057 _Inout_ LPDWORD resumehandle)
1058 {
1059 WKSTA_USER_ENUM_STRUCT UserEnumInfo;
1060 WKSTA_USER_INFO_0_CONTAINER Container0;
1061 WKSTA_USER_INFO_1_CONTAINER Container1;
1062 NET_API_STATUS status;
1063
1064 TRACE("NetWkstaUserEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername),
1065 level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle);
1066
1067 UserEnumInfo.Level = level;
1068 switch (level)
1069 {
1070 case 0:
1071 UserEnumInfo.WkstaUserInfo.Level0 = &Container0;
1072 Container0.EntriesRead = 0;
1073 Container0.Buffer = NULL;
1074 break;
1075
1076 case 1:
1077 UserEnumInfo.WkstaUserInfo.Level1 = &Container1;
1078 Container1.EntriesRead = 0;
1079 Container1.Buffer = NULL;
1080 break;
1081
1082 default:
1083 return ERROR_INVALID_PARAMETER;
1084 }
1085
1086 RpcTryExcept
1087 {
1088 status = NetrWkstaUserEnum(servername,
1089 &UserEnumInfo,
1090 prefmaxlen,
1091 totalentries,
1092 resumehandle);
1093 if (status == NERR_Success || status == ERROR_MORE_DATA)
1094 {
1095 switch (level)
1096 {
1097 case 0:
1098 *bufptr = (LPBYTE)UserEnumInfo.WkstaUserInfo.Level0->Buffer;
1099 *entriesread = UserEnumInfo.WkstaUserInfo.Level0->EntriesRead;
1100 break;
1101
1102 case 1:
1103 *bufptr = (LPBYTE)UserEnumInfo.WkstaUserInfo.Level1->Buffer;
1104 *entriesread = UserEnumInfo.WkstaUserInfo.Level1->EntriesRead;
1105 break;
1106 }
1107 }
1108 }
1109 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1110 {
1111 status = I_RpcMapWin32Status(RpcExceptionCode());
1112 }
1113 RpcEndExcept;
1114
1115 return status;
1116 }
1117
1118
1119 #if 0
1120 NET_API_STATUS
1121 WINAPI
1122 NetWkstaUserGetInfo(
1123 LPWSTR reserved,
1124 _In_ DWORD level,
1125 _Out_ PBYTE *bufptr)
1126 {
1127 NET_API_STATUS status;
1128
1129 TRACE("NetWkstaUserGetInfo(%s, %d, %p)\n",
1130 debugstr_w(reserved), level, bufptr);
1131
1132 if (reserved != NULL)
1133 return ERROR_INVALID_PARAMETER;
1134
1135 *bufptr = NULL;
1136
1137 RpcTryExcept
1138 {
1139 status = NetrWkstaUserGetInfo(NULL,
1140 level,
1141 (LPWKSTA_USER_INFO)bufptr);
1142 }
1143 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1144 {
1145 status = I_RpcMapWin32Status(RpcExceptionCode());
1146 }
1147 RpcEndExcept;
1148
1149 return status;
1150 }
1151 #endif
1152
1153
1154 NET_API_STATUS
1155 WINAPI
NetWkstaUserSetInfo(LPWSTR reserved,_In_ DWORD level,_In_ LPBYTE buf,_Out_ LPDWORD parm_err)1156 NetWkstaUserSetInfo(
1157 LPWSTR reserved,
1158 _In_ DWORD level,
1159 _In_ LPBYTE buf,
1160 _Out_ LPDWORD parm_err)
1161 {
1162 NET_API_STATUS status;
1163
1164 TRACE("NetWkstaSetInfo(%s, %d, %p, %p)\n",
1165 debugstr_w(reserved), level, buf, parm_err);
1166
1167 if (reserved != NULL)
1168 return ERROR_INVALID_PARAMETER;
1169
1170 RpcTryExcept
1171 {
1172 status = NetrWkstaUserSetInfo(NULL,
1173 level,
1174 (LPWKSTA_USER_INFO)&buf,
1175 parm_err);
1176 }
1177 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1178 {
1179 status = I_RpcMapWin32Status(RpcExceptionCode());
1180 }
1181 RpcEndExcept;
1182
1183 return status;
1184 }
1185
1186 /* EOF */
1187