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 if (call
->ndr_push_param
== NULL
) {
46 call
->ndr_push_param
->flags
= RAPNDR_FLAGS
;
48 call
->ndr_push_data
= ndr_push_init_ctx(call
);
49 if (call
->ndr_push_data
== NULL
) {
53 call
->ndr_push_data
->flags
= RAPNDR_FLAGS
;
55 call
->pull_mem_ctx
= mem_ctx
;
60 static void rap_cli_push_paramdesc(struct rap_call
*call
, char desc
)
64 if (call
->paramdesc
!= NULL
)
65 len
= strlen(call
->paramdesc
);
67 call
->paramdesc
= talloc_realloc(call
,
72 call
->paramdesc
[len
] = desc
;
73 call
->paramdesc
[len
+1] = '\0';
76 static void rap_cli_push_word(struct rap_call
*call
, uint16_t val
)
78 rap_cli_push_paramdesc(call
, 'W');
79 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, val
);
82 static void rap_cli_push_dword(struct rap_call
*call
, uint32_t val
)
84 rap_cli_push_paramdesc(call
, 'D');
85 ndr_push_uint32(call
->ndr_push_param
, NDR_SCALARS
, val
);
88 static void rap_cli_push_rcvbuf(struct rap_call
*call
, int len
)
90 rap_cli_push_paramdesc(call
, 'r');
91 rap_cli_push_paramdesc(call
, 'L');
92 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, len
);
93 call
->rcv_datalen
= len
;
96 static void rap_cli_push_sendbuf(struct rap_call
*call
, int len
)
98 rap_cli_push_paramdesc(call
, 's');
99 rap_cli_push_paramdesc(call
, 'T');
100 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, len
);
103 static void rap_cli_push_param(struct rap_call
*call
, uint16_t val
)
105 rap_cli_push_paramdesc(call
, 'P');
106 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, val
);
109 static void rap_cli_expect_multiple_entries(struct rap_call
*call
)
111 rap_cli_push_paramdesc(call
, 'e');
112 rap_cli_push_paramdesc(call
, 'h');
113 call
->rcv_paramlen
+= 4; /* uint16_t entry count, uint16_t total */
116 static void rap_cli_expect_word(struct rap_call
*call
)
118 rap_cli_push_paramdesc(call
, 'h');
119 call
->rcv_paramlen
+= 2;
122 static void rap_cli_push_string(struct rap_call
*call
, const char *str
)
125 rap_cli_push_paramdesc(call
, 'O');
128 rap_cli_push_paramdesc(call
, 'z');
129 ndr_push_string(call
->ndr_push_param
, NDR_SCALARS
, str
);
132 static void rap_cli_expect_format(struct rap_call
*call
, const char *format
)
134 call
->datadesc
= format
;
137 static void rap_cli_expect_extra_format(struct rap_call
*call
, const char *format
)
139 call
->auxdatadesc
= format
;
142 static NTSTATUS
rap_pull_string(TALLOC_CTX
*mem_ctx
, struct ndr_pull
*ndr
,
143 uint16_t convert
, const char **dest
)
145 uint16_t string_offset
;
150 NDR_RETURN(ndr_pull_uint16(ndr
, NDR_SCALARS
, &string_offset
));
151 NDR_RETURN(ndr_pull_uint16(ndr
, NDR_SCALARS
, &ignore
));
153 string_offset
-= convert
;
155 if (string_offset
+1 > ndr
->data_size
)
156 return NT_STATUS_INVALID_PARAMETER
;
158 p
= (const char *)(ndr
->data
+ string_offset
);
159 len
= strnlen(p
, ndr
->data_size
-string_offset
);
161 if ( string_offset
+ len
+ 1 > ndr
->data_size
)
162 return NT_STATUS_INVALID_PARAMETER
;
164 *dest
= talloc_zero_array(mem_ctx
, char, len
+1);
165 pull_string(discard_const_p(char, *dest
), p
, len
+1, len
, STR_ASCII
);
170 NTSTATUS
rap_cli_do_call(struct smbcli_tree
*tree
,
171 struct rap_call
*call
)
174 DATA_BLOB param_blob
;
176 struct ndr_push
*params
;
177 struct ndr_push
*data
;
178 struct smb_trans2 trans
;
180 params
= ndr_push_init_ctx(call
);
183 return NT_STATUS_NO_MEMORY
;
185 params
->flags
= RAPNDR_FLAGS
;
187 data
= ndr_push_init_ctx(call
);
190 return NT_STATUS_NO_MEMORY
;
192 data
->flags
= RAPNDR_FLAGS
;
194 trans
.in
.max_param
= call
->rcv_paramlen
;
195 trans
.in
.max_data
= call
->rcv_datalen
;
196 trans
.in
.max_setup
= 0;
198 trans
.in
.timeout
= 0;
199 trans
.in
.setup_count
= 0;
200 trans
.in
.setup
= NULL
;
201 trans
.in
.trans_name
= "\\PIPE\\LANMAN";
203 NDR_RETURN(ndr_push_uint16(params
, NDR_SCALARS
, call
->callno
));
205 NDR_RETURN(ndr_push_string(params
, NDR_SCALARS
, call
->paramdesc
));
207 NDR_RETURN(ndr_push_string(params
, NDR_SCALARS
, call
->datadesc
));
209 param_blob
= ndr_push_blob(call
->ndr_push_param
);
210 NDR_RETURN(ndr_push_bytes(params
, param_blob
.data
,
213 data_blob
= ndr_push_blob(call
->ndr_push_data
);
214 NDR_RETURN(ndr_push_bytes(data
, data_blob
.data
,
217 if (call
->auxdatadesc
)
218 NDR_RETURN(ndr_push_string(params
, NDR_SCALARS
, call
->auxdatadesc
));
220 trans
.in
.params
= ndr_push_blob(params
);
221 trans
.in
.data
= ndr_push_blob(data
);
223 result
= smb_raw_trans(tree
, call
, &trans
);
225 if (!NT_STATUS_IS_OK(result
))
228 call
->ndr_pull_param
= ndr_pull_init_blob(&trans
.out
.params
, call
);
229 call
->ndr_pull_param
->flags
= RAPNDR_FLAGS
;
230 call
->ndr_pull_param
->current_mem_ctx
= call
->pull_mem_ctx
;
231 call
->ndr_pull_data
= ndr_pull_init_blob(&trans
.out
.data
, call
);
232 call
->ndr_pull_data
->flags
= RAPNDR_FLAGS
;
233 call
->ndr_pull_data
->current_mem_ctx
= call
->pull_mem_ctx
;
239 NTSTATUS
smbcli_rap_netshareenum(struct smbcli_tree
*tree
,
241 struct rap_NetShareEnum
*r
)
243 struct rap_call
*call
;
244 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
247 call
= new_rap_cli_call(tree
, RAP_WshareEnum
);
250 return NT_STATUS_NO_MEMORY
;
252 rap_cli_push_word(call
, r
->in
.level
); /* Level */
253 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
254 rap_cli_expect_multiple_entries(call
);
256 switch(r
->in
.level
) {
258 rap_cli_expect_format(call
, "B13");
261 rap_cli_expect_format(call
, "B13BWz");
265 if (DEBUGLEVEL
>= 10) {
266 NDR_PRINT_IN_DEBUG(rap_NetShareEnum
, r
);
269 result
= rap_cli_do_call(tree
, call
);
271 if (!NT_STATUS_IS_OK(result
))
274 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
275 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
276 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
277 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
279 r
->out
.info
= talloc_array(mem_ctx
, union rap_share_info
, r
->out
.count
);
281 if (r
->out
.info
== NULL
) {
282 result
= NT_STATUS_NO_MEMORY
;
286 for (i
=0; i
<r
->out
.count
; i
++) {
287 switch(r
->in
.level
) {
289 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
290 r
->out
.info
[i
].info0
.share_name
, 13));
293 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
294 r
->out
.info
[i
].info1
.share_name
, 13));
295 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
296 &r
->out
.info
[i
].info1
.reserved1
, 1));
297 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_data
,
298 NDR_SCALARS
, &r
->out
.info
[i
].info1
.share_type
));
299 RAP_GOTO(rap_pull_string(mem_ctx
, call
->ndr_pull_data
,
301 &r
->out
.info
[i
].info1
.comment
));
306 if (DEBUGLEVEL
>= 10) {
307 NDR_PRINT_OUT_DEBUG(rap_NetShareEnum
, r
);
309 result
= NT_STATUS_OK
;
316 NTSTATUS
smbcli_rap_netserverenum2(struct smbcli_tree
*tree
,
318 struct rap_NetServerEnum2
*r
)
320 struct rap_call
*call
;
321 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
324 call
= new_rap_cli_call(mem_ctx
, RAP_NetServerEnum2
);
327 return NT_STATUS_NO_MEMORY
;
329 rap_cli_push_word(call
, r
->in
.level
);
330 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
331 rap_cli_expect_multiple_entries(call
);
332 rap_cli_push_dword(call
, r
->in
.servertype
);
333 rap_cli_push_string(call
, r
->in
.domain
);
335 switch(r
->in
.level
) {
337 rap_cli_expect_format(call
, "B16");
340 rap_cli_expect_format(call
, "B16BBDz");
344 if (DEBUGLEVEL
>= 10) {
345 NDR_PRINT_IN_DEBUG(rap_NetServerEnum2
, r
);
348 result
= rap_cli_do_call(tree
, call
);
350 if (!NT_STATUS_IS_OK(result
))
353 result
= NT_STATUS_INVALID_PARAMETER
;
355 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
356 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
357 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
358 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
360 r
->out
.info
= talloc_array(mem_ctx
, union rap_server_info
, r
->out
.count
);
362 if (r
->out
.info
== NULL
) {
363 result
= NT_STATUS_NO_MEMORY
;
367 for (i
=0; i
<r
->out
.count
; i
++) {
368 switch(r
->in
.level
) {
370 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
371 r
->out
.info
[i
].info0
.name
, 16));
374 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
375 r
->out
.info
[i
].info1
.name
, 16));
376 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
377 &r
->out
.info
[i
].info1
.version_major
, 1));
378 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
379 &r
->out
.info
[i
].info1
.version_minor
, 1));
380 NDR_GOTO(ndr_pull_uint32(call
->ndr_pull_data
,
381 NDR_SCALARS
, &r
->out
.info
[i
].info1
.servertype
));
382 RAP_GOTO(rap_pull_string(mem_ctx
, call
->ndr_pull_data
,
384 &r
->out
.info
[i
].info1
.comment
));
388 if (DEBUGLEVEL
>= 10) {
389 NDR_PRINT_OUT_DEBUG(rap_NetServerEnum2
, r
);
392 result
= NT_STATUS_OK
;
399 NTSTATUS
smbcli_rap_netservergetinfo(struct smbcli_tree
*tree
,
401 struct rap_WserverGetInfo
*r
)
403 struct rap_call
*call
;
404 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
406 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WserverGetInfo
))) {
407 return NT_STATUS_NO_MEMORY
;
410 rap_cli_push_word(call
, r
->in
.level
);
411 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
412 rap_cli_expect_word(call
);
414 switch(r
->in
.level
) {
416 rap_cli_expect_format(call
, "B16");
419 rap_cli_expect_format(call
, "B16BBDz");
422 result
= NT_STATUS_INVALID_PARAMETER
;
426 if (DEBUGLEVEL
>= 10) {
427 NDR_PRINT_IN_DEBUG(rap_WserverGetInfo
, r
);
430 result
= rap_cli_do_call(tree
, call
);
432 if (!NT_STATUS_IS_OK(result
))
435 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
436 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
437 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
439 switch(r
->in
.level
) {
441 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
442 r
->out
.info
.info0
.name
, 16));
445 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
446 r
->out
.info
.info1
.name
, 16));
447 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
448 &r
->out
.info
.info1
.version_major
, 1));
449 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
450 &r
->out
.info
.info1
.version_minor
, 1));
451 NDR_GOTO(ndr_pull_uint32(call
->ndr_pull_data
,
452 NDR_SCALARS
, &r
->out
.info
.info1
.servertype
));
453 RAP_GOTO(rap_pull_string(mem_ctx
, call
->ndr_pull_data
,
455 &r
->out
.info
.info1
.comment
));
458 if (DEBUGLEVEL
>= 10) {
459 NDR_PRINT_OUT_DEBUG(rap_WserverGetInfo
, r
);
466 static enum ndr_err_code
ndr_pull_rap_NetPrintQEnum_data(struct ndr_pull
*ndr
, struct rap_NetPrintQEnum
*r
)
468 uint32_t cntr_info_0
;
469 TALLOC_CTX
*_mem_save_info_0
;
471 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
472 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
473 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
474 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
475 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
476 NDR_CHECK(ndr_pull_rap_printq_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
478 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
479 NDR_CHECK(ndr_pull_rap_printq_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
481 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
483 return NDR_ERR_SUCCESS
;
486 NTSTATUS
smbcli_rap_netprintqenum(struct smbcli_tree
*tree
,
488 struct rap_NetPrintQEnum
*r
)
490 struct rap_call
*call
;
491 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
493 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQEnum
))) {
494 return NT_STATUS_NO_MEMORY
;
497 rap_cli_push_word(call
, r
->in
.level
);
498 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
499 rap_cli_expect_multiple_entries(call
);
501 switch(r
->in
.level
) {
503 rap_cli_expect_format(call
, "B13");
506 rap_cli_expect_format(call
, "B13BWWWzzzzzWW");
509 rap_cli_expect_format(call
, "B13BWWWzzzzzWN");
510 rap_cli_expect_extra_format(call
, "WB21BB16B10zWWzDDz");
513 rap_cli_expect_format(call
, "zWWWWzzzzWWzzl");
516 rap_cli_expect_format(call
, "zWWWWzzzzWNzzl");
517 rap_cli_expect_extra_format(call
, "WWzWWDDzz");
518 /* no mention of extra format in MS-RAP */
521 rap_cli_expect_format(call
, "z");
524 result
= NT_STATUS_INVALID_PARAMETER
;
528 if (DEBUGLEVEL
>= 10) {
529 NDR_PRINT_IN_DEBUG(rap_NetPrintQEnum
, r
);
532 result
= rap_cli_do_call(tree
, call
);
534 if (!NT_STATUS_IS_OK(result
))
537 result
= NT_STATUS_INVALID_PARAMETER
;
539 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
540 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
541 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
542 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
544 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
546 NDR_GOTO(ndr_pull_rap_NetPrintQEnum_data(call
->ndr_pull_data
, r
));
548 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
550 if (DEBUGLEVEL
>= 10) {
551 NDR_PRINT_OUT_DEBUG(rap_NetPrintQEnum
, r
);
554 result
= NT_STATUS_OK
;
561 NTSTATUS
smbcli_rap_netprintqgetinfo(struct smbcli_tree
*tree
,
563 struct rap_NetPrintQGetInfo
*r
)
565 struct rap_call
*call
;
566 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
568 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQGetInfo
))) {
569 return NT_STATUS_NO_MEMORY
;
572 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
573 rap_cli_push_word(call
, r
->in
.level
);
574 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
575 rap_cli_expect_word(call
);
577 switch(r
->in
.level
) {
579 rap_cli_expect_format(call
, "B13");
582 rap_cli_expect_format(call
, "B13BWWWzzzzzWW");
585 rap_cli_expect_format(call
, "B13BWWWzzzzzWN");
586 rap_cli_expect_extra_format(call
, "WB21BB16B10zWWzDDz");
589 rap_cli_expect_format(call
, "zWWWWzzzzWWzzl");
592 rap_cli_expect_format(call
, "zWWWWzzzzWNzzl");
593 rap_cli_expect_extra_format(call
, "WWzWWDDzz");
594 /* no mention of extra format in MS-RAP */
597 rap_cli_expect_format(call
, "z");
600 result
= NT_STATUS_INVALID_PARAMETER
;
604 if (DEBUGLEVEL
>= 10) {
605 NDR_PRINT_IN_DEBUG(rap_NetPrintQGetInfo
, r
);
608 result
= rap_cli_do_call(tree
, call
);
610 if (!NT_STATUS_IS_OK(result
))
613 result
= NT_STATUS_INVALID_PARAMETER
;
617 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
618 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
619 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
621 if (r
->out
.status
== 0) {
622 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
624 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
625 NDR_GOTO(ndr_pull_rap_printq_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
628 if (DEBUGLEVEL
>= 10) {
629 NDR_PRINT_OUT_DEBUG(rap_NetPrintQGetInfo
, r
);
632 result
= NT_STATUS_OK
;
638 NTSTATUS
smbcli_rap_netprintjobpause(struct smbcli_tree
*tree
,
640 struct rap_NetPrintJobPause
*r
)
642 struct rap_call
*call
;
643 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
645 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobPause
))) {
646 return NT_STATUS_NO_MEMORY
;
649 rap_cli_push_word(call
, r
->in
.JobID
);
651 rap_cli_expect_format(call
, "W");
653 if (DEBUGLEVEL
>= 10) {
654 NDR_PRINT_IN_DEBUG(rap_NetPrintJobPause
, r
);
657 result
= rap_cli_do_call(tree
, call
);
659 if (!NT_STATUS_IS_OK(result
))
662 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
663 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
665 if (DEBUGLEVEL
>= 10) {
666 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobPause
, r
);
674 NTSTATUS
smbcli_rap_netprintjobcontinue(struct smbcli_tree
*tree
,
676 struct rap_NetPrintJobContinue
*r
)
678 struct rap_call
*call
;
679 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
681 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobContinue
))) {
682 return NT_STATUS_NO_MEMORY
;
685 rap_cli_push_word(call
, r
->in
.JobID
);
687 rap_cli_expect_format(call
, "W");
689 if (DEBUGLEVEL
>= 10) {
690 NDR_PRINT_IN_DEBUG(rap_NetPrintJobContinue
, r
);
693 result
= rap_cli_do_call(tree
, call
);
695 if (!NT_STATUS_IS_OK(result
))
698 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
699 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
701 if (DEBUGLEVEL
>= 10) {
702 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobContinue
, r
);
710 NTSTATUS
smbcli_rap_netprintjobdelete(struct smbcli_tree
*tree
,
712 struct rap_NetPrintJobDelete
*r
)
714 struct rap_call
*call
;
715 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
717 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobDel
))) {
718 return NT_STATUS_NO_MEMORY
;
721 rap_cli_push_word(call
, r
->in
.JobID
);
723 rap_cli_expect_format(call
, "W");
725 if (DEBUGLEVEL
>= 10) {
726 NDR_PRINT_IN_DEBUG(rap_NetPrintJobDelete
, r
);
729 result
= rap_cli_do_call(tree
, call
);
731 if (!NT_STATUS_IS_OK(result
))
734 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
735 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
737 if (DEBUGLEVEL
>= 10) {
738 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobDelete
, r
);
746 NTSTATUS
smbcli_rap_netprintqueuepause(struct smbcli_tree
*tree
,
748 struct rap_NetPrintQueuePause
*r
)
750 struct rap_call
*call
;
751 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
753 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQPause
))) {
754 return NT_STATUS_NO_MEMORY
;
757 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
759 rap_cli_expect_format(call
, "");
761 if (DEBUGLEVEL
>= 10) {
762 NDR_PRINT_IN_DEBUG(rap_NetPrintQueuePause
, r
);
765 result
= rap_cli_do_call(tree
, call
);
767 if (!NT_STATUS_IS_OK(result
))
770 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
771 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
773 if (DEBUGLEVEL
>= 10) {
774 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueuePause
, r
);
782 NTSTATUS
smbcli_rap_netprintqueueresume(struct smbcli_tree
*tree
,
784 struct rap_NetPrintQueueResume
*r
)
786 struct rap_call
*call
;
787 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
789 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQContinue
))) {
790 return NT_STATUS_NO_MEMORY
;
793 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
795 rap_cli_expect_format(call
, "");
797 if (DEBUGLEVEL
>= 10) {
798 NDR_PRINT_IN_DEBUG(rap_NetPrintQueueResume
, r
);
801 result
= rap_cli_do_call(tree
, call
);
803 if (!NT_STATUS_IS_OK(result
))
806 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
807 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
809 if (DEBUGLEVEL
>= 10) {
810 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueueResume
, r
);
818 NTSTATUS
smbcli_rap_netprintqueuepurge(struct smbcli_tree
*tree
,
820 struct rap_NetPrintQueuePurge
*r
)
822 struct rap_call
*call
;
823 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
825 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQPurge
))) {
826 return NT_STATUS_NO_MEMORY
;
829 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
831 rap_cli_expect_format(call
, "");
833 if (DEBUGLEVEL
>= 10) {
834 NDR_PRINT_IN_DEBUG(rap_NetPrintQueuePurge
, r
);
837 result
= rap_cli_do_call(tree
, call
);
839 if (!NT_STATUS_IS_OK(result
))
842 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
843 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
845 if (DEBUGLEVEL
>= 10) {
846 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueuePurge
, r
);
854 static enum ndr_err_code
ndr_pull_rap_NetPrintJobEnum_data(struct ndr_pull
*ndr
, struct rap_NetPrintJobEnum
*r
)
856 uint32_t cntr_info_0
;
857 TALLOC_CTX
*_mem_save_info_0
;
859 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
860 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
861 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
862 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
863 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
864 NDR_CHECK(ndr_pull_rap_printj_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
866 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
867 NDR_CHECK(ndr_pull_rap_printj_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
869 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
871 return NDR_ERR_SUCCESS
;
874 NTSTATUS
smbcli_rap_netprintjobenum(struct smbcli_tree
*tree
,
876 struct rap_NetPrintJobEnum
*r
)
878 struct rap_call
*call
;
879 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
881 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobEnum
))) {
882 return NT_STATUS_NO_MEMORY
;
885 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
886 rap_cli_push_word(call
, r
->in
.level
);
887 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
888 rap_cli_expect_multiple_entries(call
);
890 switch(r
->in
.level
) {
892 rap_cli_expect_format(call
, "W");
895 rap_cli_expect_format(call
, "WB21BB16B10zWWzDDz");
898 rap_cli_expect_format(call
, "WWzWWDDzz");
901 rap_cli_expect_format(call
, "WWzWWDDzzzzzzzzzzlz");
904 rap_cli_expect_format(call
, "WWzWWDDzzzzzDDDDDDD");
907 result
= NT_STATUS_INVALID_PARAMETER
;
911 if (DEBUGLEVEL
>= 10) {
912 NDR_PRINT_IN_DEBUG(rap_NetPrintJobEnum
, r
);
915 result
= rap_cli_do_call(tree
, call
);
917 if (!NT_STATUS_IS_OK(result
))
920 result
= NT_STATUS_INVALID_PARAMETER
;
922 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
923 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
924 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
925 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
927 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
929 NDR_GOTO(ndr_pull_rap_NetPrintJobEnum_data(call
->ndr_pull_data
, r
));
931 if (DEBUGLEVEL
>= 10) {
932 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobEnum
, r
);
935 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
937 result
= NT_STATUS_OK
;
944 NTSTATUS
smbcli_rap_netprintjobgetinfo(struct smbcli_tree
*tree
,
946 struct rap_NetPrintJobGetInfo
*r
)
948 struct rap_call
*call
;
949 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
951 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobGetInfo
))) {
952 return NT_STATUS_NO_MEMORY
;
955 rap_cli_push_word(call
, r
->in
.JobID
);
956 rap_cli_push_word(call
, r
->in
.level
);
957 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
958 rap_cli_expect_word(call
);
960 switch(r
->in
.level
) {
962 rap_cli_expect_format(call
, "W");
965 rap_cli_expect_format(call
, "WB21BB16B10zWWzDDz");
968 rap_cli_expect_format(call
, "WWzWWDDzz");
971 rap_cli_expect_format(call
, "WWzWWDDzzzzzzzzzzlz");
974 rap_cli_expect_format(call
, "WWzWWDDzzzzzDDDDDDD");
977 result
= NT_STATUS_INVALID_PARAMETER
;
981 if (DEBUGLEVEL
>= 10) {
982 NDR_PRINT_IN_DEBUG(rap_NetPrintJobGetInfo
, r
);
985 result
= rap_cli_do_call(tree
, call
);
987 if (!NT_STATUS_IS_OK(result
))
990 result
= NT_STATUS_INVALID_PARAMETER
;
992 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
993 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
994 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
996 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
998 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
999 NDR_GOTO(ndr_pull_rap_printj_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1001 if (DEBUGLEVEL
>= 10) {
1002 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobGetInfo
, r
);
1005 result
= NT_STATUS_OK
;
1012 NTSTATUS
smbcli_rap_netprintjobsetinfo(struct smbcli_tree
*tree
,
1013 TALLOC_CTX
*mem_ctx
,
1014 struct rap_NetPrintJobSetInfo
*r
)
1016 struct rap_call
*call
;
1017 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1019 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobSetInfo
))) {
1020 return NT_STATUS_NO_MEMORY
;
1023 rap_cli_push_word(call
, r
->in
.JobID
);
1024 rap_cli_push_word(call
, r
->in
.level
);
1025 rap_cli_push_sendbuf(call
, r
->in
.bufsize
);
1026 rap_cli_push_param(call
, r
->in
.ParamNum
);
1028 switch (r
->in
.ParamNum
) {
1029 case RAP_PARAM_JOBNUM
:
1030 case RAP_PARAM_JOBPOSITION
:
1031 case RAP_PARAM_JOBSTATUS
:
1032 NDR_GOTO(ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.Param
.value
));
1034 case RAP_PARAM_USERNAME
:
1035 case RAP_PARAM_NOTIFYNAME
:
1036 case RAP_PARAM_DATATYPE
:
1037 case RAP_PARAM_PARAMETERS_STRING
:
1038 case RAP_PARAM_JOBSTATUSSTR
:
1039 case RAP_PARAM_JOBCOMMENT
:
1040 NDR_GOTO(ndr_push_string(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.Param
.string
));
1042 case RAP_PARAM_TIMESUBMITTED
:
1043 case RAP_PARAM_JOBSIZE
:
1044 NDR_GOTO(ndr_push_uint32(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.Param
.value4
));
1047 result
= NT_STATUS_INVALID_PARAMETER
;
1051 /* not really sure if this is correct */
1052 rap_cli_expect_format(call
, "WB21BB16B10zWWzDDz");
1054 if (DEBUGLEVEL
>= 10) {
1055 NDR_PRINT_IN_DEBUG(rap_NetPrintJobSetInfo
, r
);
1058 result
= rap_cli_do_call(tree
, call
);
1060 if (!NT_STATUS_IS_OK(result
))
1063 result
= NT_STATUS_INVALID_PARAMETER
;
1065 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1066 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1068 result
= NT_STATUS_OK
;
1070 if (!NT_STATUS_IS_OK(result
)) {
1074 if (DEBUGLEVEL
>= 10) {
1075 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobSetInfo
, r
);
1083 static enum ndr_err_code
ndr_pull_rap_NetPrintDestEnum_data(struct ndr_pull
*ndr
, struct rap_NetPrintDestEnum
*r
)
1085 uint32_t cntr_info_0
;
1086 TALLOC_CTX
*_mem_save_info_0
;
1088 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
1089 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
1090 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
1091 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1092 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
1093 NDR_CHECK(ndr_pull_rap_printdest_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
1095 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1096 NDR_CHECK(ndr_pull_rap_printdest_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
1098 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
1100 return NDR_ERR_SUCCESS
;
1104 NTSTATUS
smbcli_rap_netprintdestenum(struct smbcli_tree
*tree
,
1105 TALLOC_CTX
*mem_ctx
,
1106 struct rap_NetPrintDestEnum
*r
)
1108 struct rap_call
*call
;
1109 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1111 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintDestEnum
))) {
1112 return NT_STATUS_NO_MEMORY
;
1115 rap_cli_push_word(call
, r
->in
.level
);
1116 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1117 rap_cli_expect_multiple_entries(call
);
1119 switch(r
->in
.level
) {
1121 rap_cli_expect_format(call
, "B9");
1124 rap_cli_expect_format(call
, "B9B21WWzW");
1127 rap_cli_expect_format(call
, "z");
1130 rap_cli_expect_format(call
, "zzzWWzzzWW");
1133 result
= NT_STATUS_INVALID_PARAMETER
;
1137 if (DEBUGLEVEL
>= 10) {
1138 NDR_PRINT_IN_DEBUG(rap_NetPrintDestEnum
, r
);
1141 result
= rap_cli_do_call(tree
, call
);
1143 if (!NT_STATUS_IS_OK(result
))
1146 result
= NT_STATUS_INVALID_PARAMETER
;
1148 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1149 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1150 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
1151 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1153 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1155 NDR_GOTO(ndr_pull_rap_NetPrintDestEnum_data(call
->ndr_pull_data
, r
));
1157 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
1159 if (DEBUGLEVEL
>= 10) {
1160 NDR_PRINT_OUT_DEBUG(rap_NetPrintDestEnum
, r
);
1163 result
= NT_STATUS_OK
;
1170 NTSTATUS
smbcli_rap_netprintdestgetinfo(struct smbcli_tree
*tree
,
1171 TALLOC_CTX
*mem_ctx
,
1172 struct rap_NetPrintDestGetInfo
*r
)
1174 struct rap_call
*call
;
1175 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1177 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintDestGetInfo
))) {
1178 return NT_STATUS_NO_MEMORY
;
1181 rap_cli_push_string(call
, r
->in
.PrintDestName
);
1182 rap_cli_push_word(call
, r
->in
.level
);
1183 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1184 rap_cli_expect_word(call
);
1186 switch(r
->in
.level
) {
1188 rap_cli_expect_format(call
, "B9");
1191 rap_cli_expect_format(call
, "B9B21WWzW");
1194 rap_cli_expect_format(call
, "z");
1197 rap_cli_expect_format(call
, "zzzWWzzzWW");
1200 result
= NT_STATUS_INVALID_PARAMETER
;
1204 if (DEBUGLEVEL
>= 10) {
1205 NDR_PRINT_IN_DEBUG(rap_NetPrintDestGetInfo
, r
);
1208 result
= rap_cli_do_call(tree
, call
);
1210 if (!NT_STATUS_IS_OK(result
))
1213 result
= NT_STATUS_INVALID_PARAMETER
;
1215 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1216 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1217 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1219 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1221 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
1222 NDR_GOTO(ndr_pull_rap_printdest_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1224 if (DEBUGLEVEL
>= 10) {
1225 NDR_PRINT_OUT_DEBUG(rap_NetPrintDestGetInfo
, r
);
1228 result
= NT_STATUS_OK
;
1235 NTSTATUS
smbcli_rap_netuserpasswordset2(struct smbcli_tree
*tree
,
1236 TALLOC_CTX
*mem_ctx
,
1237 struct rap_NetUserPasswordSet2
*r
)
1239 struct rap_call
*call
;
1240 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1242 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserPasswordSet2
))) {
1243 return NT_STATUS_NO_MEMORY
;
1246 rap_cli_push_string(call
, r
->in
.UserName
);
1247 rap_cli_push_paramdesc(call
, 'b');
1248 rap_cli_push_paramdesc(call
, '1');
1249 rap_cli_push_paramdesc(call
, '6');
1250 ndr_push_array_uint8(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.OldPassword
, 16);
1251 rap_cli_push_paramdesc(call
, 'b');
1252 rap_cli_push_paramdesc(call
, '1');
1253 rap_cli_push_paramdesc(call
, '6');
1254 ndr_push_array_uint8(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.NewPassword
, 16);
1255 rap_cli_push_word(call
, r
->in
.EncryptedPassword
);
1256 rap_cli_push_word(call
, r
->in
.RealPasswordLength
);
1258 rap_cli_expect_format(call
, "");
1260 if (DEBUGLEVEL
>= 10) {
1261 NDR_PRINT_IN_DEBUG(rap_NetUserPasswordSet2
, r
);
1264 result
= rap_cli_do_call(tree
, call
);
1266 if (!NT_STATUS_IS_OK(result
))
1269 result
= NT_STATUS_INVALID_PARAMETER
;
1271 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1272 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1274 result
= NT_STATUS_OK
;
1276 if (!NT_STATUS_IS_OK(result
)) {
1280 if (DEBUGLEVEL
>= 10) {
1281 NDR_PRINT_OUT_DEBUG(rap_NetUserPasswordSet2
, r
);
1289 NTSTATUS
smbcli_rap_netoemchangepassword(struct smbcli_tree
*tree
,
1290 TALLOC_CTX
*mem_ctx
,
1291 struct rap_NetOEMChangePassword
*r
)
1293 struct rap_call
*call
;
1294 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1296 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_SamOEMChgPasswordUser2_P
))) {
1297 return NT_STATUS_NO_MEMORY
;
1300 rap_cli_push_string(call
, r
->in
.UserName
);
1301 rap_cli_push_sendbuf(call
, 532);
1302 ndr_push_array_uint8(call
->ndr_push_data
, NDR_SCALARS
, r
->in
.crypt_password
, 516);
1303 ndr_push_array_uint8(call
->ndr_push_data
, NDR_SCALARS
, r
->in
.password_hash
, 16);
1305 rap_cli_expect_format(call
, "B516B16");
1307 if (DEBUGLEVEL
>= 10) {
1308 NDR_PRINT_IN_DEBUG(rap_NetOEMChangePassword
, r
);
1311 result
= rap_cli_do_call(tree
, call
);
1313 if (!NT_STATUS_IS_OK(result
))
1316 result
= NT_STATUS_INVALID_PARAMETER
;
1318 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1319 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1321 result
= NT_STATUS_OK
;
1323 if (!NT_STATUS_IS_OK(result
)) {
1327 if (DEBUGLEVEL
>= 10) {
1328 NDR_PRINT_OUT_DEBUG(rap_NetOEMChangePassword
, r
);
1336 NTSTATUS
smbcli_rap_netusergetinfo(struct smbcli_tree
*tree
,
1337 TALLOC_CTX
*mem_ctx
,
1338 struct rap_NetUserGetInfo
*r
)
1340 struct rap_call
*call
;
1341 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1343 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserGetInfo
))) {
1344 return NT_STATUS_NO_MEMORY
;
1347 rap_cli_push_string(call
, r
->in
.UserName
);
1348 rap_cli_push_word(call
, r
->in
.level
);
1349 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1350 rap_cli_expect_word(call
);
1352 switch(r
->in
.level
) {
1354 rap_cli_expect_format(call
, "B21");
1357 rap_cli_expect_format(call
, "B21BB16DWzzWz");
1360 rap_cli_expect_format(call
, "B21BB16DWzzWzDzzzzDDDDWb21WWzWW");
1363 rap_cli_expect_format(call
, "B21Bzzz");
1366 rap_cli_expect_format(call
, "B21BzzzWDDzzDDWWzWzDWb21W");
1369 result
= NT_STATUS_INVALID_PARAMETER
;
1373 if (DEBUGLEVEL
>= 10) {
1374 NDR_PRINT_IN_DEBUG(rap_NetUserGetInfo
, r
);
1377 result
= rap_cli_do_call(tree
, call
);
1379 if (!NT_STATUS_IS_OK(result
))
1382 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1383 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1384 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1386 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1388 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
1389 NDR_GOTO(ndr_pull_rap_netuser_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1391 if (DEBUGLEVEL
>= 10) {
1392 NDR_PRINT_OUT_DEBUG(rap_NetUserGetInfo
, r
);
1395 result
= NT_STATUS_OK
;
1403 static enum ndr_err_code
ndr_pull_rap_NetSessionEnum_data(struct ndr_pull
*ndr
, struct rap_NetSessionEnum
*r
)
1405 uint32_t cntr_info_0
;
1406 TALLOC_CTX
*_mem_save_info_0
;
1408 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
1409 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
1410 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
1411 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1412 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
1413 NDR_CHECK(ndr_pull_rap_session_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
1415 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1416 NDR_CHECK(ndr_pull_rap_session_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
1418 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
1420 return NDR_ERR_SUCCESS
;
1424 NTSTATUS
smbcli_rap_netsessionenum(struct smbcli_tree
*tree
,
1425 TALLOC_CTX
*mem_ctx
,
1426 struct rap_NetSessionEnum
*r
)
1428 struct rap_call
*call
;
1429 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1431 call
= new_rap_cli_call(tree
, RAP_WsessionEnum
);
1434 return NT_STATUS_NO_MEMORY
;
1436 rap_cli_push_word(call
, r
->in
.level
);
1437 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1438 rap_cli_expect_multiple_entries(call
);
1440 switch(r
->in
.level
) {
1442 rap_cli_expect_format(call
, "zzWWWDDDz");
1445 result
= NT_STATUS_INVALID_PARAMETER
;
1449 if (DEBUGLEVEL
>= 10) {
1450 NDR_PRINT_IN_DEBUG(rap_NetSessionEnum
, r
);
1453 result
= rap_cli_do_call(tree
, call
);
1455 if (!NT_STATUS_IS_OK(result
))
1458 result
= NT_STATUS_INVALID_PARAMETER
;
1460 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1461 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1462 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
1463 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1465 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1467 NDR_GOTO(ndr_pull_rap_NetSessionEnum_data(call
->ndr_pull_data
, r
));
1469 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
1471 if (DEBUGLEVEL
>= 10) {
1472 NDR_PRINT_OUT_DEBUG(rap_NetSessionEnum
, r
);
1475 result
= NT_STATUS_OK
;
1482 NTSTATUS
smbcli_rap_netsessiongetinfo(struct smbcli_tree
*tree
,
1483 TALLOC_CTX
*mem_ctx
,
1484 struct rap_NetSessionGetInfo
*r
)
1486 struct rap_call
*call
;
1487 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1489 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WsessionGetInfo
))) {
1490 return NT_STATUS_NO_MEMORY
;
1493 rap_cli_push_string(call
, r
->in
.SessionName
);
1494 rap_cli_push_word(call
, r
->in
.level
);
1495 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1496 rap_cli_expect_word(call
);
1498 switch(r
->in
.level
) {
1500 rap_cli_expect_format(call
, "zzWWWDDDz");
1503 result
= NT_STATUS_INVALID_PARAMETER
;
1507 if (DEBUGLEVEL
>= 10) {
1508 NDR_PRINT_IN_DEBUG(rap_NetSessionGetInfo
, r
);
1511 result
= rap_cli_do_call(tree
, call
);
1513 if (!NT_STATUS_IS_OK(result
))
1516 result
= NT_STATUS_INVALID_PARAMETER
;
1518 ZERO_STRUCT(r
->out
);
1520 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1521 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1522 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1524 if (r
->out
.status
== 0 && r
->out
.available
) {
1525 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1527 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
1528 NDR_GOTO(ndr_pull_rap_session_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1531 if (DEBUGLEVEL
>= 10) {
1532 NDR_PRINT_OUT_DEBUG(rap_NetSessionGetInfo
, r
);
1535 result
= NT_STATUS_OK
;
1542 NTSTATUS
smbcli_rap_netuseradd(struct smbcli_tree
*tree
,
1543 TALLOC_CTX
*mem_ctx
,
1544 struct rap_NetUserAdd
*r
)
1546 struct rap_call
*call
;
1547 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1549 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserAdd2
))) {
1550 return NT_STATUS_NO_MEMORY
;
1553 rap_cli_push_word(call
, r
->in
.level
);
1554 rap_cli_push_sendbuf(call
, r
->in
.bufsize
);
1555 rap_cli_push_word(call
, r
->in
.pwdlength
);
1556 rap_cli_push_word(call
, r
->in
.unknown
);
1558 switch (r
->in
.level
) {
1560 rap_cli_expect_format(call
, "B21BB16DWzzWz");
1563 result
= NT_STATUS_INVALID_PARAMETER
;
1567 if (DEBUGLEVEL
>= 10) {
1568 NDR_PRINT_IN_DEBUG(rap_NetUserAdd
, r
);
1571 NDR_GOTO(ndr_push_set_switch_value(call
->ndr_push_data
, &r
->in
.info
, r
->in
.level
));
1572 NDR_GOTO(ndr_push_rap_netuser_info(call
->ndr_push_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->in
.info
));
1574 result
= rap_cli_do_call(tree
, call
);
1576 if (!NT_STATUS_IS_OK(result
))
1579 result
= NT_STATUS_INVALID_PARAMETER
;
1581 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1582 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1584 result
= NT_STATUS_OK
;
1586 if (!NT_STATUS_IS_OK(result
)) {
1590 if (DEBUGLEVEL
>= 10) {
1591 NDR_PRINT_OUT_DEBUG(rap_NetUserAdd
, r
);
1599 NTSTATUS
smbcli_rap_netuserdelete(struct smbcli_tree
*tree
,
1600 TALLOC_CTX
*mem_ctx
,
1601 struct rap_NetUserDelete
*r
)
1603 struct rap_call
*call
;
1604 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1606 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserDel
))) {
1607 return NT_STATUS_NO_MEMORY
;
1610 rap_cli_push_string(call
, r
->in
.UserName
);
1612 rap_cli_expect_format(call
, "");
1613 rap_cli_expect_extra_format(call
, "");
1615 if (DEBUGLEVEL
>= 10) {
1616 NDR_PRINT_IN_DEBUG(rap_NetUserDelete
, r
);
1619 result
= rap_cli_do_call(tree
, call
);
1621 if (!NT_STATUS_IS_OK(result
))
1624 result
= NT_STATUS_INVALID_PARAMETER
;
1626 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1627 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1629 result
= NT_STATUS_OK
;
1631 if (!NT_STATUS_IS_OK(result
)) {
1635 if (DEBUGLEVEL
>= 10) {
1636 NDR_PRINT_OUT_DEBUG(rap_NetUserDelete
, r
);
1644 NTSTATUS
smbcli_rap_netremotetod(struct smbcli_tree
*tree
,
1645 TALLOC_CTX
*mem_ctx
,
1646 struct rap_NetRemoteTOD
*r
)
1648 struct rap_call
*call
;
1649 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1651 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_NetRemoteTOD
))) {
1652 return NT_STATUS_NO_MEMORY
;
1655 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1657 rap_cli_expect_format(call
, "DDBBBBWWBBWB");
1658 rap_cli_expect_extra_format(call
, "");
1660 if (DEBUGLEVEL
>= 10) {
1661 NDR_PRINT_IN_DEBUG(rap_NetRemoteTOD
, r
);
1664 result
= rap_cli_do_call(tree
, call
);
1666 if (!NT_STATUS_IS_OK(result
))
1669 result
= NT_STATUS_INVALID_PARAMETER
;
1671 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1672 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1674 NDR_GOTO(ndr_pull_rap_TimeOfDayInfo(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.tod
));
1676 result
= NT_STATUS_OK
;
1678 if (!NT_STATUS_IS_OK(result
)) {
1682 if (DEBUGLEVEL
>= 10) {
1683 NDR_PRINT_OUT_DEBUG(rap_NetRemoteTOD
, r
);