Windows: Improve WKSSRC and SRVSVC compatibility with Windows
[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 100:
53         WkstaInfo->WkstaInfo100 = calloc(1, sizeof(WKSTA_INFO_100));
54         break;
55     }
56
57     if (WkstaInfo->WkstaInfo100 == NULL) {
58         return ERROR_NOT_ENOUGH_MEMORY;
59     }
60
61     /*
62      * Remove any leading slashes since they are not part of the
63      * server name.
64      */
65     for ( s=ServerName; *s == '\\' || *s == '/'; s++);
66
67     switch (Level) {
68     case  100:
69         WkstaInfo->WkstaInfo100->wki100_computername = _wcsupr(wcsdup(s));
70         WkstaInfo->WkstaInfo100->wki100_langroup = _wcsdup(L"AFS");
71         WkstaInfo->WkstaInfo100->wki100_platform_id = PLATFORM_ID_AFS;
72         WkstaInfo->WkstaInfo100->wki100_ver_major = AFSPRODUCT_VERSION_MAJOR;
73         WkstaInfo->WkstaInfo100->wki100_ver_minor = AFSPRODUCT_VERSION_MINOR;
74         return 0;
75     case  502:
76     case 1013:
77     case 1018:
78     case 1046:
79     default:
80         return ERROR_INVALID_LEVEL;
81     }
82 }
83
84 unsigned long NetrWkstaSetInfo(
85     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
86     /* [in] */ unsigned long Level,
87     /* [switch_is][in] */ LPWKSTA_INFO WkstaInfo,
88     /* [unique][out][in] */ unsigned long *ErrorParameter)
89 {
90     osi_Log0(afsd_logp, "NetrWkstaSetInfo not supported");
91     return ERROR_NOT_SUPPORTED;
92 }
93
94 unsigned long NetrWkstaUserEnum(
95     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
96     /* [out][in] */ LPWKSTA_USER_ENUM_STRUCT UserInfo,
97     /* [in] */ unsigned long PreferredMaximumLength,
98     /* [out] */ unsigned long *TotalEntries,
99     /* [unique][out][in] */ unsigned long *ResumeHandle)
100 {
101     osi_Log0(afsd_logp, "NetrWkstaUserEnum not supported");
102     return ERROR_NOT_SUPPORTED;
103 }
104
105 unsigned long NetrWkstaTransportEnum(
106     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
107     /* [out][in] */ LPWKSTA_TRANSPORT_ENUM_STRUCT TransportInfo,
108     /* [in] */ unsigned long PreferredMaximumLength,
109     /* [out] */ unsigned long *TotalEntries,
110     /* [unique][out][in] */ unsigned long *ResumeHandle)
111 {
112     osi_Log0(afsd_logp, "NetrWkstaTransportEnum not supported");
113     return ERROR_NOT_SUPPORTED;
114 }
115
116 unsigned long NetrWkstaTransportAdd(
117     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
118     /* [in] */ unsigned long Level,
119     /* [in] */ LPWKSTA_TRANSPORT_INFO_0 TransportInfo,
120     /* [unique][out][in] */ unsigned long *ErrorParameter)
121 {
122     osi_Log0(afsd_logp, "NetrWkstaTransportAdd not supported");
123     return ERROR_NOT_SUPPORTED;
124 }
125
126 unsigned long NetrWkstaTransportDel(
127     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
128     /* [unique][string][in] */ wchar_t *TransportName,
129     /* [in] */ unsigned long ForceLevel)
130 {
131     osi_Log0(afsd_logp, "NetrWkstaTransportDel not supported");
132     return ERROR_NOT_SUPPORTED;
133 }
134
135 unsigned long NetrWorkstationStatisticsGet(
136     /* [unique][string][in] */ WKSSVC_IDENTIFY_HANDLE ServerName,
137     /* [unique][string][in] */ wchar_t *ServiceName,
138     /* [in] */ unsigned long Level,
139     /* [in] */ unsigned long Options,
140     /* [out] */ LPSTAT_WORKSTATION_0 *Buffer)
141 {
142     osi_Log0(afsd_logp, "NetrWorkstationStatisticsGet not supported");
143     return ERROR_NOT_SUPPORTED;
144 }
145
146 unsigned long NetrGetJoinInformation(
147     /* [unique][string][in] */ WKSSVC_IMPERSONATE_HANDLE ServerName,
148     /* [string][out][in] */ wchar_t **NameBuffer,
149     /* [out] */ PNETSETUP_JOIN_STATUS BufferType)
150 {
151     osi_Log0(afsd_logp, "NetrGetJoinInformation not supported");
152     return ERROR_NOT_SUPPORTED;
153 }
154
155 unsigned long NetrJoinDomain2(
156     /* [in] */ handle_t RpcBindingHandle,
157     /* [unique][string][in] */ wchar_t *ServerName,
158     /* [string][in] */ wchar_t *DomainName,
159     /* [unique][string][in] */ wchar_t *MachineAccountOU,
160     /* [unique][string][in] */ wchar_t *AccountName,
161     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD Password,
162     /* [in] */ unsigned long Options)
163 {
164     osi_Log0(afsd_logp, "NetrJoinDomain2 not supported");
165     return ERROR_NOT_SUPPORTED;
166 }
167
168 unsigned long NetrUnjoinDomain2(
169     /* [in] */ handle_t RpcBindingHandle,
170     /* [unique][string][in] */ wchar_t *ServerName,
171     /* [unique][string][in] */ wchar_t *AccountName,
172     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD Password,
173     /* [in] */ unsigned long Options)
174 {
175     osi_Log0(afsd_logp, "NetrUnjoinDomain2 not supported");
176     return ERROR_NOT_SUPPORTED;
177 }
178
179 unsigned long NetrRenameMachineInDomain2(
180     /* [in] */ handle_t RpcBindingHandle,
181     /* [unique][string][in] */ wchar_t *ServerName,
182     /* [unique][string][in] */ wchar_t *MachineName,
183     /* [unique][string][in] */ wchar_t *AccountName,
184     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD Password,
185     /* [in] */ unsigned long Options)
186 {
187     osi_Log0(afsd_logp, "NetrRenameMachineInDomain2 not supported");
188     return ERROR_NOT_SUPPORTED;
189 }
190
191 unsigned long NetrValidateName2(
192     /* [in] */ handle_t RpcBindingHandle,
193     /* [unique][string][in] */ wchar_t *ServerName,
194     /* [string][in] */ wchar_t *NameToValidate,
195     /* [unique][string][in] */ wchar_t *AccountName,
196     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD Password,
197     /* [in] */ NETSETUP_NAME_TYPE NameType)
198 {
199     osi_Log0(afsd_logp, "NetrValidateName2 not supported");
200     return ERROR_NOT_SUPPORTED;
201 }
202
203 unsigned long NetrGetJoinableOUs2(
204     /* [in] */ handle_t RpcBindingHandle,
205     /* [unique][string][in] */ wchar_t *ServerName,
206     /* [string][in] */ wchar_t *DomainName,
207     /* [unique][string][in] */ wchar_t *AccountName,
208     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD Password,
209     /* [out][in] */ unsigned long *OUCount,
210     /* [size_is][size_is][string][out] */ wchar_t ***OUs)
211 {
212     osi_Log0(afsd_logp, "NetrGetJoinableOUs2 not supported");
213     return ERROR_NOT_SUPPORTED;
214 }
215
216 unsigned long NetrAddAlternateComputerName(
217     /* [in] */ handle_t RpcBindingHandle,
218     /* [unique][string][in] */ wchar_t *ServerName,
219     /* [unique][string][in] */ wchar_t *AlternateName,
220     /* [unique][string][in] */ wchar_t *DomainAccount,
221     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword,
222     /* [in] */ unsigned long Reserved)
223 {
224     osi_Log0(afsd_logp, "NetrAddAlternateComputerName not supported");
225     return ERROR_NOT_SUPPORTED;
226 }
227
228 unsigned long NetrRemoveAlternateComputerName(
229     /* [in] */ handle_t RpcBindingHandle,
230     /* [unique][string][in] */ wchar_t *ServerName,
231     /* [unique][string][in] */ wchar_t *AlternateName,
232     /* [unique][string][in] */ wchar_t *DomainAccount,
233     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword,
234     /* [in] */ unsigned long Reserved)
235 {
236     osi_Log0(afsd_logp, "NetrRemoveAlternateComputerName not supported");
237     return ERROR_NOT_SUPPORTED;
238 }
239
240 unsigned long NetrSetPrimaryComputerName(
241     /* [in] */ handle_t RpcBindingHandle,
242     /* [unique][string][in] */ wchar_t *ServerName,
243     /* [unique][string][in] */ wchar_t *PrimaryName,
244     /* [unique][string][in] */ wchar_t *DomainAccount,
245     /* [unique][in] */ PJOINPR_ENCRYPTED_USER_PASSWORD EncryptedPassword,
246     /* [in] */ unsigned long Reserved)
247 {
248     osi_Log0(afsd_logp, "NetrSetPrimaryComputerName not supported");
249     return ERROR_NOT_SUPPORTED;
250 }
251
252 unsigned long NetrEnumerateComputerNames(
253     /* [unique][string][in] */ WKSSVC_IMPERSONATE_HANDLE ServerName,
254     /* [in] */ NET_COMPUTER_NAME_TYPE NameType,
255     /* [in] */ unsigned long Reserved,
256     /* [out] */ PNET_COMPUTER_NAME_ARRAY *ComputerNames)
257 {
258     osi_Log0(afsd_logp, "NetrEnumerateComputerName not supported");
259     return ERROR_NOT_SUPPORTED;
260 }
261
262 /* [nocode] */ void Opnum3NotUsedOnWire(
263     /* [in] */ handle_t IDL_handle)
264 {
265 }
266
267 /* [nocode] */ void Opnum4NotUsedOnWire(
268     /* [in] */ handle_t IDL_handle)
269 {
270 }
271
272 /* [nocode] */ void Opnum8NotUsedOnWire(
273     /* [in] */ handle_t IDL_handle)
274 {
275 }
276
277 /* [nocode] */ void Opnum9NotUsedOnWire(
278     /* [in] */ handle_t IDL_handle)
279 {
280 }
281
282 /* [nocode] */ void Opnum10NotUsedOnWire(
283     /* [in] */ handle_t IDL_handle)
284 {
285 }
286
287 /* [nocode] */ void Opnum11NotUsedOnWire(
288     /* [in] */ handle_t IDL_handle)
289 {
290 }
291
292 /* [nocode] */ void Opnum12NotUsedOnWire(
293     /* [in] */ handle_t IDL_handle)
294 {
295 }
296
297
298 /* [nocode] */ void Opnum14NotUsedOnWire(
299     /* [in] */ handle_t IDL_handle)
300 {
301 }
302
303 /* [nocode] */ void Opnum15NotUsedOnWire(
304     /* [in] */ handle_t IDL_handle)
305 {
306 }
307
308 /* [nocode] */ void Opnum16NotUsedOnWire(
309     /* [in] */ handle_t IDL_handle)
310 {
311 }
312
313 /* [nocode] */ void Opnum17NotUsedOnWire(
314     /* [in] */ handle_t IDL_handle)
315 {
316 }
317
318 /* [nocode] */ void Opnum18NotUsedOnWire(
319     /* [in] */ handle_t IDL_handle)
320 {
321 }
322
323 /* [nocode] */ void Opnum19NotUsedOnWire(
324     /* [in] */ handle_t IDL_handle)
325 {
326 }
327
328
329 /* [nocode] */ void Opnum21NotUsedOnWire(
330     /* [in] */ handle_t IDL_handle)
331 {
332 }
333