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