2 * Unix SMB/CIFS implementation.
3 * RPC Pipe client / server routines
5 * Copyright (C) Andrew Tridgell 1992-1997,
6 * Copyright (C) Gerald (Jerry) Carter 2006.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 /* This is the implementation of the wks interface. */
25 #include "libnet/libnet.h"
28 #define DBGC_CLASS DBGC_RPC_SRV
30 /*******************************************************************
31 Fill in the values for the struct wkssvc_NetWkstaInfo100.
32 ********************************************************************/
34 static void create_wks_info_100(struct wkssvc_NetWkstaInfo100
*info100
)
36 info100
->platform_id
= PLATFORM_ID_NT
; /* unknown */
37 info100
->version_major
= lp_major_announce_version();
38 info100
->version_minor
= lp_minor_announce_version();
40 info100
->server_name
= talloc_asprintf_strupper_m(
41 info100
, "%s", global_myname());
42 info100
->domain_name
= talloc_asprintf_strupper_m(
43 info100
, "%s", lp_workgroup());
48 /********************************************************************
49 only supports info level 100 at the moment.
50 ********************************************************************/
52 WERROR
_wkssvc_NetWkstaGetInfo(pipes_struct
*p
, struct wkssvc_NetWkstaGetInfo
*r
)
54 struct wkssvc_NetWkstaInfo100
*wks100
= NULL
;
56 /* We only support info level 100 currently */
58 if ( r
->in
.level
!= 100 ) {
59 return WERR_UNKNOWN_LEVEL
;
62 if ( (wks100
= TALLOC_ZERO_P(p
->mem_ctx
, struct wkssvc_NetWkstaInfo100
)) == NULL
) {
66 create_wks_info_100( wks100
);
68 r
->out
.info
->info100
= wks100
;
73 /********************************************************************
74 ********************************************************************/
76 WERROR
_wkssvc_NetWkstaSetInfo(pipes_struct
*p
, struct wkssvc_NetWkstaSetInfo
*r
)
78 /* FIXME: Add implementation code here */
79 p
->rng_fault_state
= True
;
80 return WERR_NOT_SUPPORTED
;
83 /********************************************************************
84 ********************************************************************/
86 WERROR
_wkssvc_NetWkstaEnumUsers(pipes_struct
*p
, struct wkssvc_NetWkstaEnumUsers
*r
)
88 /* FIXME: Add implementation code here */
89 p
->rng_fault_state
= True
;
90 return WERR_NOT_SUPPORTED
;
93 /********************************************************************
94 ********************************************************************/
96 WERROR
_wkssvc_NetrWkstaUserGetInfo(pipes_struct
*p
, struct wkssvc_NetrWkstaUserGetInfo
*r
)
98 /* FIXME: Add implementation code here */
99 p
->rng_fault_state
= True
;
100 return WERR_NOT_SUPPORTED
;
103 /********************************************************************
104 ********************************************************************/
106 WERROR
_wkssvc_NetrWkstaUserSetInfo(pipes_struct
*p
, struct wkssvc_NetrWkstaUserSetInfo
*r
)
108 /* FIXME: Add implementation code here */
109 p
->rng_fault_state
= True
;
110 return WERR_NOT_SUPPORTED
;
113 /********************************************************************
114 ********************************************************************/
116 WERROR
_wkssvc_NetWkstaTransportEnum(pipes_struct
*p
, struct wkssvc_NetWkstaTransportEnum
*r
)
118 /* FIXME: Add implementation code here */
119 p
->rng_fault_state
= True
;
120 return WERR_NOT_SUPPORTED
;
123 /********************************************************************
124 ********************************************************************/
126 WERROR
_wkssvc_NetrWkstaTransportAdd(pipes_struct
*p
, struct wkssvc_NetrWkstaTransportAdd
*r
)
128 /* FIXME: Add implementation code here */
129 p
->rng_fault_state
= True
;
130 return WERR_NOT_SUPPORTED
;
133 /********************************************************************
134 ********************************************************************/
136 WERROR
_wkssvc_NetrWkstaTransportDel(pipes_struct
*p
, struct wkssvc_NetrWkstaTransportDel
*r
)
138 /* FIXME: Add implementation code here */
139 p
->rng_fault_state
= True
;
140 return WERR_NOT_SUPPORTED
;
143 /********************************************************************
144 ********************************************************************/
146 WERROR
_wkssvc_NetrUseAdd(pipes_struct
*p
, struct wkssvc_NetrUseAdd
*r
)
148 /* FIXME: Add implementation code here */
149 p
->rng_fault_state
= True
;
150 return WERR_NOT_SUPPORTED
;
153 /********************************************************************
154 ********************************************************************/
156 WERROR
_wkssvc_NetrUseGetInfo(pipes_struct
*p
, struct wkssvc_NetrUseGetInfo
*r
)
158 /* FIXME: Add implementation code here */
159 p
->rng_fault_state
= True
;
160 return WERR_NOT_SUPPORTED
;
163 /********************************************************************
164 ********************************************************************/
166 WERROR
_wkssvc_NetrUseDel(pipes_struct
*p
, struct wkssvc_NetrUseDel
*r
)
168 /* FIXME: Add implementation code here */
169 p
->rng_fault_state
= True
;
170 return WERR_NOT_SUPPORTED
;
173 /********************************************************************
174 ********************************************************************/
176 WERROR
_wkssvc_NetrUseEnum(pipes_struct
*p
, struct wkssvc_NetrUseEnum
*r
)
178 /* FIXME: Add implementation code here */
179 p
->rng_fault_state
= True
;
180 return WERR_NOT_SUPPORTED
;
183 /********************************************************************
184 ********************************************************************/
186 WERROR
_wkssvc_NetrMessageBufferSend(pipes_struct
*p
, struct wkssvc_NetrMessageBufferSend
*r
)
188 /* FIXME: Add implementation code here */
189 p
->rng_fault_state
= True
;
190 return WERR_NOT_SUPPORTED
;
193 /********************************************************************
194 ********************************************************************/
196 WERROR
_wkssvc_NetrWorkstationStatisticsGet(pipes_struct
*p
, struct wkssvc_NetrWorkstationStatisticsGet
*r
)
198 /* FIXME: Add implementation code here */
199 p
->rng_fault_state
= True
;
200 return WERR_NOT_SUPPORTED
;
203 /********************************************************************
204 ********************************************************************/
206 WERROR
_wkssvc_NetrLogonDomainNameAdd(pipes_struct
*p
, struct wkssvc_NetrLogonDomainNameAdd
*r
)
208 /* FIXME: Add implementation code here */
209 p
->rng_fault_state
= True
;
210 return WERR_NOT_SUPPORTED
;
213 /********************************************************************
214 ********************************************************************/
216 WERROR
_wkssvc_NetrLogonDomainNameDel(pipes_struct
*p
, struct wkssvc_NetrLogonDomainNameDel
*r
)
218 /* FIXME: Add implementation code here */
219 p
->rng_fault_state
= True
;
220 return WERR_NOT_SUPPORTED
;
223 /********************************************************************
224 ********************************************************************/
226 WERROR
_wkssvc_NetrJoinDomain(pipes_struct
*p
, struct wkssvc_NetrJoinDomain
*r
)
228 /* FIXME: Add implementation code here */
229 p
->rng_fault_state
= True
;
230 return WERR_NOT_SUPPORTED
;
233 /********************************************************************
234 ********************************************************************/
236 WERROR
_wkssvc_NetrUnjoinDomain(pipes_struct
*p
, struct wkssvc_NetrUnjoinDomain
*r
)
238 /* FIXME: Add implementation code here */
239 p
->rng_fault_state
= True
;
240 return WERR_NOT_SUPPORTED
;
243 /********************************************************************
244 ********************************************************************/
246 WERROR
_wkssvc_NetrRenameMachineInDomain(pipes_struct
*p
, struct wkssvc_NetrRenameMachineInDomain
*r
)
248 /* FIXME: Add implementation code here */
249 p
->rng_fault_state
= True
;
250 return WERR_NOT_SUPPORTED
;
253 /********************************************************************
254 ********************************************************************/
256 WERROR
_wkssvc_NetrValidateName(pipes_struct
*p
, struct wkssvc_NetrValidateName
*r
)
258 /* FIXME: Add implementation code here */
259 p
->rng_fault_state
= True
;
260 return WERR_NOT_SUPPORTED
;
263 /********************************************************************
264 ********************************************************************/
266 WERROR
_wkssvc_NetrGetJoinInformation(pipes_struct
*p
, struct wkssvc_NetrGetJoinInformation
*r
)
268 /* FIXME: Add implementation code here */
269 p
->rng_fault_state
= True
;
270 return WERR_NOT_SUPPORTED
;
273 /********************************************************************
274 ********************************************************************/
276 WERROR
_wkssvc_NetrGetJoinableOus(pipes_struct
*p
, struct wkssvc_NetrGetJoinableOus
*r
)
278 /* FIXME: Add implementation code here */
279 p
->rng_fault_state
= True
;
280 return WERR_NOT_SUPPORTED
;
283 /********************************************************************
284 _wkssvc_NetrJoinDomain2
285 ********************************************************************/
287 WERROR
_wkssvc_NetrJoinDomain2(pipes_struct
*p
,
288 struct wkssvc_NetrJoinDomain2
*r
)
290 struct libnet_JoinCtx
*j
= NULL
;
291 char *cleartext_pwd
= NULL
;
292 char *admin_domain
= NULL
;
293 char *admin_account
= NULL
;
296 struct nt_user_token
*token
= p
->pipe_user
.nt_user_token
;
297 struct netr_DsRGetDCNameInfo
*info
= NULL
;
299 if (!r
->in
.domain_name
) {
300 return WERR_INVALID_PARAM
;
303 if (!user_has_privileges(token
, &se_machine_account
) &&
304 !nt_token_check_domain_rid(token
, DOMAIN_GROUP_RID_ADMINS
) &&
305 !nt_token_check_domain_rid(token
, BUILTIN_ALIAS_RID_ADMINS
)) {
306 DEBUG(5,("_wkssvc_NetrJoinDomain2: account doesn't have "
307 "sufficient privileges\n"));
308 return WERR_ACCESS_DENIED
;
311 werr
= decode_wkssvc_join_password_buffer(p
->mem_ctx
,
312 r
->in
.encrypted_password
,
315 if (!W_ERROR_IS_OK(werr
)) {
319 split_domain_user(p
->mem_ctx
,
324 status
= dsgetdcname(p
->mem_ctx
,
328 DS_DIRECTORY_SERVICE_REQUIRED
|
329 DS_WRITABLE_REQUIRED
|
332 if (!NT_STATUS_IS_OK(status
)) {
333 return ntstatus_to_werror(status
);
336 werr
= libnet_init_JoinCtx(p
->mem_ctx
, &j
);
337 if (!W_ERROR_IS_OK(werr
)) {
341 j
->in
.dc_name
= info
->dc_unc
;
342 j
->in
.domain_name
= r
->in
.domain_name
;
343 j
->in
.account_ou
= r
->in
.account_ou
;
344 j
->in
.join_flags
= r
->in
.join_flags
;
345 j
->in
.admin_account
= admin_account
;
346 j
->in
.admin_password
= cleartext_pwd
;
350 werr
= libnet_Join(p
->mem_ctx
, j
);
353 if (!W_ERROR_IS_OK(werr
)) {
354 DEBUG(5,("_wkssvc_NetrJoinDomain2: libnet_Join gave %s\n",
355 j
->out
.error_string
? j
->out
.error_string
:
363 /********************************************************************
364 ********************************************************************/
366 WERROR
_wkssvc_NetrUnjoinDomain2(pipes_struct
*p
, struct wkssvc_NetrUnjoinDomain2
*r
)
368 /* FIXME: Add implementation code here */
369 p
->rng_fault_state
= True
;
370 return WERR_NOT_SUPPORTED
;
373 /********************************************************************
374 ********************************************************************/
376 WERROR
_wkssvc_NetrRenameMachineInDomain2(pipes_struct
*p
, struct wkssvc_NetrRenameMachineInDomain2
*r
)
378 /* FIXME: Add implementation code here */
379 p
->rng_fault_state
= True
;
380 return WERR_NOT_SUPPORTED
;
383 /********************************************************************
384 ********************************************************************/
386 WERROR
_wkssvc_NetrValidateName2(pipes_struct
*p
, struct wkssvc_NetrValidateName2
*r
)
388 /* FIXME: Add implementation code here */
389 p
->rng_fault_state
= True
;
390 return WERR_NOT_SUPPORTED
;
393 /********************************************************************
394 ********************************************************************/
396 WERROR
_wkssvc_NetrGetJoinableOus2(pipes_struct
*p
, struct wkssvc_NetrGetJoinableOus2
*r
)
398 /* FIXME: Add implementation code here */
399 p
->rng_fault_state
= True
;
400 return WERR_NOT_SUPPORTED
;
403 /********************************************************************
404 ********************************************************************/
406 WERROR
_wkssvc_NetrAddAlternateComputerName(pipes_struct
*p
, struct wkssvc_NetrAddAlternateComputerName
*r
)
408 /* FIXME: Add implementation code here */
409 p
->rng_fault_state
= True
;
410 return WERR_NOT_SUPPORTED
;
413 /********************************************************************
414 ********************************************************************/
416 WERROR
_wkssvc_NetrRemoveAlternateComputerName(pipes_struct
*p
, struct wkssvc_NetrRemoveAlternateComputerName
*r
)
418 /* FIXME: Add implementation code here */
419 p
->rng_fault_state
= True
;
420 return WERR_NOT_SUPPORTED
;
423 /********************************************************************
424 ********************************************************************/
426 WERROR
_wkssvc_NetrSetPrimaryComputername(pipes_struct
*p
, struct wkssvc_NetrSetPrimaryComputername
*r
)
428 /* FIXME: Add implementation code here */
429 p
->rng_fault_state
= True
;
430 return WERR_NOT_SUPPORTED
;
433 /********************************************************************
434 ********************************************************************/
436 WERROR
_wkssvc_NetrEnumerateComputerNames(pipes_struct
*p
, struct wkssvc_NetrEnumerateComputerNames
*r
)
438 /* FIXME: Add implementation code here */
439 p
->rng_fault_state
= True
;
440 return WERR_NOT_SUPPORTED
;