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