2 Unix SMB/CIFS implementation.
4 Copyright (C) Volker Lendecke 2004
5 Copyright (C) Tim Potter 2005
6 Copyright (C) Jelmer Vernooij 2007
7 Copyright (C) Guenther Deschner 2010-2011
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "libcli/libcli.h"
25 #include "../librpc/gen_ndr/ndr_rap.h"
26 #include "libcli/rap/rap.h"
27 #include "librpc/ndr/libndr.h"
29 struct rap_call
*new_rap_cli_call(TALLOC_CTX
*mem_ctx
, uint16_t callno
)
31 struct rap_call
*call
;
33 call
= talloc_zero(mem_ctx
, struct rap_call
);
38 call
->callno
= callno
;
39 call
->rcv_paramlen
= 4;
41 call
->ndr_push_param
= ndr_push_init_ctx(call
);
42 call
->ndr_push_param
->flags
= RAPNDR_FLAGS
;
44 call
->ndr_push_data
= ndr_push_init_ctx(call
);
45 call
->ndr_push_data
->flags
= RAPNDR_FLAGS
;
47 call
->pull_mem_ctx
= mem_ctx
;
52 static void rap_cli_push_paramdesc(struct rap_call
*call
, char desc
)
56 if (call
->paramdesc
!= NULL
)
57 len
= strlen(call
->paramdesc
);
59 call
->paramdesc
= talloc_realloc(call
,
64 call
->paramdesc
[len
] = desc
;
65 call
->paramdesc
[len
+1] = '\0';
68 static void rap_cli_push_word(struct rap_call
*call
, uint16_t val
)
70 rap_cli_push_paramdesc(call
, 'W');
71 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, val
);
74 static void rap_cli_push_dword(struct rap_call
*call
, uint32_t val
)
76 rap_cli_push_paramdesc(call
, 'D');
77 ndr_push_uint32(call
->ndr_push_param
, NDR_SCALARS
, val
);
80 static void rap_cli_push_rcvbuf(struct rap_call
*call
, int len
)
82 rap_cli_push_paramdesc(call
, 'r');
83 rap_cli_push_paramdesc(call
, 'L');
84 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, len
);
85 call
->rcv_datalen
= len
;
88 static void rap_cli_push_sendbuf(struct rap_call
*call
, int len
)
90 rap_cli_push_paramdesc(call
, 's');
91 rap_cli_push_paramdesc(call
, 'T');
92 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, len
);
95 static void rap_cli_push_param(struct rap_call
*call
, uint16_t val
)
97 rap_cli_push_paramdesc(call
, 'P');
98 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, val
);
101 static void rap_cli_expect_multiple_entries(struct rap_call
*call
)
103 rap_cli_push_paramdesc(call
, 'e');
104 rap_cli_push_paramdesc(call
, 'h');
105 call
->rcv_paramlen
+= 4; /* uint16_t entry count, uint16_t total */
108 static void rap_cli_expect_word(struct rap_call
*call
)
110 rap_cli_push_paramdesc(call
, 'h');
111 call
->rcv_paramlen
+= 2;
114 static void rap_cli_push_string(struct rap_call
*call
, const char *str
)
117 rap_cli_push_paramdesc(call
, 'O');
120 rap_cli_push_paramdesc(call
, 'z');
121 ndr_push_string(call
->ndr_push_param
, NDR_SCALARS
, str
);
124 static void rap_cli_expect_format(struct rap_call
*call
, const char *format
)
126 call
->datadesc
= format
;
129 static void rap_cli_expect_extra_format(struct rap_call
*call
, const char *format
)
131 call
->auxdatadesc
= format
;
134 static NTSTATUS
rap_pull_string(TALLOC_CTX
*mem_ctx
, struct ndr_pull
*ndr
,
135 uint16_t convert
, const char **dest
)
137 uint16_t string_offset
;
142 NDR_RETURN(ndr_pull_uint16(ndr
, NDR_SCALARS
, &string_offset
));
143 NDR_RETURN(ndr_pull_uint16(ndr
, NDR_SCALARS
, &ignore
));
145 string_offset
-= convert
;
147 if (string_offset
+1 > ndr
->data_size
)
148 return NT_STATUS_INVALID_PARAMETER
;
150 p
= (const char *)(ndr
->data
+ string_offset
);
151 len
= strnlen(p
, ndr
->data_size
-string_offset
);
153 if ( string_offset
+ len
+ 1 > ndr
->data_size
)
154 return NT_STATUS_INVALID_PARAMETER
;
156 *dest
= talloc_zero_array(mem_ctx
, char, len
+1);
157 pull_string(discard_const_p(char, *dest
), p
, len
+1, len
, STR_ASCII
);
162 NTSTATUS
rap_cli_do_call(struct smbcli_tree
*tree
,
163 struct rap_call
*call
)
166 DATA_BLOB param_blob
;
168 struct ndr_push
*params
;
169 struct ndr_push
*data
;
170 struct smb_trans2 trans
;
172 params
= ndr_push_init_ctx(call
);
175 return NT_STATUS_NO_MEMORY
;
177 params
->flags
= RAPNDR_FLAGS
;
179 data
= ndr_push_init_ctx(call
);
182 return NT_STATUS_NO_MEMORY
;
184 data
->flags
= RAPNDR_FLAGS
;
186 trans
.in
.max_param
= call
->rcv_paramlen
;
187 trans
.in
.max_data
= call
->rcv_datalen
;
188 trans
.in
.max_setup
= 0;
190 trans
.in
.timeout
= 0;
191 trans
.in
.setup_count
= 0;
192 trans
.in
.setup
= NULL
;
193 trans
.in
.trans_name
= "\\PIPE\\LANMAN";
195 NDR_RETURN(ndr_push_uint16(params
, NDR_SCALARS
, call
->callno
));
197 NDR_RETURN(ndr_push_string(params
, NDR_SCALARS
, call
->paramdesc
));
199 NDR_RETURN(ndr_push_string(params
, NDR_SCALARS
, call
->datadesc
));
201 param_blob
= ndr_push_blob(call
->ndr_push_param
);
202 NDR_RETURN(ndr_push_bytes(params
, param_blob
.data
,
205 data_blob
= ndr_push_blob(call
->ndr_push_data
);
206 NDR_RETURN(ndr_push_bytes(data
, data_blob
.data
,
209 if (call
->auxdatadesc
)
210 NDR_RETURN(ndr_push_string(params
, NDR_SCALARS
, call
->auxdatadesc
));
212 trans
.in
.params
= ndr_push_blob(params
);
213 trans
.in
.data
= ndr_push_blob(data
);
215 result
= smb_raw_trans(tree
, call
, &trans
);
217 if (!NT_STATUS_IS_OK(result
))
220 call
->ndr_pull_param
= ndr_pull_init_blob(&trans
.out
.params
, call
);
221 call
->ndr_pull_param
->flags
= RAPNDR_FLAGS
;
222 call
->ndr_pull_param
->current_mem_ctx
= call
->pull_mem_ctx
;
223 call
->ndr_pull_data
= ndr_pull_init_blob(&trans
.out
.data
, call
);
224 call
->ndr_pull_data
->flags
= RAPNDR_FLAGS
;
225 call
->ndr_pull_data
->current_mem_ctx
= call
->pull_mem_ctx
;
231 NTSTATUS
smbcli_rap_netshareenum(struct smbcli_tree
*tree
,
233 struct rap_NetShareEnum
*r
)
235 struct rap_call
*call
;
236 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
239 call
= new_rap_cli_call(tree
, RAP_WshareEnum
);
242 return NT_STATUS_NO_MEMORY
;
244 rap_cli_push_word(call
, r
->in
.level
); /* Level */
245 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
246 rap_cli_expect_multiple_entries(call
);
248 switch(r
->in
.level
) {
250 rap_cli_expect_format(call
, "B13");
253 rap_cli_expect_format(call
, "B13BWz");
257 if (DEBUGLEVEL
>= 10) {
258 NDR_PRINT_IN_DEBUG(rap_NetShareEnum
, r
);
261 result
= rap_cli_do_call(tree
, call
);
263 if (!NT_STATUS_IS_OK(result
))
266 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
267 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
268 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
269 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
271 r
->out
.info
= talloc_array(mem_ctx
, union rap_share_info
, r
->out
.count
);
273 if (r
->out
.info
== NULL
) {
274 result
= NT_STATUS_NO_MEMORY
;
278 for (i
=0; i
<r
->out
.count
; i
++) {
279 switch(r
->in
.level
) {
281 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
282 r
->out
.info
[i
].info0
.share_name
, 13));
285 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
286 r
->out
.info
[i
].info1
.share_name
, 13));
287 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
288 &r
->out
.info
[i
].info1
.reserved1
, 1));
289 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_data
,
290 NDR_SCALARS
, &r
->out
.info
[i
].info1
.share_type
));
291 RAP_GOTO(rap_pull_string(mem_ctx
, call
->ndr_pull_data
,
293 &r
->out
.info
[i
].info1
.comment
));
298 if (DEBUGLEVEL
>= 10) {
299 NDR_PRINT_OUT_DEBUG(rap_NetShareEnum
, r
);
301 result
= NT_STATUS_OK
;
308 NTSTATUS
smbcli_rap_netserverenum2(struct smbcli_tree
*tree
,
310 struct rap_NetServerEnum2
*r
)
312 struct rap_call
*call
;
313 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
316 call
= new_rap_cli_call(mem_ctx
, RAP_NetServerEnum2
);
319 return NT_STATUS_NO_MEMORY
;
321 rap_cli_push_word(call
, r
->in
.level
);
322 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
323 rap_cli_expect_multiple_entries(call
);
324 rap_cli_push_dword(call
, r
->in
.servertype
);
325 rap_cli_push_string(call
, r
->in
.domain
);
327 switch(r
->in
.level
) {
329 rap_cli_expect_format(call
, "B16");
332 rap_cli_expect_format(call
, "B16BBDz");
336 if (DEBUGLEVEL
>= 10) {
337 NDR_PRINT_IN_DEBUG(rap_NetServerEnum2
, r
);
340 result
= rap_cli_do_call(tree
, call
);
342 if (!NT_STATUS_IS_OK(result
))
345 result
= NT_STATUS_INVALID_PARAMETER
;
347 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
348 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
349 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
350 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
352 r
->out
.info
= talloc_array(mem_ctx
, union rap_server_info
, r
->out
.count
);
354 if (r
->out
.info
== NULL
) {
355 result
= NT_STATUS_NO_MEMORY
;
359 for (i
=0; i
<r
->out
.count
; i
++) {
360 switch(r
->in
.level
) {
362 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
363 r
->out
.info
[i
].info0
.name
, 16));
366 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
367 r
->out
.info
[i
].info1
.name
, 16));
368 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
369 &r
->out
.info
[i
].info1
.version_major
, 1));
370 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
371 &r
->out
.info
[i
].info1
.version_minor
, 1));
372 NDR_GOTO(ndr_pull_uint32(call
->ndr_pull_data
,
373 NDR_SCALARS
, &r
->out
.info
[i
].info1
.servertype
));
374 RAP_GOTO(rap_pull_string(mem_ctx
, call
->ndr_pull_data
,
376 &r
->out
.info
[i
].info1
.comment
));
380 if (DEBUGLEVEL
>= 10) {
381 NDR_PRINT_OUT_DEBUG(rap_NetServerEnum2
, r
);
384 result
= NT_STATUS_OK
;
391 NTSTATUS
smbcli_rap_netservergetinfo(struct smbcli_tree
*tree
,
393 struct rap_WserverGetInfo
*r
)
395 struct rap_call
*call
;
396 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
398 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WserverGetInfo
))) {
399 return NT_STATUS_NO_MEMORY
;
402 rap_cli_push_word(call
, r
->in
.level
);
403 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
404 rap_cli_expect_word(call
);
406 switch(r
->in
.level
) {
408 rap_cli_expect_format(call
, "B16");
411 rap_cli_expect_format(call
, "B16BBDz");
414 result
= NT_STATUS_INVALID_PARAMETER
;
418 if (DEBUGLEVEL
>= 10) {
419 NDR_PRINT_IN_DEBUG(rap_WserverGetInfo
, r
);
422 result
= rap_cli_do_call(tree
, call
);
424 if (!NT_STATUS_IS_OK(result
))
427 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
428 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
429 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
431 switch(r
->in
.level
) {
433 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
434 r
->out
.info
.info0
.name
, 16));
437 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
438 r
->out
.info
.info1
.name
, 16));
439 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
440 &r
->out
.info
.info1
.version_major
, 1));
441 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
442 &r
->out
.info
.info1
.version_minor
, 1));
443 NDR_GOTO(ndr_pull_uint32(call
->ndr_pull_data
,
444 NDR_SCALARS
, &r
->out
.info
.info1
.servertype
));
445 RAP_GOTO(rap_pull_string(mem_ctx
, call
->ndr_pull_data
,
447 &r
->out
.info
.info1
.comment
));
450 if (DEBUGLEVEL
>= 10) {
451 NDR_PRINT_OUT_DEBUG(rap_WserverGetInfo
, r
);
458 static enum ndr_err_code
ndr_pull_rap_NetPrintQEnum_data(struct ndr_pull
*ndr
, struct rap_NetPrintQEnum
*r
)
460 uint32_t cntr_info_0
;
461 TALLOC_CTX
*_mem_save_info_0
;
463 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
464 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
465 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
466 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
467 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
468 NDR_CHECK(ndr_pull_rap_printq_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
470 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
471 NDR_CHECK(ndr_pull_rap_printq_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
473 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
475 return NDR_ERR_SUCCESS
;
478 NTSTATUS
smbcli_rap_netprintqenum(struct smbcli_tree
*tree
,
480 struct rap_NetPrintQEnum
*r
)
482 struct rap_call
*call
;
483 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
485 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQEnum
))) {
486 return NT_STATUS_NO_MEMORY
;
489 rap_cli_push_word(call
, r
->in
.level
);
490 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
491 rap_cli_expect_multiple_entries(call
);
493 switch(r
->in
.level
) {
495 rap_cli_expect_format(call
, "B13");
498 rap_cli_expect_format(call
, "B13BWWWzzzzzWW");
501 rap_cli_expect_format(call
, "B13BWWWzzzzzWN");
502 rap_cli_expect_extra_format(call
, "WB21BB16B10zWWzDDz");
505 rap_cli_expect_format(call
, "zWWWWzzzzWWzzl");
508 rap_cli_expect_format(call
, "zWWWWzzzzWNzzl");
509 rap_cli_expect_extra_format(call
, "WWzWWDDzz");
510 /* no mention of extra format in MS-RAP */
513 rap_cli_expect_format(call
, "z");
516 result
= NT_STATUS_INVALID_PARAMETER
;
520 if (DEBUGLEVEL
>= 10) {
521 NDR_PRINT_IN_DEBUG(rap_NetPrintQEnum
, r
);
524 result
= rap_cli_do_call(tree
, call
);
526 if (!NT_STATUS_IS_OK(result
))
529 result
= NT_STATUS_INVALID_PARAMETER
;
531 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
532 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
533 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
534 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
536 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
538 NDR_GOTO(ndr_pull_rap_NetPrintQEnum_data(call
->ndr_pull_data
, r
));
540 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
542 if (DEBUGLEVEL
>= 10) {
543 NDR_PRINT_OUT_DEBUG(rap_NetPrintQEnum
, r
);
546 result
= NT_STATUS_OK
;
553 NTSTATUS
smbcli_rap_netprintqgetinfo(struct smbcli_tree
*tree
,
555 struct rap_NetPrintQGetInfo
*r
)
557 struct rap_call
*call
;
558 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
560 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQGetInfo
))) {
561 return NT_STATUS_NO_MEMORY
;
564 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
565 rap_cli_push_word(call
, r
->in
.level
);
566 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
567 rap_cli_expect_word(call
);
569 switch(r
->in
.level
) {
571 rap_cli_expect_format(call
, "B13");
574 rap_cli_expect_format(call
, "B13BWWWzzzzzWW");
577 rap_cli_expect_format(call
, "B13BWWWzzzzzWN");
578 rap_cli_expect_extra_format(call
, "WB21BB16B10zWWzDDz");
581 rap_cli_expect_format(call
, "zWWWWzzzzWWzzl");
584 rap_cli_expect_format(call
, "zWWWWzzzzWNzzl");
585 rap_cli_expect_extra_format(call
, "WWzWWDDzz");
586 /* no mention of extra format in MS-RAP */
589 rap_cli_expect_format(call
, "z");
592 result
= NT_STATUS_INVALID_PARAMETER
;
596 if (DEBUGLEVEL
>= 10) {
597 NDR_PRINT_IN_DEBUG(rap_NetPrintQGetInfo
, r
);
600 result
= rap_cli_do_call(tree
, call
);
602 if (!NT_STATUS_IS_OK(result
))
605 result
= NT_STATUS_INVALID_PARAMETER
;
609 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
610 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
611 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
613 if (r
->out
.status
== 0) {
614 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
616 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
617 NDR_GOTO(ndr_pull_rap_printq_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
620 if (DEBUGLEVEL
>= 10) {
621 NDR_PRINT_OUT_DEBUG(rap_NetPrintQGetInfo
, r
);
624 result
= NT_STATUS_OK
;
630 NTSTATUS
smbcli_rap_netprintjobpause(struct smbcli_tree
*tree
,
632 struct rap_NetPrintJobPause
*r
)
634 struct rap_call
*call
;
635 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
637 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobPause
))) {
638 return NT_STATUS_NO_MEMORY
;
641 rap_cli_push_word(call
, r
->in
.JobID
);
643 rap_cli_expect_format(call
, "W");
645 if (DEBUGLEVEL
>= 10) {
646 NDR_PRINT_IN_DEBUG(rap_NetPrintJobPause
, r
);
649 result
= rap_cli_do_call(tree
, call
);
651 if (!NT_STATUS_IS_OK(result
))
654 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
655 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
657 if (DEBUGLEVEL
>= 10) {
658 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobPause
, r
);
666 NTSTATUS
smbcli_rap_netprintjobcontinue(struct smbcli_tree
*tree
,
668 struct rap_NetPrintJobContinue
*r
)
670 struct rap_call
*call
;
671 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
673 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobContinue
))) {
674 return NT_STATUS_NO_MEMORY
;
677 rap_cli_push_word(call
, r
->in
.JobID
);
679 rap_cli_expect_format(call
, "W");
681 if (DEBUGLEVEL
>= 10) {
682 NDR_PRINT_IN_DEBUG(rap_NetPrintJobContinue
, r
);
685 result
= rap_cli_do_call(tree
, call
);
687 if (!NT_STATUS_IS_OK(result
))
690 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
691 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
693 if (DEBUGLEVEL
>= 10) {
694 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobContinue
, r
);
702 NTSTATUS
smbcli_rap_netprintjobdelete(struct smbcli_tree
*tree
,
704 struct rap_NetPrintJobDelete
*r
)
706 struct rap_call
*call
;
707 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
709 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobDel
))) {
710 return NT_STATUS_NO_MEMORY
;
713 rap_cli_push_word(call
, r
->in
.JobID
);
715 rap_cli_expect_format(call
, "W");
717 if (DEBUGLEVEL
>= 10) {
718 NDR_PRINT_IN_DEBUG(rap_NetPrintJobDelete
, r
);
721 result
= rap_cli_do_call(tree
, call
);
723 if (!NT_STATUS_IS_OK(result
))
726 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
727 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
729 if (DEBUGLEVEL
>= 10) {
730 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobDelete
, r
);
738 NTSTATUS
smbcli_rap_netprintqueuepause(struct smbcli_tree
*tree
,
740 struct rap_NetPrintQueuePause
*r
)
742 struct rap_call
*call
;
743 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
745 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQPause
))) {
746 return NT_STATUS_NO_MEMORY
;
749 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
751 rap_cli_expect_format(call
, "");
753 if (DEBUGLEVEL
>= 10) {
754 NDR_PRINT_IN_DEBUG(rap_NetPrintQueuePause
, r
);
757 result
= rap_cli_do_call(tree
, call
);
759 if (!NT_STATUS_IS_OK(result
))
762 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
763 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
765 if (DEBUGLEVEL
>= 10) {
766 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueuePause
, r
);
774 NTSTATUS
smbcli_rap_netprintqueueresume(struct smbcli_tree
*tree
,
776 struct rap_NetPrintQueueResume
*r
)
778 struct rap_call
*call
;
779 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
781 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQContinue
))) {
782 return NT_STATUS_NO_MEMORY
;
785 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
787 rap_cli_expect_format(call
, "");
789 if (DEBUGLEVEL
>= 10) {
790 NDR_PRINT_IN_DEBUG(rap_NetPrintQueueResume
, r
);
793 result
= rap_cli_do_call(tree
, call
);
795 if (!NT_STATUS_IS_OK(result
))
798 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
799 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
801 if (DEBUGLEVEL
>= 10) {
802 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueueResume
, r
);
810 NTSTATUS
smbcli_rap_netprintqueuepurge(struct smbcli_tree
*tree
,
812 struct rap_NetPrintQueuePurge
*r
)
814 struct rap_call
*call
;
815 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
817 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQPurge
))) {
818 return NT_STATUS_NO_MEMORY
;
821 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
823 rap_cli_expect_format(call
, "");
825 if (DEBUGLEVEL
>= 10) {
826 NDR_PRINT_IN_DEBUG(rap_NetPrintQueuePurge
, r
);
829 result
= rap_cli_do_call(tree
, call
);
831 if (!NT_STATUS_IS_OK(result
))
834 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
835 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
837 if (DEBUGLEVEL
>= 10) {
838 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueuePurge
, r
);
846 static enum ndr_err_code
ndr_pull_rap_NetPrintJobEnum_data(struct ndr_pull
*ndr
, struct rap_NetPrintJobEnum
*r
)
848 uint32_t cntr_info_0
;
849 TALLOC_CTX
*_mem_save_info_0
;
851 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
852 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
853 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
854 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
855 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
856 NDR_CHECK(ndr_pull_rap_printj_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
858 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
859 NDR_CHECK(ndr_pull_rap_printj_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
861 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
863 return NDR_ERR_SUCCESS
;
866 NTSTATUS
smbcli_rap_netprintjobenum(struct smbcli_tree
*tree
,
868 struct rap_NetPrintJobEnum
*r
)
870 struct rap_call
*call
;
871 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
873 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobEnum
))) {
874 return NT_STATUS_NO_MEMORY
;
877 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
878 rap_cli_push_word(call
, r
->in
.level
);
879 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
880 rap_cli_expect_multiple_entries(call
);
882 switch(r
->in
.level
) {
884 rap_cli_expect_format(call
, "W");
887 rap_cli_expect_format(call
, "WB21BB16B10zWWzDDz");
890 rap_cli_expect_format(call
, "WWzWWDDzz");
893 rap_cli_expect_format(call
, "WWzWWDDzzzzzzzzzzlz");
896 rap_cli_expect_format(call
, "WWzWWDDzzzzzDDDDDDD");
899 result
= NT_STATUS_INVALID_PARAMETER
;
903 if (DEBUGLEVEL
>= 10) {
904 NDR_PRINT_IN_DEBUG(rap_NetPrintJobEnum
, r
);
907 result
= rap_cli_do_call(tree
, call
);
909 if (!NT_STATUS_IS_OK(result
))
912 result
= NT_STATUS_INVALID_PARAMETER
;
914 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
915 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
916 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
917 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
919 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
921 NDR_GOTO(ndr_pull_rap_NetPrintJobEnum_data(call
->ndr_pull_data
, r
));
923 if (DEBUGLEVEL
>= 10) {
924 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobEnum
, r
);
927 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
929 result
= NT_STATUS_OK
;
936 NTSTATUS
smbcli_rap_netprintjobgetinfo(struct smbcli_tree
*tree
,
938 struct rap_NetPrintJobGetInfo
*r
)
940 struct rap_call
*call
;
941 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
943 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobGetInfo
))) {
944 return NT_STATUS_NO_MEMORY
;
947 rap_cli_push_word(call
, r
->in
.JobID
);
948 rap_cli_push_word(call
, r
->in
.level
);
949 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
950 rap_cli_expect_word(call
);
952 switch(r
->in
.level
) {
954 rap_cli_expect_format(call
, "W");
957 rap_cli_expect_format(call
, "WB21BB16B10zWWzDDz");
960 rap_cli_expect_format(call
, "WWzWWDDzz");
963 rap_cli_expect_format(call
, "WWzWWDDzzzzzzzzzzlz");
966 rap_cli_expect_format(call
, "WWzWWDDzzzzzDDDDDDD");
969 result
= NT_STATUS_INVALID_PARAMETER
;
973 if (DEBUGLEVEL
>= 10) {
974 NDR_PRINT_IN_DEBUG(rap_NetPrintJobGetInfo
, r
);
977 result
= rap_cli_do_call(tree
, call
);
979 if (!NT_STATUS_IS_OK(result
))
982 result
= NT_STATUS_INVALID_PARAMETER
;
984 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
985 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
986 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
988 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
990 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
991 NDR_GOTO(ndr_pull_rap_printj_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
993 if (DEBUGLEVEL
>= 10) {
994 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobGetInfo
, r
);
997 result
= NT_STATUS_OK
;
1004 NTSTATUS
smbcli_rap_netprintjobsetinfo(struct smbcli_tree
*tree
,
1005 TALLOC_CTX
*mem_ctx
,
1006 struct rap_NetPrintJobSetInfo
*r
)
1008 struct rap_call
*call
;
1009 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1011 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobSetInfo
))) {
1012 return NT_STATUS_NO_MEMORY
;
1015 rap_cli_push_word(call
, r
->in
.JobID
);
1016 rap_cli_push_word(call
, r
->in
.level
);
1017 rap_cli_push_sendbuf(call
, r
->in
.bufsize
);
1018 rap_cli_push_param(call
, r
->in
.ParamNum
);
1020 switch (r
->in
.ParamNum
) {
1021 case RAP_PARAM_JOBNUM
:
1022 case RAP_PARAM_JOBPOSITION
:
1023 case RAP_PARAM_JOBSTATUS
:
1024 NDR_GOTO(ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.Param
.value
));
1026 case RAP_PARAM_USERNAME
:
1027 case RAP_PARAM_NOTIFYNAME
:
1028 case RAP_PARAM_DATATYPE
:
1029 case RAP_PARAM_PARAMETERS_STRING
:
1030 case RAP_PARAM_JOBSTATUSSTR
:
1031 case RAP_PARAM_JOBCOMMENT
:
1032 NDR_GOTO(ndr_push_string(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.Param
.string
));
1034 case RAP_PARAM_TIMESUBMITTED
:
1035 case RAP_PARAM_JOBSIZE
:
1036 NDR_GOTO(ndr_push_uint32(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.Param
.value4
));
1039 result
= NT_STATUS_INVALID_PARAMETER
;
1043 /* not really sure if this is correct */
1044 rap_cli_expect_format(call
, "WB21BB16B10zWWzDDz");
1046 if (DEBUGLEVEL
>= 10) {
1047 NDR_PRINT_IN_DEBUG(rap_NetPrintJobSetInfo
, r
);
1050 result
= rap_cli_do_call(tree
, call
);
1052 if (!NT_STATUS_IS_OK(result
))
1055 result
= NT_STATUS_INVALID_PARAMETER
;
1057 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1058 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1060 result
= NT_STATUS_OK
;
1062 if (!NT_STATUS_IS_OK(result
)) {
1066 if (DEBUGLEVEL
>= 10) {
1067 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobSetInfo
, r
);
1075 static enum ndr_err_code
ndr_pull_rap_NetPrintDestEnum_data(struct ndr_pull
*ndr
, struct rap_NetPrintDestEnum
*r
)
1077 uint32_t cntr_info_0
;
1078 TALLOC_CTX
*_mem_save_info_0
;
1080 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
1081 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
1082 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
1083 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1084 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
1085 NDR_CHECK(ndr_pull_rap_printdest_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
1087 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1088 NDR_CHECK(ndr_pull_rap_printdest_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
1090 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
1092 return NDR_ERR_SUCCESS
;
1096 NTSTATUS
smbcli_rap_netprintdestenum(struct smbcli_tree
*tree
,
1097 TALLOC_CTX
*mem_ctx
,
1098 struct rap_NetPrintDestEnum
*r
)
1100 struct rap_call
*call
;
1101 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1103 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintDestEnum
))) {
1104 return NT_STATUS_NO_MEMORY
;
1107 rap_cli_push_word(call
, r
->in
.level
);
1108 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1109 rap_cli_expect_multiple_entries(call
);
1111 switch(r
->in
.level
) {
1113 rap_cli_expect_format(call
, "B9");
1116 rap_cli_expect_format(call
, "B9B21WWzW");
1119 rap_cli_expect_format(call
, "z");
1122 rap_cli_expect_format(call
, "zzzWWzzzWW");
1125 result
= NT_STATUS_INVALID_PARAMETER
;
1129 if (DEBUGLEVEL
>= 10) {
1130 NDR_PRINT_IN_DEBUG(rap_NetPrintDestEnum
, r
);
1133 result
= rap_cli_do_call(tree
, call
);
1135 if (!NT_STATUS_IS_OK(result
))
1138 result
= NT_STATUS_INVALID_PARAMETER
;
1140 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1141 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1142 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
1143 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1145 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1147 NDR_GOTO(ndr_pull_rap_NetPrintDestEnum_data(call
->ndr_pull_data
, r
));
1149 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
1151 if (DEBUGLEVEL
>= 10) {
1152 NDR_PRINT_OUT_DEBUG(rap_NetPrintDestEnum
, r
);
1155 result
= NT_STATUS_OK
;
1162 NTSTATUS
smbcli_rap_netprintdestgetinfo(struct smbcli_tree
*tree
,
1163 TALLOC_CTX
*mem_ctx
,
1164 struct rap_NetPrintDestGetInfo
*r
)
1166 struct rap_call
*call
;
1167 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1169 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintDestGetInfo
))) {
1170 return NT_STATUS_NO_MEMORY
;
1173 rap_cli_push_string(call
, r
->in
.PrintDestName
);
1174 rap_cli_push_word(call
, r
->in
.level
);
1175 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1176 rap_cli_expect_word(call
);
1178 switch(r
->in
.level
) {
1180 rap_cli_expect_format(call
, "B9");
1183 rap_cli_expect_format(call
, "B9B21WWzW");
1186 rap_cli_expect_format(call
, "z");
1189 rap_cli_expect_format(call
, "zzzWWzzzWW");
1192 result
= NT_STATUS_INVALID_PARAMETER
;
1196 if (DEBUGLEVEL
>= 10) {
1197 NDR_PRINT_IN_DEBUG(rap_NetPrintDestGetInfo
, r
);
1200 result
= rap_cli_do_call(tree
, call
);
1202 if (!NT_STATUS_IS_OK(result
))
1205 result
= NT_STATUS_INVALID_PARAMETER
;
1207 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1208 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1209 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1211 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1213 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
1214 NDR_GOTO(ndr_pull_rap_printdest_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1216 if (DEBUGLEVEL
>= 10) {
1217 NDR_PRINT_OUT_DEBUG(rap_NetPrintDestGetInfo
, r
);
1220 result
= NT_STATUS_OK
;
1227 NTSTATUS
smbcli_rap_netuserpasswordset2(struct smbcli_tree
*tree
,
1228 TALLOC_CTX
*mem_ctx
,
1229 struct rap_NetUserPasswordSet2
*r
)
1231 struct rap_call
*call
;
1232 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1234 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserPasswordSet2
))) {
1235 return NT_STATUS_NO_MEMORY
;
1238 rap_cli_push_string(call
, r
->in
.UserName
);
1239 rap_cli_push_paramdesc(call
, 'b');
1240 rap_cli_push_paramdesc(call
, '1');
1241 rap_cli_push_paramdesc(call
, '6');
1242 ndr_push_array_uint8(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.OldPassword
, 16);
1243 rap_cli_push_paramdesc(call
, 'b');
1244 rap_cli_push_paramdesc(call
, '1');
1245 rap_cli_push_paramdesc(call
, '6');
1246 ndr_push_array_uint8(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.NewPassword
, 16);
1247 rap_cli_push_word(call
, r
->in
.EncryptedPassword
);
1248 rap_cli_push_word(call
, r
->in
.RealPasswordLength
);
1250 rap_cli_expect_format(call
, "");
1252 if (DEBUGLEVEL
>= 10) {
1253 NDR_PRINT_IN_DEBUG(rap_NetUserPasswordSet2
, r
);
1256 result
= rap_cli_do_call(tree
, call
);
1258 if (!NT_STATUS_IS_OK(result
))
1261 result
= NT_STATUS_INVALID_PARAMETER
;
1263 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1264 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1266 result
= NT_STATUS_OK
;
1268 if (!NT_STATUS_IS_OK(result
)) {
1272 if (DEBUGLEVEL
>= 10) {
1273 NDR_PRINT_OUT_DEBUG(rap_NetUserPasswordSet2
, r
);
1281 NTSTATUS
smbcli_rap_netoemchangepassword(struct smbcli_tree
*tree
,
1282 TALLOC_CTX
*mem_ctx
,
1283 struct rap_NetOEMChangePassword
*r
)
1285 struct rap_call
*call
;
1286 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1288 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_SamOEMChgPasswordUser2_P
))) {
1289 return NT_STATUS_NO_MEMORY
;
1292 rap_cli_push_string(call
, r
->in
.UserName
);
1293 rap_cli_push_sendbuf(call
, 532);
1294 ndr_push_array_uint8(call
->ndr_push_data
, NDR_SCALARS
, r
->in
.crypt_password
, 516);
1295 ndr_push_array_uint8(call
->ndr_push_data
, NDR_SCALARS
, r
->in
.password_hash
, 16);
1297 rap_cli_expect_format(call
, "B516B16");
1299 if (DEBUGLEVEL
>= 10) {
1300 NDR_PRINT_IN_DEBUG(rap_NetOEMChangePassword
, r
);
1303 result
= rap_cli_do_call(tree
, call
);
1305 if (!NT_STATUS_IS_OK(result
))
1308 result
= NT_STATUS_INVALID_PARAMETER
;
1310 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1311 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1313 result
= NT_STATUS_OK
;
1315 if (!NT_STATUS_IS_OK(result
)) {
1319 if (DEBUGLEVEL
>= 10) {
1320 NDR_PRINT_OUT_DEBUG(rap_NetOEMChangePassword
, r
);
1328 NTSTATUS
smbcli_rap_netusergetinfo(struct smbcli_tree
*tree
,
1329 TALLOC_CTX
*mem_ctx
,
1330 struct rap_NetUserGetInfo
*r
)
1332 struct rap_call
*call
;
1333 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1335 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserGetInfo
))) {
1336 return NT_STATUS_NO_MEMORY
;
1339 rap_cli_push_string(call
, r
->in
.UserName
);
1340 rap_cli_push_word(call
, r
->in
.level
);
1341 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1342 rap_cli_expect_word(call
);
1344 switch(r
->in
.level
) {
1346 rap_cli_expect_format(call
, "B21");
1349 rap_cli_expect_format(call
, "B21BB16DWzzWz");
1352 rap_cli_expect_format(call
, "B21BB16DWzzWzDzzzzDDDDWb21WWzWW");
1355 rap_cli_expect_format(call
, "B21Bzzz");
1358 rap_cli_expect_format(call
, "B21BzzzWDDzzDDWWzWzDWb21W");
1361 result
= NT_STATUS_INVALID_PARAMETER
;
1365 if (DEBUGLEVEL
>= 10) {
1366 NDR_PRINT_IN_DEBUG(rap_NetUserGetInfo
, r
);
1369 result
= rap_cli_do_call(tree
, call
);
1371 if (!NT_STATUS_IS_OK(result
))
1374 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1375 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1376 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1378 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1380 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
1381 NDR_GOTO(ndr_pull_rap_netuser_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1383 if (DEBUGLEVEL
>= 10) {
1384 NDR_PRINT_OUT_DEBUG(rap_NetUserGetInfo
, r
);
1387 result
= NT_STATUS_OK
;
1395 static enum ndr_err_code
ndr_pull_rap_NetSessionEnum_data(struct ndr_pull
*ndr
, struct rap_NetSessionEnum
*r
)
1397 uint32_t cntr_info_0
;
1398 TALLOC_CTX
*_mem_save_info_0
;
1400 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
1401 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
1402 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
1403 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1404 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
1405 NDR_CHECK(ndr_pull_rap_session_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
1407 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1408 NDR_CHECK(ndr_pull_rap_session_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
1410 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
1412 return NDR_ERR_SUCCESS
;
1416 NTSTATUS
smbcli_rap_netsessionenum(struct smbcli_tree
*tree
,
1417 TALLOC_CTX
*mem_ctx
,
1418 struct rap_NetSessionEnum
*r
)
1420 struct rap_call
*call
;
1421 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1423 call
= new_rap_cli_call(tree
, RAP_WsessionEnum
);
1426 return NT_STATUS_NO_MEMORY
;
1428 rap_cli_push_word(call
, r
->in
.level
);
1429 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1430 rap_cli_expect_multiple_entries(call
);
1432 switch(r
->in
.level
) {
1434 rap_cli_expect_format(call
, "zzWWWDDDz");
1437 result
= NT_STATUS_INVALID_PARAMETER
;
1441 if (DEBUGLEVEL
>= 10) {
1442 NDR_PRINT_IN_DEBUG(rap_NetSessionEnum
, r
);
1445 result
= rap_cli_do_call(tree
, call
);
1447 if (!NT_STATUS_IS_OK(result
))
1450 result
= NT_STATUS_INVALID_PARAMETER
;
1452 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1453 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1454 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
1455 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1457 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1459 NDR_GOTO(ndr_pull_rap_NetSessionEnum_data(call
->ndr_pull_data
, r
));
1461 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
1463 if (DEBUGLEVEL
>= 10) {
1464 NDR_PRINT_OUT_DEBUG(rap_NetSessionEnum
, r
);
1467 result
= NT_STATUS_OK
;
1474 NTSTATUS
smbcli_rap_netsessiongetinfo(struct smbcli_tree
*tree
,
1475 TALLOC_CTX
*mem_ctx
,
1476 struct rap_NetSessionGetInfo
*r
)
1478 struct rap_call
*call
;
1479 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1481 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WsessionGetInfo
))) {
1482 return NT_STATUS_NO_MEMORY
;
1485 rap_cli_push_string(call
, r
->in
.SessionName
);
1486 rap_cli_push_word(call
, r
->in
.level
);
1487 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1488 rap_cli_expect_word(call
);
1490 switch(r
->in
.level
) {
1492 rap_cli_expect_format(call
, "zzWWWDDDz");
1495 result
= NT_STATUS_INVALID_PARAMETER
;
1499 if (DEBUGLEVEL
>= 10) {
1500 NDR_PRINT_IN_DEBUG(rap_NetSessionGetInfo
, r
);
1503 result
= rap_cli_do_call(tree
, call
);
1505 if (!NT_STATUS_IS_OK(result
))
1508 result
= NT_STATUS_INVALID_PARAMETER
;
1510 ZERO_STRUCT(r
->out
);
1512 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1513 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1514 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1516 if (r
->out
.status
== 0 && r
->out
.available
) {
1517 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1519 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
1520 NDR_GOTO(ndr_pull_rap_session_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1523 if (DEBUGLEVEL
>= 10) {
1524 NDR_PRINT_OUT_DEBUG(rap_NetSessionGetInfo
, r
);
1527 result
= NT_STATUS_OK
;
1534 NTSTATUS
smbcli_rap_netuseradd(struct smbcli_tree
*tree
,
1535 TALLOC_CTX
*mem_ctx
,
1536 struct rap_NetUserAdd
*r
)
1538 struct rap_call
*call
;
1539 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1541 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserAdd2
))) {
1542 return NT_STATUS_NO_MEMORY
;
1545 rap_cli_push_word(call
, r
->in
.level
);
1546 rap_cli_push_sendbuf(call
, r
->in
.bufsize
);
1547 rap_cli_push_word(call
, r
->in
.pwdlength
);
1548 rap_cli_push_word(call
, r
->in
.unknown
);
1550 switch (r
->in
.level
) {
1552 rap_cli_expect_format(call
, "B21BB16DWzzWz");
1555 result
= NT_STATUS_INVALID_PARAMETER
;
1559 if (DEBUGLEVEL
>= 10) {
1560 NDR_PRINT_IN_DEBUG(rap_NetUserAdd
, r
);
1563 NDR_GOTO(ndr_push_set_switch_value(call
->ndr_push_data
, &r
->in
.info
, r
->in
.level
));
1564 NDR_GOTO(ndr_push_rap_netuser_info(call
->ndr_push_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->in
.info
));
1566 result
= rap_cli_do_call(tree
, call
);
1568 if (!NT_STATUS_IS_OK(result
))
1571 result
= NT_STATUS_INVALID_PARAMETER
;
1573 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1574 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1576 result
= NT_STATUS_OK
;
1578 if (!NT_STATUS_IS_OK(result
)) {
1582 if (DEBUGLEVEL
>= 10) {
1583 NDR_PRINT_OUT_DEBUG(rap_NetUserAdd
, r
);
1591 NTSTATUS
smbcli_rap_netuserdelete(struct smbcli_tree
*tree
,
1592 TALLOC_CTX
*mem_ctx
,
1593 struct rap_NetUserDelete
*r
)
1595 struct rap_call
*call
;
1596 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1598 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserDel
))) {
1599 return NT_STATUS_NO_MEMORY
;
1602 rap_cli_push_string(call
, r
->in
.UserName
);
1604 rap_cli_expect_format(call
, "");
1605 rap_cli_expect_extra_format(call
, "");
1607 if (DEBUGLEVEL
>= 10) {
1608 NDR_PRINT_IN_DEBUG(rap_NetUserDelete
, r
);
1611 result
= rap_cli_do_call(tree
, call
);
1613 if (!NT_STATUS_IS_OK(result
))
1616 result
= NT_STATUS_INVALID_PARAMETER
;
1618 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1619 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1621 result
= NT_STATUS_OK
;
1623 if (!NT_STATUS_IS_OK(result
)) {
1627 if (DEBUGLEVEL
>= 10) {
1628 NDR_PRINT_OUT_DEBUG(rap_NetUserDelete
, r
);
1636 NTSTATUS
smbcli_rap_netremotetod(struct smbcli_tree
*tree
,
1637 TALLOC_CTX
*mem_ctx
,
1638 struct rap_NetRemoteTOD
*r
)
1640 struct rap_call
*call
;
1641 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1643 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_NetRemoteTOD
))) {
1644 return NT_STATUS_NO_MEMORY
;
1647 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1649 rap_cli_expect_format(call
, "DDBBBBWWBBWB");
1650 rap_cli_expect_extra_format(call
, "");
1652 if (DEBUGLEVEL
>= 10) {
1653 NDR_PRINT_IN_DEBUG(rap_NetRemoteTOD
, r
);
1656 result
= rap_cli_do_call(tree
, call
);
1658 if (!NT_STATUS_IS_OK(result
))
1661 result
= NT_STATUS_INVALID_PARAMETER
;
1663 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1664 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1666 NDR_GOTO(ndr_pull_rap_TimeOfDayInfo(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.tod
));
1668 result
= NT_STATUS_OK
;
1670 if (!NT_STATUS_IS_OK(result
)) {
1674 if (DEBUGLEVEL
>= 10) {
1675 NDR_PRINT_OUT_DEBUG(rap_NetRemoteTOD
, r
);