xref: /reactos/dll/win32/netapi32/misc.c (revision c2c66aff)
1 /*
2  * PROJECT:     NetAPI DLL
3  * LICENSE:     GPL-2.0 (https://spdx.org/licenses/GPL-2.0)
4  * PURPOSE:     Miscellaneous functions
5  * COPYRIGHT:   Copyright 2017 Eric Kohl (eric.kohl@reactos.org)
6  */
7 
8 /* INCLUDES ******************************************************************/
9 
10 #include "netapi32.h"
11 
12 #include <rpc.h>
13 #include "srvsvc_c.h"
14 #include "wkssvc_c.h"
15 
16 
17 WINE_DEFAULT_DEBUG_CHANNEL(netapi32);
18 
19 /* FUNCTIONS *****************************************************************/
20 
21 NET_API_STATUS
22 WINAPI
23 NetStatisticsGet(
24     _In_ LPWSTR server,
25     _In_ LPWSTR service,
26     _In_ DWORD level,
27     _In_ DWORD options,
28     _Out_ LPBYTE *bufptr)
29 {
30     NET_API_STATUS status = ERROR_NOT_SUPPORTED;
31 
32     TRACE("NetStatisticsGet(%s %s %lu %lu %p)\n",
33           debugstr_w(server), debugstr_w(service), level, options, bufptr);
34 
35     *bufptr = NULL;
36 
37     if (_wcsicmp(service, L"LanmanWorkstation") == 0)
38     {
39         if (level != 0)
40             return ERROR_INVALID_LEVEL;
41 
42         if (options != 0)
43             return ERROR_INVALID_PARAMETER;
44 
45         RpcTryExcept
46         {
47             status = NetrWorkstationStatisticsGet(server,
48                                                   L"LanmanWorkstation",
49                                                   level,
50                                                   options,
51                                                   (LPSTAT_WORKSTATION_0*)bufptr);
52         }
53         RpcExcept(EXCEPTION_EXECUTE_HANDLER)
54         {
55             status = I_RpcMapWin32Status(RpcExceptionCode());
56         }
57         RpcEndExcept;
58     }
59     else if (_wcsicmp(service, L"LanmanServer") == 0)
60     {
61         if (level != 0)
62             return ERROR_INVALID_LEVEL;
63 
64         if (options != 0)
65             return ERROR_INVALID_PARAMETER;
66 
67         RpcTryExcept
68         {
69             status = NetrServerStatisticsGet(server,
70                                              L"LanmanServer",
71                                              level,
72                                              options,
73                                              (LPSTAT_SERVER_0 *)bufptr);
74         }
75         RpcExcept(EXCEPTION_EXECUTE_HANDLER)
76         {
77             status = I_RpcMapWin32Status(RpcExceptionCode());
78         }
79         RpcEndExcept;
80     }
81 
82     return status;
83 }
84 
85 
86 NET_API_STATUS
87 WINAPI
88 NetpNtStatusToApiStatus(
89     _In_ NTSTATUS Status)
90 {
91     NET_API_STATUS ApiStatus;
92 
93     switch (Status)
94     {
95         case STATUS_SUCCESS:
96             ApiStatus = NERR_Success;
97             break;
98 
99         case STATUS_INVALID_ACCOUNT_NAME:
100             ApiStatus = NERR_BadUsername;
101             break;
102 
103         case STATUS_PASSWORD_RESTRICTION:
104             ApiStatus = NERR_PasswordTooShort;
105             break;
106 
107         default:
108             ApiStatus = RtlNtStatusToDosError(Status);
109             break;
110     }
111 
112     return ApiStatus;
113 }
114 
115 /* EOF */
116