Windows: Add support for NetWkstaGetInfo levels 101 and 102
[openafs.git] / src / WINNT / afsd / rpc_wkssvc.c
1 /*
2  * Copyright (c) 2009 Secure Endpoints Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person
5  * obtaining a copy of this software and associated documentation
6  * files (the "Software"), to deal in the Software without
7  * restriction, including without limitation the rights to use, copy,
8  * modify, merge, publish, distribute, sublicense, and/or sell copies
9  * of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24
25 #include <windows.h>
26 #include <lmcons.h>
27 #include <stdlib.h>
28 #include "afsd.h"
29 #include "ms-wkssvc.h"
30 #include "AFS_component_version_number.h"
31
32 #define PLATFORM_ID_AFS 800
33
34 #pragma warning( disable: 4027 )  /* func w/o formal parameter list */
35
36 unsigned long NetrWkstaGetInfo(
37     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
38     /* [in] */ unsigned long Level,
39     /* [switch_is][out] */ LPWKSTA_INFO WkstaInfo)
40 {
41     wchar_t *s;
42
43     osi_Log1(afsd_logp, "NetrWkstaGetInfo level %u", Level);
44
45     /*
46      * How much space do we need and do we have that much room?
47      * For now, just assume we can return everything in one shot
48      * because the reality is that in this function call we do
49      * not know the max size of the RPC response.
50      */
51     switch (Level) {
52     case 102:
53         WkstaInfo->WkstaInfo102 = calloc(1, sizeof(WKSTA_INFO_102));
54         break;
55     case 101:
56         WkstaInfo->WkstaInfo101 = calloc(1, sizeof(WKSTA_INFO_101));
57         break;
58     case 100:
59         WkstaInfo->WkstaInfo100 = calloc(1, sizeof(WKSTA_INFO_100));
60         break;
61     }
62
63     if (WkstaInfo->WkstaInfo100 == NULL) {
64         return ERROR_INVALID_LEVEL;
65     }
66
67     /*
68      * Remove any leading slashes since they are not part of the
69      * server name.
70      */
71     for ( s=ServerName; *s == '\\' || *s == '/'; s++);
72
73     switch (Level) {
74     case 102:
75         WkstaInfo->WkstaInfo102->wki102_logged_on_users = 0;
76     case 101:
77         WkstaInfo->WkstaInfo101->wki101_lanroot = NULL;
78     case  100:
79         WkstaInfo->WkstaInfo100->wki100_computername = _wcsupr(wcsdup(s));
80         WkstaInfo->WkstaInfo100->wki100_langroup = _wcsdup(L"AFS");
81         WkstaInfo->WkstaInfo100->wki100_platform_id = PLATFORM_ID_AFS;
82         WkstaInfo->WkstaInfo100->wki100_ver_major = AFSPRODUCT_VERSION_MAJOR;
83         WkstaInfo->WkstaInfo100->wki100_ver_minor = AFSPRODUCT_VERSION_MINOR;
84         return 0;
85     case  502:
86     case 1013:
87     case 1018:
88     case 1046:
89     default:
90         return ERROR_INVALID_LEVEL;
91     }
92 }
93
94 unsigned long NetrWkstaSetInfo(
95     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
96     /* [in] */ unsigned long Level,
97     /* [switch_is][in] */ LPWKSTA_INFO WkstaInfo,
98     /* [unique][out][in] */ unsigned long *ErrorParameter)
99 {
100     osi_Log0(afsd_logp, "NetrWkstaSetInfo not supported");
101     return ERROR_NOT_SUPPORTED;
102 }
103
104 unsigned long NetrWkstaUserEnum(
105     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
106     /* [out][in] */ LPWKSTA_USER_ENUM_STRUCT UserInfo,
107     /* [in] */ unsigned long PreferredMaximumLength,
108     /* [out] */ unsigned long *TotalEntries,
109     /* [unique][out][in] */ unsigned long *ResumeHandle)
110 {
111     osi_Log0(afsd_logp, "NetrWkstaUserEnum not supported");
112     return ERROR_NOT_SUPPORTED;
113 }
114
115 unsigned long NetrWkstaTransportEnum(
116     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
117     /* [out][in] */ LPWKSTA_TRANSPORT_ENUM_STRUCT TransportInfo,
118     /* [in] */ unsigned long PreferredMaximumLength,
119     /* [out] */ unsigned long *TotalEntries,
120     /* [unique][out][in] */ unsigned long *ResumeHandle)
121 {
122     osi_Log0(afsd_logp, "NetrWkstaTransportEnum not supported");
123     return ERROR_NOT_SUPPORTED;
124 }
125
126 unsigned long NetrWkstaTransportAdd(
127     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
128     /* [in] */ unsigned long Level,
129     /* [in] */ LPWKSTA_TRANSPORT_INFO_0 TransportInfo,
130     /* [unique][out][in] */ unsigned long *ErrorParameter)
131 {
132     osi_Log0(afsd_logp, "NetrWkstaTransportAdd not supported");
133     return ERROR_NOT_SUPPORTED;
134 }
135
136 unsigned long NetrWkstaTransportDel(
137     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
138     /* [unique][string][in] */ wchar_t *TransportName,
139     /* [in] */ unsigned long ForceLevel)
140 {
141     osi_Log0(afsd_logp, "NetrWkstaTransportDel not supported");
142     return ERROR_NOT_SUPPORTED;
143 }
144
145 unsigned long NetrWorkstationStatisticsGet(
146     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
147     /* [unique][string][in] */ wchar_t *ServiceName,
148     /* [in] */ unsigned long Level,
149     /* [in] */ unsigned long Options,
150     /* [out] */ LPSTAT_WORKSTATION_0 *Buffer)
151 {
152     osi_Log0(afsd_logp, "NetrWorkstationStatisticsGet not supported");
153     return ERROR_NOT_SUPPORTED;
154 }
155
156 unsigned long NetrGetJoinInformation(
157     /* [unique][string][in] */ WKSSVC_IMPERSONATE_HANDLE ServerName,
158     /* [string][out][in] */ wchar_t **NameBuffer,
159     /* [out] */ PNETSETUP_JOIN_STATUS BufferType)
160 {
161     osi_Log0(afsd_logp, "NetrGetJoinInformation not supported");
162     return ERROR_NOT_SUPPORTED;
163 }
164
165 unsigned long NetrJoinDomain2(
166     /* [in] */ handle_t RpcBindingHandle,
167     /* [unique][string][in] */ wchar_t *ServerName,
168     /* [string][in] */ wchar_t *DomainName,
169     /* [unique][string][in] */ wchar_t *MachineAccountOU,
170     /* [unique][string][in] */ wchar_t *AccountName,
171     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD Password,
172     /* [in] */ unsigned long Options)
173 {
174     osi_Log0(afsd_logp, "NetrJoinDomain2 not supported");
175     return ERROR_NOT_SUPPORTED;
176 }
177
178 unsigned long NetrUnjoinDomain2(
179     /* [in] */ handle_t RpcBindingHandle,
180     /* [unique][string][in] */ wchar_t *ServerName,
181     /* [unique][string][in] */ wchar_t *AccountName,
182     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD Password,
183     /* [in] */ unsigned long Options)
184 {
185     osi_Log0(afsd_logp, "NetrUnjoinDomain2 not supported");
186     return ERROR_NOT_SUPPORTED;
187 }
188
189 unsigned long NetrRenameMachineInDomain2(
190     /* [in] */ handle_t RpcBindingHandle,
191     /* [unique][string][in] */ wchar_t *ServerName,
192     /* [unique][string][in] */ wchar_t *MachineName,
193     /* [unique][string][in] */ wchar_t *AccountName,
194     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD Password,
195     /* [in] */ unsigned long Options)
196 {
197     osi_Log0(afsd_logp, "NetrRenameMachineInDomain2 not supported");
198     return ERROR_NOT_SUPPORTED;
199 }
200
201 unsigned long NetrValidateName2(
202     /* [in] */ handle_t RpcBindingHandle,
203     /* [unique][string][in] */ wchar_t *ServerName,
204     /* [string][in] */ wchar_t *NameToValidate,
205     /* [unique][string][in] */ wchar_t *AccountName,
206     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD Password,
207     /* [in] */ NETSETUP_NAME_TYPE NameType)
208 {
209     osi_Log0(afsd_logp, "NetrValidateName2 not supported");
210     return ERROR_NOT_SUPPORTED;
211 }
212
213 unsigned long NetrGetJoinableOUs2(
214     /* [in] */ handle_t RpcBindingHandle,
215     /* [unique][string][in] */ wchar_t *ServerName,
216     /* [string][in] */ wchar_t *DomainName,
217     /* [unique][string][in] */ wchar_t *AccountName,
218     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD Password,
219     /* [out][in] */ unsigned long *OUCount,
220     /* [size_is][size_is][string][out] */ wchar_t ***OUs)
221 {
222     osi_Log0(afsd_logp, "NetrGetJoinableOUs2 not supported");
223     return ERROR_NOT_SUPPORTED;
224 }
225
226 unsigned long NetrAddAlternateComputerName(
227     /* [in] */ handle_t RpcBindingHandle,
228     /* [unique][string][in] */ wchar_t *ServerName,
229     /* [unique][string][in] */ wchar_t *AlternateName,
230     /* [unique][string][in] */ wchar_t *DomainAccount,
231     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword,
232     /* [in] */ unsigned long Reserved)
233 {
234     osi_Log0(afsd_logp, "NetrAddAlternateComputerName not supported");
235     return ERROR_NOT_SUPPORTED;
236 }
237
238 unsigned long NetrRemoveAlternateComputerName(
239     /* [in] */ handle_t RpcBindingHandle,
240     /* [unique][string][in] */ wchar_t *ServerName,
241     /* [unique][string][in] */ wchar_t *AlternateName,
242     /* [unique][string][in] */ wchar_t *DomainAccount,
243     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword,
244     /* [in] */ unsigned long Reserved)
245 {
246     osi_Log0(afsd_logp, "NetrRemoveAlternateComputerName not supported");
247     return ERROR_NOT_SUPPORTED;
248 }
249
250 unsigned long NetrSetPrimaryComputerName(
251     /* [in] */ handle_t RpcBindingHandle,
252     /* [unique][string][in] */ wchar_t *ServerName,
253     /* [unique][string][in] */ wchar_t *PrimaryName,
254     /* [unique][string][in] */ wchar_t *DomainAccount,
255     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword,
256     /* [in] */ unsigned long Reserved)
257 {
258     osi_Log0(afsd_logp, "NetrSetPrimaryComputerName not supported");
259     return ERROR_NOT_SUPPORTED;
260 }
261
262 unsigned long NetrEnumerateComputerNames(
263     /* [unique][string][in] */ WKSSVC_IMPERSONATE_HANDLE ServerName,
264     /* [in] */ NET_COMPUTER_NAME_TYPE NameType,
265     /* [in] */ unsigned long Reserved,
266     /* [out] */ PNET_COMPUTER_NAME_ARRAY *ComputerNames)
267 {
268     osi_Log0(afsd_logp, "NetrEnumerateComputerName not supported");
269     return ERROR_NOT_SUPPORTED;
270 }
271
272 /* [nocode] */ void Opnum3NotUsedOnWire(
273     /* [in] */ handle_t IDL_handle)
274 {
275 }
276
277 /* [nocode] */ void Opnum4NotUsedOnWire(
278     /* [in] */ handle_t IDL_handle)
279 {
280 }
281
282 /* [nocode] */ void Opnum8NotUsedOnWire(
283     /* [in] */ handle_t IDL_handle)
284 {
285 }
286
287 /* [nocode] */ void Opnum9NotUsedOnWire(
288     /* [in] */ handle_t IDL_handle)
289 {
290 }
291
292 /* [nocode] */ void Opnum10NotUsedOnWire(
293     /* [in] */ handle_t IDL_handle)
294 {
295 }
296
297 /* [nocode] */ void Opnum11NotUsedOnWire(
298     /* [in] */ handle_t IDL_handle)
299 {
300 }
301
302 /* [nocode] */ void Opnum12NotUsedOnWire(
303     /* [in] */ handle_t IDL_handle)
304 {
305 }
306
307
308 /* [nocode] */ void Opnum14NotUsedOnWire(
309     /* [in] */ handle_t IDL_handle)
310 {
311 }
312
313 /* [nocode] */ void Opnum15NotUsedOnWire(
314     /* [in] */ handle_t IDL_handle)
315 {
316 }
317
318 /* [nocode] */ void Opnum16NotUsedOnWire(
319     /* [in] */ handle_t IDL_handle)
320 {
321 }
322
323 /* [nocode] */ void Opnum17NotUsedOnWire(
324     /* [in] */ handle_t IDL_handle)
325 {
326 }
327
328 /* [nocode] */ void Opnum18NotUsedOnWire(
329     /* [in] */ handle_t IDL_handle)
330 {
331 }
332
333 /* [nocode] */ void Opnum19NotUsedOnWire(
334     /* [in] */ handle_t IDL_handle)
335 {
336 }
337
338
339 /* [nocode] */ void Opnum21NotUsedOnWire(
340     /* [in] */ handle_t IDL_handle)
341 {
342 }
343