[NETAPI32] Add RPC binding code to functions that require explicit binding
[reactos.git] / dll / win32 / netapi32 / wksta_new.c
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
19 void __RPC_FAR * __RPC_USER midl_user_allocate(SIZE_T len)
20 {
21 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
22 }
23
24
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
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
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
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
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
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
187 NetpUnbind(
188 handle_t BindingHandle)
189 {
190 RPC_STATUS status;
191
192 FIXME("NetpUnbind(%p)\n", BindingHandle);
193
194 status = RpcBindingFree(&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
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;
215 handle_t BindingHandle;
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 BindingHandle = NULL;
224 EncryptedPassword = NULL;
225
226 RpcTryExcept
227 {
228 status = NetrAddAlternateComputerName(BindingHandle,
229 (PWSTR)Server,
230 (PWSTR)AlternateName,
231 (PWSTR)DomainAccount,
232 EncryptedPassword,
233 Reserved);
234 }
235 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
236 {
237 status = I_RpcMapWin32Status(RpcExceptionCode());
238 }
239 RpcEndExcept;
240
241 return status;
242 }
243
244
245 NET_API_STATUS
246 WINAPI
247 NetEnumerateComputerNames(
248 _In_opt_ LPCWSTR Server,
249 _In_ NET_COMPUTER_NAME_TYPE NameType,
250 _In_ ULONG Reserved,
251 _Out_ PDWORD EntryCount,
252 _Out_ LPWSTR **ComputerNames)
253 {
254 PNET_COMPUTER_NAME_ARRAY ComputerNameArray = NULL;
255 ULONG BufferSize, i;
256 PWSTR *NameBuffer = NULL, Ptr;
257 NET_API_STATUS status;
258
259 TRACE("NetEnumerateComputerNames(%s %lu %lu %p %p)\n",
260 debugstr_w(Server), NameType, Reserved, EntryCount, ComputerNames);
261
262 RpcTryExcept
263 {
264 status = NetrEnumerateComputerNames((PWSTR)Server,
265 NameType,
266 Reserved,
267 &ComputerNameArray);
268 if (status == NERR_Success)
269 {
270 *EntryCount = ComputerNameArray->EntryCount;
271
272 BufferSize = 0;
273 for (i = 0; i < ComputerNameArray->EntryCount; i++)
274 {
275 BufferSize += ComputerNameArray->ComputerNames[i].Length + sizeof(WCHAR) + sizeof(PWSTR);
276 }
277
278 status = NetApiBufferAllocate(BufferSize, (PVOID*)&NameBuffer);
279 if (status == NERR_Success)
280 {
281 ZeroMemory(NameBuffer, BufferSize);
282
283 Ptr = (PWSTR)((ULONG_PTR)NameBuffer + ComputerNameArray->EntryCount * sizeof(PWSTR));
284 for (i = 0; i < ComputerNameArray->EntryCount; i++)
285 {
286 NameBuffer[i] = Ptr;
287 CopyMemory(Ptr,
288 ComputerNameArray->ComputerNames[i].Buffer,
289 ComputerNameArray->ComputerNames[i].Length);
290 Ptr = (PWSTR)((ULONG_PTR)Ptr + ComputerNameArray->ComputerNames[i].Length + sizeof(WCHAR));
291 }
292
293 *ComputerNames = NameBuffer;
294 }
295 }
296 }
297 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
298 {
299 status = I_RpcMapWin32Status(RpcExceptionCode());
300 }
301 RpcEndExcept;
302
303 return status;
304 }
305
306
307 #if 0
308 NET_API_STATUS
309 WINAPI
310 NetGetJoinInformation(
311 _In_ LPCWSTR lpServer,
312 _Out_ LPWSTR *lpNameBuffer,
313 _Out_ PNETSETUP_JOIN_STATUS BufferType)
314 {
315 NET_API_STATUS status;
316
317 TRACE("NetGetJoinInformation(%s %p %p)\n",
318 debugstr_w(lpServer), lpNameBuffer, BufferType);
319
320 if (lpNameBuffer == NULL || BufferType == NULL)
321 return ERROR_INVALID_PARAMETER;
322
323 RpcTryExcept
324 {
325 status = NetrGetJoinInformation((LPWSTR)lpServer,
326 lpNameBuffer,
327 BufferType);
328 }
329 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
330 {
331 status = I_RpcMapWin32Status(RpcExceptionCode());
332 }
333 RpcEndExcept;
334
335 return status;
336 }
337 #endif
338
339
340 NET_API_STATUS
341 WINAPI
342 NetGetJoinableOUs(
343 _In_ LPCWSTR lpServer,
344 _In_ LPCWSTR lpDomain,
345 _In_ LPCWSTR lpAccount,
346 _In_ LPCWSTR lpPassword,
347 _Out_ DWORD *OUCount,
348 _Out_ LPWSTR **OUs)
349 {
350 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
351 handle_t BindingHandle;
352 NET_API_STATUS status;
353
354 TRACE("NetGetJoinableOUs(%s %s %s %s %p %p)\n",
355 debugstr_w(lpServer), debugstr_w(lpDomain), debugstr_w(lpAccount),
356 debugstr_w(lpPassword), OUCount, OUs);
357
358 /* FIXME */
359 BindingHandle = NULL;
360 EncryptedPassword = NULL;
361
362 RpcTryExcept
363 {
364 status = NetrGetJoinableOUs2(BindingHandle,
365 (PWSTR)lpServer,
366 (PWSTR)lpDomain,
367 (PWSTR)lpAccount,
368 EncryptedPassword,
369 OUCount,
370 OUs);
371 }
372 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
373 {
374 status = I_RpcMapWin32Status(RpcExceptionCode());
375 }
376 RpcEndExcept;
377
378 return status;
379 }
380
381
382 NET_API_STATUS
383 WINAPI
384 NetJoinDomain(
385 _In_opt_ LPCWSTR lpServer,
386 _In_ LPCWSTR lpDomain,
387 _In_opt_ LPCWSTR lpAccountOU,
388 _In_opt_ LPCWSTR lpAccount,
389 _In_opt_ LPCWSTR lpPassword,
390 _In_ DWORD fJoinOptions)
391 {
392 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
393 handle_t BindingHandle = NULL;
394 NET_API_STATUS status;
395
396 FIXME("NetJoinDomain(%s %s %s %s 0x%lx)\n",
397 debugstr_w(lpServer), debugstr_w(lpDomain), debugstr_w(lpAccountOU),
398 debugstr_w(lpAccount), debugstr_w(lpPassword), fJoinOptions);
399
400 /* FIXME */
401
402 status = NetpBind(lpServer,
403 &BindingHandle);
404 if (status != NERR_Success)
405 {
406 ERR("NetpBind() failed (status 0x%lx)\n", status);
407 return status;
408 }
409
410 RpcTryExcept
411 {
412 status = NetrJoinDomain2(BindingHandle,
413 (PWSTR)lpServer,
414 (PWSTR)lpDomain,
415 (PWSTR)lpAccountOU,
416 (PWSTR)lpAccount,
417 EncryptedPassword,
418 fJoinOptions);
419 }
420 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
421 {
422 RPC_STATUS rpcStatus = RpcExceptionCode();
423 FIXME("Exception 0x%lx\n", rpcStatus);
424 status = I_RpcMapWin32Status(rpcStatus);
425 }
426 RpcEndExcept;
427
428 NetpUnbind(BindingHandle);
429
430 return status;
431 }
432
433
434 NET_API_STATUS
435 WINAPI
436 NetRemoveAlternateComputerName(
437 _In_opt_ LPCWSTR Server,
438 _In_ LPCWSTR AlternateName,
439 _In_opt_ LPCWSTR DomainAccount,
440 _In_opt_ LPCWSTR DomainAccountPassword,
441 _In_ ULONG Reserved)
442 {
443 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
444 handle_t BindingHandle;
445 NET_API_STATUS status;
446
447 TRACE("NetRemoveAlternateComputerName(%s %s %s %s 0x%lx)\n",
448 debugstr_w(Server), debugstr_w(AlternateName), debugstr_w(DomainAccount),
449 debugstr_w(DomainAccountPassword), Reserved);
450
451 /* FIXME */
452 BindingHandle = NULL;
453 EncryptedPassword = NULL;
454
455 RpcTryExcept
456 {
457 status = NetrRemoveAlternateComputerName(BindingHandle,
458 (PWSTR)Server,
459 (PWSTR)AlternateName,
460 (PWSTR)DomainAccount,
461 EncryptedPassword,
462 Reserved);
463 }
464 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
465 {
466 status = I_RpcMapWin32Status(RpcExceptionCode());
467 }
468 RpcEndExcept;
469
470 return status;
471 }
472
473
474 NET_API_STATUS
475 WINAPI
476 NetRenameMachineInDomain(
477 _In_ LPCWSTR lpServer,
478 _In_ LPCWSTR lpNewMachineName,
479 _In_ LPCWSTR lpAccount,
480 _In_ LPCWSTR lpPassword,
481 _In_ DWORD fRenameOptions)
482 {
483 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
484 handle_t BindingHandle;
485 NET_API_STATUS status;
486
487 TRACE("NetRenameMachineInDomain(%s %s %s %s 0x%lx)\n",
488 debugstr_w(lpServer), debugstr_w(lpNewMachineName), debugstr_w(lpAccount),
489 debugstr_w(lpPassword), fRenameOptions);
490
491 /* FIXME */
492 BindingHandle = NULL;
493 EncryptedPassword = NULL;
494
495 RpcTryExcept
496 {
497 status = NetrRenameMachineInDomain2(BindingHandle,
498 (PWSTR)lpServer,
499 (PWSTR)lpNewMachineName,
500 (PWSTR)lpAccount,
501 EncryptedPassword,
502 fRenameOptions);
503 }
504 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
505 {
506 status = I_RpcMapWin32Status(RpcExceptionCode());
507 }
508 RpcEndExcept;
509
510 return status;
511 }
512
513
514 NET_API_STATUS
515 WINAPI
516 NetSetPrimaryComputerName(
517 _In_opt_ LPCWSTR Server,
518 _In_ LPCWSTR PrimaryName,
519 _In_opt_ LPCWSTR DomainAccount,
520 _In_opt_ LPCWSTR DomainAccountPassword,
521 _In_ ULONG Reserved)
522 {
523 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
524 handle_t BindingHandle;
525 NET_API_STATUS status;
526
527 TRACE("NetSetPrimaryComputerName(%s %s %s %s %lu)\n",
528 debugstr_w(Server), debugstr_w(PrimaryName), debugstr_w(DomainAccount),
529 debugstr_w(DomainAccountPassword), Reserved);
530
531 /* FIXME */
532 BindingHandle = NULL;
533 EncryptedPassword = NULL;
534
535 RpcTryExcept
536 {
537 status = NetrSetPrimaryComputerName(BindingHandle,
538 (PWSTR)Server,
539 (PWSTR)PrimaryName,
540 (PWSTR)DomainAccount,
541 EncryptedPassword,
542 Reserved);
543 }
544 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
545 {
546 status = I_RpcMapWin32Status(RpcExceptionCode());
547 }
548 RpcEndExcept;
549
550 return status;
551 }
552
553
554 NET_API_STATUS
555 WINAPI
556 NetUnjoinDomain(
557 _In_ LPCWSTR lpServer,
558 _In_opt_ LPCWSTR lpAccount,
559 _In_opt_ LPCWSTR lpPassword,
560 _In_ DWORD fUnjoinOptions)
561 {
562 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
563 handle_t BindingHandle = NULL;
564 NET_API_STATUS status;
565
566 TRACE("NetUnjoinDomain(%s %s %s %s 0x%lx)\n",
567 debugstr_w(lpServer), debugstr_w(lpAccount),
568 debugstr_w(lpPassword), fUnjoinOptions);
569
570 /* FIXME */
571
572 status = NetpBind(lpServer,
573 &BindingHandle);
574 if (status != NERR_Success)
575 {
576 ERR("NetpBind() failed (status 0x%lx)\n", status);
577 return status;
578 }
579
580 RpcTryExcept
581 {
582 status = NetrUnjoinDomain2(BindingHandle,
583 (PWSTR)lpServer,
584 (PWSTR)lpAccount,
585 EncryptedPassword,
586 fUnjoinOptions);
587 }
588 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
589 {
590 status = I_RpcMapWin32Status(RpcExceptionCode());
591 }
592 RpcEndExcept;
593
594 NetpUnbind(BindingHandle);
595
596 return status;
597 }
598
599
600 NET_API_STATUS
601 WINAPI
602 NetUseAdd(
603 _In_ LMSTR UncServerName,
604 _In_ DWORD Level,
605 _In_ LPBYTE Buf,
606 _Out_ LPDWORD ParmError)
607 {
608 NET_API_STATUS status;
609
610 TRACE("NetUseAdd(%s %d %p %p)\n", debugstr_w(UncServerName),
611 Level, Buf, ParmError);
612
613 RpcTryExcept
614 {
615 status = NetrUseAdd(UncServerName,
616 Level,
617 (LPUSE_INFO)Buf,
618 ParmError);
619 }
620 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
621 {
622 status = I_RpcMapWin32Status(RpcExceptionCode());
623 }
624 RpcEndExcept;
625
626 return status;
627 }
628
629
630 NET_API_STATUS
631 WINAPI
632 NetUseDel(
633 _In_ LMSTR UncServerName,
634 _In_ LMSTR UseName,
635 _In_ DWORD ForceCond)
636 {
637 NET_API_STATUS status;
638
639 TRACE("NetUseDel(%s %s %d)\n", debugstr_w(UncServerName),
640 debugstr_w(UseName), ForceCond);
641
642 RpcTryExcept
643 {
644 status = NetrUseDel(UncServerName,
645 UseName,
646 ForceCond);
647 }
648 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
649 {
650 status = I_RpcMapWin32Status(RpcExceptionCode());
651 }
652 RpcEndExcept;
653
654 return status;
655 }
656
657
658 NET_API_STATUS
659 WINAPI
660 NetUseEnum(
661 _In_ LMSTR UncServerName,
662 _In_ DWORD Level,
663 _Out_ LPBYTE *BufPtr,
664 _In_ DWORD PreferedMaximumSize,
665 _Out_ LPDWORD EntriesRead,
666 _Out_ LPDWORD TotalEntries,
667 _Inout_ LPDWORD ResumeHandle)
668 {
669 USE_ENUM_STRUCT UseEnumInfo;
670 USE_INFO_0_CONTAINER Container0;
671 USE_INFO_1_CONTAINER Container1;
672 USE_INFO_2_CONTAINER Container2;
673 NET_API_STATUS status;
674
675 TRACE("NetUseEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(UncServerName),
676 Level, BufPtr, PreferedMaximumSize, EntriesRead, TotalEntries, ResumeHandle);
677
678 UseEnumInfo.Level = Level;
679 switch (Level)
680 {
681 case 0:
682 UseEnumInfo.UseInfo.Level0 = &Container0;
683 Container0.EntriesRead = 0;
684 Container0.Buffer = NULL;
685 break;
686
687 case 1:
688 UseEnumInfo.UseInfo.Level1 = &Container1;
689 Container1.EntriesRead = 0;
690 Container1.Buffer = NULL;
691 break;
692
693 case 2:
694 UseEnumInfo.UseInfo.Level2 = &Container2;
695 Container2.EntriesRead = 0;
696 Container2.Buffer = NULL;
697 break;
698
699 default:
700 return ERROR_INVALID_PARAMETER;
701 }
702
703 RpcTryExcept
704 {
705 status = NetrUseEnum(UncServerName,
706 &UseEnumInfo,
707 PreferedMaximumSize,
708 TotalEntries,
709 ResumeHandle);
710 if (status == NERR_Success || status == ERROR_MORE_DATA)
711 {
712 switch (Level)
713 {
714 case 0:
715 *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level0->Buffer;
716 *EntriesRead = UseEnumInfo.UseInfo.Level0->EntriesRead;
717 break;
718
719 case 1:
720 *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level1->Buffer;
721 *EntriesRead = UseEnumInfo.UseInfo.Level1->EntriesRead;
722 break;
723
724 case 2:
725 *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level2->Buffer;
726 *EntriesRead = UseEnumInfo.UseInfo.Level2->EntriesRead;
727 break;
728 }
729 }
730 }
731 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
732 {
733 status = I_RpcMapWin32Status(RpcExceptionCode());
734 }
735 RpcEndExcept;
736
737 return status;
738 }
739
740
741 NET_API_STATUS
742 WINAPI
743 NetUseGetInfo(
744 _In_ LMSTR UncServerName,
745 _In_ LMSTR UseName,
746 _In_ DWORD Level,
747 _Out_ LPBYTE *BufPtr)
748 {
749 NET_API_STATUS status;
750
751 TRACE("NetUseGetInfo(%s, %s, %d, %p)\n", debugstr_w(UncServerName),
752 debugstr_w(UseName), Level, BufPtr);
753
754 *BufPtr = NULL;
755
756 RpcTryExcept
757 {
758 status = NetrUseGetInfo(UncServerName,
759 UseName,
760 Level,
761 (LPUSE_INFO)BufPtr);
762 }
763 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
764 {
765 status = I_RpcMapWin32Status(RpcExceptionCode());
766 }
767 RpcEndExcept;
768
769 return status;
770 }
771
772
773 NET_API_STATUS
774 WINAPI
775 NetValidateName(
776 _In_opt_ LPCWSTR lpServer,
777 _In_ LPCWSTR lpName,
778 _In_opt_ LPCWSTR lpAccount,
779 _In_opt_ LPCWSTR lpPassword,
780 _In_ NETSETUP_NAME_TYPE NameType)
781 {
782 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword = NULL;
783 handle_t BindingHandle = NULL;
784 NET_API_STATUS status;
785
786 TRACE("NetValidateName(%s %s %s %s %u)\n",
787 debugstr_w(lpServer), debugstr_w(lpName), debugstr_w(lpAccount),
788 debugstr_w(lpPassword), NameType);
789
790 /* FIXME */
791
792 status = NetpBind(lpServer,
793 &BindingHandle);
794 if (status != NERR_Success)
795 {
796 ERR("NetpBind() failed (status 0x%lx)\n", status);
797 return status;
798 }
799
800 RpcTryExcept
801 {
802 status = NetrValidateName2(BindingHandle,
803 (PWSTR)lpServer,
804 (PWSTR)lpName,
805 (PWSTR)lpAccount,
806 EncryptedPassword,
807 NameType);
808 }
809 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
810 {
811 status = I_RpcMapWin32Status(RpcExceptionCode());
812 }
813 RpcEndExcept;
814
815 NetpUnbind(BindingHandle);
816
817 return status;
818 }
819
820
821 #if 0
822 NET_API_STATUS
823 WINAPI
824 NetWkstaGetInfo(
825 _In_ LPWSTR servername,
826 _In_ DWORD level,
827 _Out_ LPBYTE *bufptr)
828 {
829 NET_API_STATUS status;
830
831 TRACE("NetWkstaGetInfo(%s, %d, %p)\n",
832 debugstr_w(servername), level, bufptr);
833
834 if (bufptr == NULL)
835 return ERROR_INVALID_PARAMETER;
836
837 *bufptr = NULL;
838
839 RpcTryExcept
840 {
841 status = NetrWkstaGetInfo(servername,
842 level,
843 (LPWKSTA_INFO)bufptr);
844 }
845 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
846 {
847 status = I_RpcMapWin32Status(RpcExceptionCode());
848 }
849 RpcEndExcept;
850
851 return status;
852 }
853 #endif
854
855
856 NET_API_STATUS
857 WINAPI
858 NetWkstaSetInfo(
859 _In_ LPWSTR servername,
860 _In_ DWORD level,
861 _In_ LPBYTE buffer,
862 _Out_ LPDWORD parm_err)
863 {
864 NET_API_STATUS status;
865
866 TRACE("NetWkstaSetInfo(%s, %d, %p, %p)\n",
867 debugstr_w(servername), level, buffer, parm_err);
868
869 RpcTryExcept
870 {
871 status = NetrWkstaSetInfo(servername,
872 level,
873 (LPWKSTA_INFO)buffer,
874 parm_err);
875 }
876 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
877 {
878 status = I_RpcMapWin32Status(RpcExceptionCode());
879 }
880 RpcEndExcept;
881
882 return status;
883 }
884
885
886 NET_API_STATUS
887 WINAPI
888 NetWkstaTransportAdd(
889 _In_opt_ LPWSTR servername,
890 _In_ DWORD level,
891 _In_ LPBYTE buf,
892 _Out_ LPDWORD parm_err)
893 {
894 NET_API_STATUS status;
895
896 TRACE("NetWkstaTransportAdd(%s, %d, %p, %p)\n", debugstr_w(servername),
897 level, buf, parm_err);
898
899 RpcTryExcept
900 {
901 status = NetrWkstaTransportAdd(servername,
902 level,
903 (LPWKSTA_TRANSPORT_INFO_0)buf,
904 parm_err);
905 }
906 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
907 {
908 status = I_RpcMapWin32Status(RpcExceptionCode());
909 }
910 RpcEndExcept;
911
912 return status;
913 }
914
915
916 NET_API_STATUS
917 WINAPI
918 NetWkstaTransportDel(
919 _In_opt_ LPWSTR servername,
920 _In_ LPWSTR transportname,
921 _In_ DWORD ucond)
922 {
923 NET_API_STATUS status;
924
925 TRACE("NetWkstaTransportDel(%s, %s, %d)\n", debugstr_w(servername),
926 debugstr_w(transportname), ucond);
927
928 RpcTryExcept
929 {
930 status = NetrWkstaTransportDel(servername,
931 transportname,
932 ucond);
933 }
934 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
935 {
936 status = I_RpcMapWin32Status(RpcExceptionCode());
937 }
938 RpcEndExcept;
939
940 return status;
941 }
942
943
944 #if 0
945 NET_API_STATUS
946 WINAPI
947 NetWkstaTransportEnum(
948 _In_opt_ LPWSTR servername,
949 _In_ DWORD level,
950 _Out_ LPBYTE *bufptr,
951 _In_ DWORD prefmaxlen,
952 _Out_ LPDWORD entriesread,
953 _Out_ LPDWORD totalentries,
954 _Inout_ LPDWORD resumehandle)
955 {
956 WKSTA_TRANSPORT_ENUM_STRUCT TransportEnumInfo;
957 WKSTA_TRANSPORT_INFO_0_CONTAINER Container0;
958 NET_API_STATUS status;
959
960 TRACE("NetWkstaTransportEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername),
961 level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle);
962
963 TransportEnumInfo.Level = level;
964 switch (level)
965 {
966 case 0:
967 TransportEnumInfo.WkstaTransportInfo.Level0 = &Container0;
968 Container0.EntriesRead = 0;
969 Container0.Buffer = NULL;
970 break;
971
972 default:
973 return ERROR_INVALID_PARAMETER;
974 }
975
976 RpcTryExcept
977 {
978 status = NetrWkstaTransportEnum(servername,
979 &TransportEnumInfo,
980 prefmaxlen,
981 totalentries,
982 resumehandle);
983 if (status == NERR_Success || status == ERROR_MORE_DATA)
984 {
985 switch (level)
986 {
987 case 0:
988 *bufptr = (LPBYTE)TransportEnumInfo.WkstaTransportInfo.Level0->Buffer;
989 *entriesread = TransportEnumInfo.WkstaTransportInfo.Level0->EntriesRead;
990 break;
991 }
992 }
993 }
994 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
995 {
996 status = I_RpcMapWin32Status(RpcExceptionCode());
997 }
998 RpcEndExcept;
999
1000 return status;
1001 }
1002
1003
1004 NET_API_STATUS
1005 WINAPI
1006 NetWkstaUserEnum(
1007 _In_ LPWSTR servername,
1008 _In_ DWORD level,
1009 _Out_ LPBYTE *bufptr,
1010 _In_ DWORD prefmaxlen,
1011 _Out_ LPDWORD entriesread,
1012 _Out_ LPDWORD totalentries,
1013 _Inout_ LPDWORD resumehandle)
1014 {
1015 WKSTA_USER_ENUM_STRUCT UserEnumInfo;
1016 WKSTA_USER_INFO_0_CONTAINER Container0;
1017 WKSTA_USER_INFO_1_CONTAINER Container1;
1018 NET_API_STATUS status;
1019
1020 TRACE("NetWkstaUserEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername),
1021 level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle);
1022
1023 UserEnumInfo.Level = level;
1024 switch (level)
1025 {
1026 case 0:
1027 UserEnumInfo.WkstaUserInfo.Level0 = &Container0;
1028 Container0.EntriesRead = 0;
1029 Container0.Buffer = NULL;
1030 break;
1031
1032 case 1:
1033 UserEnumInfo.WkstaUserInfo.Level1 = &Container1;
1034 Container1.EntriesRead = 0;
1035 Container1.Buffer = NULL;
1036 break;
1037
1038 default:
1039 return ERROR_INVALID_PARAMETER;
1040 }
1041
1042 RpcTryExcept
1043 {
1044 status = NetrWkstaUserEnum(servername,
1045 &UserEnumInfo,
1046 prefmaxlen,
1047 totalentries,
1048 resumehandle);
1049 if (status == NERR_Success || status == ERROR_MORE_DATA)
1050 {
1051 switch (level)
1052 {
1053 case 0:
1054 *bufptr = (LPBYTE)UserEnumInfo.WkstaUserInfo.Level0->Buffer;
1055 *entriesread = UserEnumInfo.WkstaUserInfo.Level0->EntriesRead;
1056 break;
1057
1058 case 1:
1059 *bufptr = (LPBYTE)UserEnumInfo.WkstaUserInfo.Level1->Buffer;
1060 *entriesread = UserEnumInfo.WkstaUserInfo.Level1->EntriesRead;
1061 break;
1062 }
1063 }
1064 }
1065 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1066 {
1067 status = I_RpcMapWin32Status(RpcExceptionCode());
1068 }
1069 RpcEndExcept;
1070
1071 return status;
1072 }
1073
1074
1075 NET_API_STATUS
1076 WINAPI
1077 NetWkstaUserGetInfo(
1078 LPWSTR reserved,
1079 _In_ DWORD level,
1080 _Out_ PBYTE *bufptr)
1081 {
1082 NET_API_STATUS status;
1083
1084 TRACE("NetWkstaUserGetInfo(%s, %d, %p)\n",
1085 debugstr_w(reserved), level, bufptr);
1086
1087 if (reserved != NULL)
1088 return ERROR_INVALID_PARAMETER;
1089
1090 *bufptr = NULL;
1091
1092 RpcTryExcept
1093 {
1094 status = NetrWkstaUserGetInfo(NULL,
1095 level,
1096 (LPWKSTA_USER_INFO)bufptr);
1097 }
1098 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1099 {
1100 status = I_RpcMapWin32Status(RpcExceptionCode());
1101 }
1102 RpcEndExcept;
1103
1104 return status;
1105 }
1106 #endif
1107
1108
1109 NET_API_STATUS
1110 WINAPI
1111 NetWkstaUserSetInfo(
1112 LPWSTR reserved,
1113 _In_ DWORD level,
1114 _In_ LPBYTE buf,
1115 _Out_ LPDWORD parm_err)
1116 {
1117 NET_API_STATUS status;
1118
1119 TRACE("NetWkstaSetInfo(%s, %d, %p, %p)\n",
1120 debugstr_w(reserved), level, buf, parm_err);
1121
1122 if (reserved != NULL)
1123 return ERROR_INVALID_PARAMETER;
1124
1125 RpcTryExcept
1126 {
1127 status = NetrWkstaUserSetInfo(NULL,
1128 level,
1129 (LPWKSTA_USER_INFO)&buf,
1130 parm_err);
1131 }
1132 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
1133 {
1134 status = I_RpcMapWin32Status(RpcExceptionCode());
1135 }
1136 RpcEndExcept;
1137
1138 return status;
1139 }
1140
1141 /* EOF */