[NETAPI32]
[reactos.git] / reactos / 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 WINAPI
143 NetAddAlternateComputerName(
144 _In_opt_ LPCWSTR Server,
145 _In_ LPCWSTR AlternateName,
146 _In_opt_ LPCWSTR DomainAccount,
147 _In_opt_ LPCWSTR DomainAccountPassword,
148 _In_ ULONG Reserved)
149 {
150 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
151 handle_t BindingHandle;
152 NET_API_STATUS status;
153
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);
157
158 /* FIXME */
159 BindingHandle = NULL;
160 EncryptedPassword = NULL;
161
162 RpcTryExcept
163 {
164 status = NetrAddAlternateComputerName(BindingHandle,
165 (PWSTR)Server,
166 (PWSTR)AlternateName,
167 (PWSTR)DomainAccount,
168 EncryptedPassword,
169 Reserved);
170 }
171 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
172 {
173 status = I_RpcMapWin32Status(RpcExceptionCode());
174 }
175 RpcEndExcept;
176
177 return status;
178 }
179
180
181 #if 0
182 NET_API_STATUS
183 WINAPI
184 NetGetJoinInformation(
185 LPCWSTR Server,
186 LPWSTR *Name,
187 PNETSETUP_JOIN_STATUS type)
188 {
189 NET_API_STATUS status;
190
191 TRACE("NetGetJoinInformation(%s %p %p)\n", debugstr_w(Server),
192 Name, type);
193
194 if (Name == NULL || type == NULL)
195 return ERROR_INVALID_PARAMETER;
196
197 RpcTryExcept
198 {
199 status = NetrGetJoinInformation((LPWSTR)Server,
200 Name,
201 type);
202 }
203 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
204 {
205 status = I_RpcMapWin32Status(RpcExceptionCode());
206 }
207 RpcEndExcept;
208
209 return status;
210 }
211 #endif
212
213
214 NET_API_STATUS
215 WINAPI
216 NetJoinDomain(
217 _In_ LPCWSTR lpServer,
218 _In_ LPCWSTR lpDomain,
219 _In_ LPCWSTR lpAccountOU,
220 _In_ LPCWSTR lpAccount,
221 _In_ LPCWSTR lpPassword,
222 _In_ DWORD fJoinOptions)
223 {
224 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
225 handle_t BindingHandle;
226 NET_API_STATUS status;
227
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);
231
232 /* FIXME */
233 BindingHandle = NULL;
234 EncryptedPassword = NULL;
235
236 RpcTryExcept
237 {
238 status = NetrJoinDomain2(BindingHandle,
239 (PWSTR)lpServer,
240 (PWSTR)lpDomain,
241 (PWSTR)lpAccountOU,
242 (PWSTR)lpAccount,
243 EncryptedPassword,
244 fJoinOptions);
245 }
246 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
247 {
248 status = I_RpcMapWin32Status(RpcExceptionCode());
249 }
250 RpcEndExcept;
251
252 return status;
253 }
254
255
256 NET_API_STATUS
257 WINAPI
258 NetRemoveAlternateComputerName(
259 _In_opt_ LPCWSTR Server,
260 _In_ LPCWSTR AlternateName,
261 _In_opt_ LPCWSTR DomainAccount,
262 _In_opt_ LPCWSTR DomainAccountPassword,
263 _In_ ULONG Reserved)
264 {
265 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
266 handle_t BindingHandle;
267 NET_API_STATUS status;
268
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);
272
273 /* FIXME */
274 BindingHandle = NULL;
275 EncryptedPassword = NULL;
276
277 RpcTryExcept
278 {
279 status = NetrRemoveAlternateComputerName(BindingHandle,
280 (PWSTR)Server,
281 (PWSTR)AlternateName,
282 (PWSTR)DomainAccount,
283 EncryptedPassword,
284 Reserved);
285 }
286 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
287 {
288 status = I_RpcMapWin32Status(RpcExceptionCode());
289 }
290 RpcEndExcept;
291
292 return status;
293 }
294
295
296 NET_API_STATUS
297 WINAPI
298 NetRenameMachineInDomain(
299 _In_ LPCWSTR lpServer,
300 _In_ LPCWSTR lpNewMachineName,
301 _In_ LPCWSTR lpAccount,
302 _In_ LPCWSTR lpPassword,
303 _In_ DWORD fRenameOptions)
304 {
305 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
306 handle_t BindingHandle;
307 NET_API_STATUS status;
308
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);
312
313 /* FIXME */
314 BindingHandle = NULL;
315 EncryptedPassword = NULL;
316
317 RpcTryExcept
318 {
319 status = NetrRenameMachineInDomain2(BindingHandle,
320 (PWSTR)lpServer,
321 (PWSTR)lpNewMachineName,
322 (PWSTR)lpAccount,
323 EncryptedPassword,
324 fRenameOptions);
325 }
326 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
327 {
328 status = I_RpcMapWin32Status(RpcExceptionCode());
329 }
330 RpcEndExcept;
331
332 return status;
333 }
334
335
336 NET_API_STATUS
337 WINAPI
338 NetSetPrimaryComputerName(
339 _In_opt_ LPCWSTR Server,
340 _In_ LPCWSTR PrimaryName,
341 _In_opt_ LPCWSTR DomainAccount,
342 _In_opt_ LPCWSTR DomainAccountPassword,
343 _In_ ULONG Reserved)
344 {
345 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
346 handle_t BindingHandle;
347 NET_API_STATUS status;
348
349 TRACE("NetSetPrimaryComputerName(%s %s %s %s %lu)\n",
350 debugstr_w(Server), debugstr_w(PrimaryName), debugstr_w(DomainAccount),
351 debugstr_w(DomainAccountPassword), Reserved);
352
353 /* FIXME */
354 BindingHandle = NULL;
355 EncryptedPassword = NULL;
356
357 RpcTryExcept
358 {
359 status = NetrSetPrimaryComputerName(BindingHandle,
360 (PWSTR)Server,
361 (PWSTR)PrimaryName,
362 (PWSTR)DomainAccount,
363 EncryptedPassword,
364 Reserved);
365 }
366 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
367 {
368 status = I_RpcMapWin32Status(RpcExceptionCode());
369 }
370 RpcEndExcept;
371
372 return status;
373 }
374
375
376 NET_API_STATUS
377 WINAPI
378 NetUnjoinDomain(
379 _In_ LPCWSTR lpServer,
380 _In_ LPCWSTR lpAccount,
381 _In_ LPCWSTR lpPassword,
382 _In_ DWORD fUnjoinOptions)
383 {
384 PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword;
385 handle_t BindingHandle;
386 NET_API_STATUS status;
387
388 TRACE("NetUnjoinDomain(%s %s %s %s 0x%lx)\n",
389 debugstr_w(lpServer), debugstr_w(lpAccount),
390 debugstr_w(lpPassword), fUnjoinOptions);
391
392 /* FIXME */
393 BindingHandle = NULL;
394 EncryptedPassword = NULL;
395
396 RpcTryExcept
397 {
398 status = NetrUnjoinDomain2(BindingHandle,
399 (PWSTR)lpServer,
400 (PWSTR)lpAccount,
401 EncryptedPassword,
402 fUnjoinOptions);
403 }
404 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
405 {
406 status = I_RpcMapWin32Status(RpcExceptionCode());
407 }
408 RpcEndExcept;
409
410 return status;
411 }
412
413
414 NET_API_STATUS
415 WINAPI
416 NetUseAdd(
417 LMSTR UncServerName,
418 DWORD Level,
419 LPBYTE Buf,
420 LPDWORD ParmError)
421 {
422 NET_API_STATUS status;
423
424 TRACE("NetUseAdd(%s %d %p %p)\n", debugstr_w(UncServerName),
425 Level, Buf, ParmError);
426
427 RpcTryExcept
428 {
429 status = NetrUseAdd(UncServerName,
430 Level,
431 (LPUSE_INFO)Buf,
432 ParmError);
433 }
434 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
435 {
436 status = I_RpcMapWin32Status(RpcExceptionCode());
437 }
438 RpcEndExcept;
439
440 return status;
441 }
442
443
444 NET_API_STATUS
445 WINAPI
446 NetUseDel(
447 LMSTR UncServerName,
448 LMSTR UseName,
449 DWORD ForceCond)
450 {
451 NET_API_STATUS status;
452
453 TRACE("NetUseDel(%s %s %d)\n", debugstr_w(UncServerName),
454 debugstr_w(UseName), ForceCond);
455
456 RpcTryExcept
457 {
458 status = NetrUseDel(UncServerName,
459 UseName,
460 ForceCond);
461 }
462 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
463 {
464 status = I_RpcMapWin32Status(RpcExceptionCode());
465 }
466 RpcEndExcept;
467
468 return status;
469 }
470
471
472 NET_API_STATUS
473 WINAPI
474 NetUseEnum(
475 LMSTR UncServerName,
476 DWORD Level,
477 LPBYTE *BufPtr,
478 DWORD PreferedMaximumSize,
479 LPDWORD EntriesRead,
480 LPDWORD TotalEntries,
481 LPDWORD ResumeHandle)
482 {
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;
488
489 TRACE("NetUseEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(UncServerName),
490 Level, BufPtr, PreferedMaximumSize, EntriesRead, TotalEntries, ResumeHandle);
491
492 UseEnumInfo.Level = Level;
493 switch (Level)
494 {
495 case 0:
496 UseEnumInfo.UseInfo.Level0 = &Container0;
497 Container0.EntriesRead = 0;
498 Container0.Buffer = NULL;
499 break;
500
501 case 1:
502 UseEnumInfo.UseInfo.Level1 = &Container1;
503 Container1.EntriesRead = 0;
504 Container1.Buffer = NULL;
505 break;
506
507 case 2:
508 UseEnumInfo.UseInfo.Level2 = &Container2;
509 Container2.EntriesRead = 0;
510 Container2.Buffer = NULL;
511 break;
512
513 default:
514 return ERROR_INVALID_PARAMETER;
515 }
516
517 RpcTryExcept
518 {
519 status = NetrUseEnum(UncServerName,
520 &UseEnumInfo,
521 PreferedMaximumSize,
522 TotalEntries,
523 ResumeHandle);
524 if (status == NERR_Success || status == ERROR_MORE_DATA)
525 {
526 switch (Level)
527 {
528 case 0:
529 *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level0->Buffer;
530 *EntriesRead = UseEnumInfo.UseInfo.Level0->EntriesRead;
531 break;
532
533 case 1:
534 *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level1->Buffer;
535 *EntriesRead = UseEnumInfo.UseInfo.Level1->EntriesRead;
536 break;
537
538 case 2:
539 *BufPtr = (LPBYTE)UseEnumInfo.UseInfo.Level2->Buffer;
540 *EntriesRead = UseEnumInfo.UseInfo.Level2->EntriesRead;
541 break;
542 }
543 }
544 }
545 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
546 {
547 status = I_RpcMapWin32Status(RpcExceptionCode());
548 }
549 RpcEndExcept;
550
551 return status;
552 }
553
554
555 NET_API_STATUS
556 WINAPI
557 NetUseGetInfo(
558 LMSTR UncServerName,
559 LMSTR UseName,
560 DWORD Level,
561 LPBYTE *BufPtr)
562 {
563 NET_API_STATUS status;
564
565 TRACE("NetUseGetInfo(%s, %s, %d, %p)\n", debugstr_w(UncServerName),
566 debugstr_w(UseName), Level, BufPtr);
567
568 *BufPtr = NULL;
569
570 RpcTryExcept
571 {
572 status = NetrUseGetInfo(UncServerName,
573 UseName,
574 Level,
575 (LPUSE_INFO)BufPtr);
576 }
577 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
578 {
579 status = I_RpcMapWin32Status(RpcExceptionCode());
580 }
581 RpcEndExcept;
582
583 return status;
584 }
585
586
587 #if 0
588 NET_API_STATUS
589 WINAPI
590 NetWkstaGetInfo(
591 LPWSTR servername,
592 DWORD level,
593 LPBYTE *bufptr)
594 {
595 NET_API_STATUS status;
596
597 TRACE("NetWkstaGetInfo(%s, %d, %p)\n", debugstr_w(servername),
598 level, bufptr);
599
600 if (bufptr == NULL)
601 return ERROR_INVALID_PARAMETER;
602
603 *bufptr = NULL;
604
605 RpcTryExcept
606 {
607 status = NetrWkstaGetInfo(servername,
608 level,
609 (LPWKSTA_INFO)bufptr);
610 }
611 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
612 {
613 status = I_RpcMapWin32Status(RpcExceptionCode());
614 }
615 RpcEndExcept;
616
617 return status;
618 }
619 #endif
620
621
622 NET_API_STATUS
623 WINAPI
624 NetWkstaSetInfo(
625 LPWSTR servername,
626 DWORD level,
627 LPBYTE buffer,
628 LPDWORD parm_err)
629 {
630 NET_API_STATUS status;
631
632 TRACE("NetWkstaSetInfo(%s, %d, %p, %p)\n", debugstr_w(servername),
633 level, buffer, parm_err);
634
635 RpcTryExcept
636 {
637 status = NetrWkstaSetInfo(servername,
638 level,
639 (LPWKSTA_INFO)buffer,
640 parm_err);
641 }
642 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
643 {
644 status = I_RpcMapWin32Status(RpcExceptionCode());
645 }
646 RpcEndExcept;
647
648 return status;
649 }
650
651
652 NET_API_STATUS
653 WINAPI
654 NetWkstaTransportAdd(
655 LPWSTR servername,
656 DWORD level,
657 LPBYTE buf,
658 LPDWORD parm_err)
659 {
660 NET_API_STATUS status;
661
662 TRACE("NetWkstaTransportAdd(%s, %d, %p, %p)\n", debugstr_w(servername),
663 level, buf, parm_err);
664
665 RpcTryExcept
666 {
667 status = NetrWkstaTransportAdd(servername,
668 level,
669 (LPWKSTA_TRANSPORT_INFO_0)buf,
670 parm_err);
671 }
672 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
673 {
674 status = I_RpcMapWin32Status(RpcExceptionCode());
675 }
676 RpcEndExcept;
677
678 return status;
679 }
680
681
682 NET_API_STATUS
683 WINAPI
684 NetWkstaTransportDel(
685 LPWSTR servername,
686 LPWSTR transportname,
687 DWORD ucond)
688 {
689 NET_API_STATUS status;
690
691 TRACE("NetWkstaTransportDel(%s, %s, %d)\n", debugstr_w(servername),
692 debugstr_w(transportname), ucond);
693
694 RpcTryExcept
695 {
696 status = NetrWkstaTransportDel(servername,
697 transportname,
698 ucond);
699 }
700 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
701 {
702 status = I_RpcMapWin32Status(RpcExceptionCode());
703 }
704 RpcEndExcept;
705
706 return status;
707 }
708
709
710 #if 0
711 NET_API_STATUS
712 WINAPI
713 NetWkstaTransportEnum(
714 LPWSTR servername,
715 DWORD level,
716 LPBYTE *bufptr,
717 DWORD prefmaxlen,
718 LPDWORD entriesread,
719 LPDWORD totalentries,
720 LPDWORD resumehandle)
721 {
722 WKSTA_TRANSPORT_ENUM_STRUCT TransportEnumInfo;
723 WKSTA_TRANSPORT_INFO_0_CONTAINER Container0;
724 NET_API_STATUS status;
725
726 TRACE("NetWkstaTransportEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername),
727 level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle);
728
729 TransportEnumInfo.Level = level;
730 switch (level)
731 {
732 case 0:
733 TransportEnumInfo.WkstaTransportInfo.Level0 = &Container0;
734 Container0.EntriesRead = 0;
735 Container0.Buffer = NULL;
736 break;
737
738 default:
739 return ERROR_INVALID_PARAMETER;
740 }
741
742 RpcTryExcept
743 {
744 status = NetrWkstaTransportEnum(servername,
745 &TransportEnumInfo,
746 prefmaxlen,
747 totalentries,
748 resumehandle);
749 if (status == NERR_Success || status == ERROR_MORE_DATA)
750 {
751 switch (level)
752 {
753 case 0:
754 *bufptr = (LPBYTE)TransportEnumInfo.WkstaTransportInfo.Level0->Buffer;
755 *entriesread = TransportEnumInfo.WkstaTransportInfo.Level0->EntriesRead;
756 break;
757 }
758 }
759 }
760 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
761 {
762 status = I_RpcMapWin32Status(RpcExceptionCode());
763 }
764 RpcEndExcept;
765
766 return status;
767 }
768
769
770 NET_API_STATUS
771 WINAPI
772 NetWkstaUserEnum(
773 LPWSTR servername,
774 DWORD level,
775 LPBYTE *bufptr,
776 DWORD prefmaxlen,
777 LPDWORD entriesread,
778 LPDWORD totalentries,
779 LPDWORD resumehandle)
780 {
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;
785
786 TRACE("NetWkstaUserEnum(%s, %d, %p, %d, %p, %p, %p)\n", debugstr_w(servername),
787 level, bufptr, prefmaxlen, entriesread, totalentries, resumehandle);
788
789 UserEnumInfo.Level = level;
790 switch (level)
791 {
792 case 0:
793 UserEnumInfo.WkstaUserInfo.Level0 = &Container0;
794 Container0.EntriesRead = 0;
795 Container0.Buffer = NULL;
796 break;
797
798 case 1:
799 UserEnumInfo.WkstaUserInfo.Level1 = &Container1;
800 Container1.EntriesRead = 0;
801 Container1.Buffer = NULL;
802 break;
803
804 default:
805 return ERROR_INVALID_PARAMETER;
806 }
807
808 RpcTryExcept
809 {
810 status = NetrWkstaUserEnum(servername,
811 &UserEnumInfo,
812 prefmaxlen,
813 totalentries,
814 resumehandle);
815 if (status == NERR_Success || status == ERROR_MORE_DATA)
816 {
817 switch (level)
818 {
819 case 0:
820 *bufptr = (LPBYTE)UserEnumInfo.WkstaUserInfo.Level0->Buffer;
821 *entriesread = UserEnumInfo.WkstaUserInfo.Level0->EntriesRead;
822 break;
823
824 case 1:
825 *bufptr = (LPBYTE)UserEnumInfo.WkstaUserInfo.Level1->Buffer;
826 *entriesread = UserEnumInfo.WkstaUserInfo.Level1->EntriesRead;
827 break;
828 }
829 }
830 }
831 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
832 {
833 status = I_RpcMapWin32Status(RpcExceptionCode());
834 }
835 RpcEndExcept;
836
837 return status;
838 }
839
840
841 NET_API_STATUS
842 WINAPI
843 NetWkstaUserGetInfo(
844 LPWSTR reserved,
845 DWORD level,
846 PBYTE *bufptr)
847 {
848 NET_API_STATUS status;
849
850 TRACE("NetWkstaUserGetInfo(%s, %d, %p)\n", debugstr_w(reserved),
851 level, bufptr);
852
853 if (reserved != NULL)
854 return ERROR_INVALID_PARAMETER;
855
856 *bufptr = NULL;
857
858 RpcTryExcept
859 {
860 status = NetrWkstaUserGetInfo(NULL,
861 level,
862 (LPWKSTA_USER_INFO)bufptr);
863 }
864 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
865 {
866 status = I_RpcMapWin32Status(RpcExceptionCode());
867 }
868 RpcEndExcept;
869
870 return status;
871 }
872 #endif
873
874
875 NET_API_STATUS
876 WINAPI
877 NetWkstaUserSetInfo(
878 LPWSTR reserved,
879 DWORD level,
880 LPBYTE buf,
881 LPDWORD parm_err)
882 {
883 NET_API_STATUS status;
884
885 TRACE("NetWkstaSetInfo(%s, %d, %p, %p)\n", debugstr_w(reserved),
886 level, buf, parm_err);
887
888 if (reserved != NULL)
889 return ERROR_INVALID_PARAMETER;
890
891 RpcTryExcept
892 {
893 status = NetrWkstaUserSetInfo(NULL,
894 level,
895 (LPWKSTA_USER_INFO)&buf,
896 parm_err);
897 }
898 RpcExcept(EXCEPTION_EXECUTE_HANDLER)
899 {
900 status = I_RpcMapWin32Status(RpcExceptionCode());
901 }
902 RpcEndExcept;
903
904 return status;
905 }
906
907 /* EOF */