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(mem_ctx
, struct rap_call
);
38 call
->callno
= callno
;
39 call
->rcv_paramlen
= 4;
41 call
->paramdesc
= NULL
;
42 call
->datadesc
= NULL
;
43 call
->auxdatadesc
= NULL
;
45 call
->ndr_push_param
= ndr_push_init_ctx(mem_ctx
);
46 call
->ndr_push_param
->flags
= RAPNDR_FLAGS
;
48 call
->ndr_push_data
= ndr_push_init_ctx(mem_ctx
);
49 call
->ndr_push_data
->flags
= RAPNDR_FLAGS
;
54 static void rap_cli_push_paramdesc(struct rap_call
*call
, char desc
)
58 if (call
->paramdesc
!= NULL
)
59 len
= strlen(call
->paramdesc
);
61 call
->paramdesc
= talloc_realloc(call
,
66 call
->paramdesc
[len
] = desc
;
67 call
->paramdesc
[len
+1] = '\0';
70 static void rap_cli_push_word(struct rap_call
*call
, uint16_t val
)
72 rap_cli_push_paramdesc(call
, 'W');
73 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, val
);
76 static void rap_cli_push_dword(struct rap_call
*call
, uint32_t val
)
78 rap_cli_push_paramdesc(call
, 'D');
79 ndr_push_uint32(call
->ndr_push_param
, NDR_SCALARS
, val
);
82 static void rap_cli_push_rcvbuf(struct rap_call
*call
, int len
)
84 rap_cli_push_paramdesc(call
, 'r');
85 rap_cli_push_paramdesc(call
, 'L');
86 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, len
);
87 call
->rcv_datalen
= len
;
90 static void rap_cli_push_sendbuf(struct rap_call
*call
, int len
)
92 rap_cli_push_paramdesc(call
, 's');
93 rap_cli_push_paramdesc(call
, 'T');
94 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, len
);
97 static void rap_cli_push_param(struct rap_call
*call
, uint16_t val
)
99 rap_cli_push_paramdesc(call
, 'P');
100 ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, val
);
103 static void rap_cli_expect_multiple_entries(struct rap_call
*call
)
105 rap_cli_push_paramdesc(call
, 'e');
106 rap_cli_push_paramdesc(call
, 'h');
107 call
->rcv_paramlen
+= 4; /* uint16_t entry count, uint16_t total */
110 static void rap_cli_expect_word(struct rap_call
*call
)
112 rap_cli_push_paramdesc(call
, 'h');
113 call
->rcv_paramlen
+= 2;
116 static void rap_cli_push_string(struct rap_call
*call
, const char *str
)
119 rap_cli_push_paramdesc(call
, 'O');
122 rap_cli_push_paramdesc(call
, 'z');
123 ndr_push_string(call
->ndr_push_param
, NDR_SCALARS
, str
);
126 static void rap_cli_expect_format(struct rap_call
*call
, const char *format
)
128 call
->datadesc
= format
;
131 static void rap_cli_expect_extra_format(struct rap_call
*call
, const char *format
)
133 call
->auxdatadesc
= format
;
136 static NTSTATUS
rap_pull_string(TALLOC_CTX
*mem_ctx
, struct ndr_pull
*ndr
,
137 uint16_t convert
, const char **dest
)
139 uint16_t string_offset
;
144 NDR_RETURN(ndr_pull_uint16(ndr
, NDR_SCALARS
, &string_offset
));
145 NDR_RETURN(ndr_pull_uint16(ndr
, NDR_SCALARS
, &ignore
));
147 string_offset
-= convert
;
149 if (string_offset
+1 > ndr
->data_size
)
150 return NT_STATUS_INVALID_PARAMETER
;
152 p
= (const char *)(ndr
->data
+ string_offset
);
153 len
= strnlen(p
, ndr
->data_size
-string_offset
);
155 if ( string_offset
+ len
+ 1 > ndr
->data_size
)
156 return NT_STATUS_INVALID_PARAMETER
;
158 *dest
= talloc_zero_array(mem_ctx
, char, len
+1);
159 pull_string(discard_const_p(char, *dest
), p
, len
+1, len
, STR_ASCII
);
164 NTSTATUS
rap_cli_do_call(struct smbcli_tree
*tree
,
165 struct rap_call
*call
)
168 DATA_BLOB param_blob
;
170 struct ndr_push
*params
;
171 struct ndr_push
*data
;
172 struct smb_trans2 trans
;
174 params
= ndr_push_init_ctx(call
);
177 return NT_STATUS_NO_MEMORY
;
179 params
->flags
= RAPNDR_FLAGS
;
181 data
= ndr_push_init_ctx(call
);
184 return NT_STATUS_NO_MEMORY
;
186 data
->flags
= RAPNDR_FLAGS
;
188 trans
.in
.max_param
= call
->rcv_paramlen
;
189 trans
.in
.max_data
= call
->rcv_datalen
;
190 trans
.in
.max_setup
= 0;
192 trans
.in
.timeout
= 0;
193 trans
.in
.setup_count
= 0;
194 trans
.in
.setup
= NULL
;
195 trans
.in
.trans_name
= "\\PIPE\\LANMAN";
197 NDR_RETURN(ndr_push_uint16(params
, NDR_SCALARS
, call
->callno
));
199 NDR_RETURN(ndr_push_string(params
, NDR_SCALARS
, call
->paramdesc
));
201 NDR_RETURN(ndr_push_string(params
, NDR_SCALARS
, call
->datadesc
));
203 param_blob
= ndr_push_blob(call
->ndr_push_param
);
204 NDR_RETURN(ndr_push_bytes(params
, param_blob
.data
,
207 data_blob
= ndr_push_blob(call
->ndr_push_data
);
208 NDR_RETURN(ndr_push_bytes(data
, data_blob
.data
,
211 if (call
->auxdatadesc
)
212 NDR_RETURN(ndr_push_string(params
, NDR_SCALARS
, call
->auxdatadesc
));
214 trans
.in
.params
= ndr_push_blob(params
);
215 trans
.in
.data
= ndr_push_blob(data
);
217 result
= smb_raw_trans(tree
, call
, &trans
);
219 if (!NT_STATUS_IS_OK(result
))
222 call
->ndr_pull_param
= ndr_pull_init_blob(&trans
.out
.params
, call
);
223 call
->ndr_pull_param
->flags
= RAPNDR_FLAGS
;
225 call
->ndr_pull_data
= ndr_pull_init_blob(&trans
.out
.data
, call
);
226 call
->ndr_pull_data
->flags
= RAPNDR_FLAGS
;
232 NTSTATUS
smbcli_rap_netshareenum(struct smbcli_tree
*tree
,
234 struct rap_NetShareEnum
*r
)
236 struct rap_call
*call
;
237 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
240 call
= new_rap_cli_call(tree
, RAP_WshareEnum
);
243 return NT_STATUS_NO_MEMORY
;
245 rap_cli_push_word(call
, r
->in
.level
); /* Level */
246 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
247 rap_cli_expect_multiple_entries(call
);
249 switch(r
->in
.level
) {
251 rap_cli_expect_format(call
, "B13");
254 rap_cli_expect_format(call
, "B13BWz");
258 if (DEBUGLEVEL
>= 10) {
259 NDR_PRINT_IN_DEBUG(rap_NetShareEnum
, r
);
262 result
= rap_cli_do_call(tree
, call
);
264 if (!NT_STATUS_IS_OK(result
))
267 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
268 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
269 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
270 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
272 r
->out
.info
= talloc_array(mem_ctx
, union rap_share_info
, r
->out
.count
);
274 if (r
->out
.info
== NULL
) {
275 result
= NT_STATUS_NO_MEMORY
;
279 for (i
=0; i
<r
->out
.count
; i
++) {
280 switch(r
->in
.level
) {
282 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
283 r
->out
.info
[i
].info0
.share_name
, 13));
286 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
287 r
->out
.info
[i
].info1
.share_name
, 13));
288 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
289 &r
->out
.info
[i
].info1
.reserved1
, 1));
290 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_data
,
291 NDR_SCALARS
, &r
->out
.info
[i
].info1
.share_type
));
292 RAP_GOTO(rap_pull_string(mem_ctx
, call
->ndr_pull_data
,
294 &r
->out
.info
[i
].info1
.comment
));
299 if (DEBUGLEVEL
>= 10) {
300 NDR_PRINT_OUT_DEBUG(rap_NetShareEnum
, r
);
302 result
= NT_STATUS_OK
;
309 NTSTATUS
smbcli_rap_netserverenum2(struct smbcli_tree
*tree
,
311 struct rap_NetServerEnum2
*r
)
313 struct rap_call
*call
;
314 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
317 call
= new_rap_cli_call(mem_ctx
, RAP_NetServerEnum2
);
320 return NT_STATUS_NO_MEMORY
;
322 rap_cli_push_word(call
, r
->in
.level
);
323 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
324 rap_cli_expect_multiple_entries(call
);
325 rap_cli_push_dword(call
, r
->in
.servertype
);
326 rap_cli_push_string(call
, r
->in
.domain
);
328 switch(r
->in
.level
) {
330 rap_cli_expect_format(call
, "B16");
333 rap_cli_expect_format(call
, "B16BBDz");
337 if (DEBUGLEVEL
>= 10) {
338 NDR_PRINT_IN_DEBUG(rap_NetServerEnum2
, r
);
341 result
= rap_cli_do_call(tree
, call
);
343 if (!NT_STATUS_IS_OK(result
))
346 result
= NT_STATUS_INVALID_PARAMETER
;
348 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
349 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
350 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
351 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
353 r
->out
.info
= talloc_array(mem_ctx
, union rap_server_info
, r
->out
.count
);
355 if (r
->out
.info
== NULL
) {
356 result
= NT_STATUS_NO_MEMORY
;
360 for (i
=0; i
<r
->out
.count
; i
++) {
361 switch(r
->in
.level
) {
363 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
364 r
->out
.info
[i
].info0
.name
, 16));
367 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
368 r
->out
.info
[i
].info1
.name
, 16));
369 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
370 &r
->out
.info
[i
].info1
.version_major
, 1));
371 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
372 &r
->out
.info
[i
].info1
.version_minor
, 1));
373 NDR_GOTO(ndr_pull_uint32(call
->ndr_pull_data
,
374 NDR_SCALARS
, &r
->out
.info
[i
].info1
.servertype
));
375 RAP_GOTO(rap_pull_string(mem_ctx
, call
->ndr_pull_data
,
377 &r
->out
.info
[i
].info1
.comment
));
381 if (DEBUGLEVEL
>= 10) {
382 NDR_PRINT_OUT_DEBUG(rap_NetServerEnum2
, r
);
385 result
= NT_STATUS_OK
;
392 NTSTATUS
smbcli_rap_netservergetinfo(struct smbcli_tree
*tree
,
394 struct rap_WserverGetInfo
*r
)
396 struct rap_call
*call
;
397 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
399 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WserverGetInfo
))) {
400 return NT_STATUS_NO_MEMORY
;
403 rap_cli_push_word(call
, r
->in
.level
);
404 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
405 rap_cli_expect_word(call
);
407 switch(r
->in
.level
) {
409 rap_cli_expect_format(call
, "B16");
412 rap_cli_expect_format(call
, "B16BBDz");
415 result
= NT_STATUS_INVALID_PARAMETER
;
419 if (DEBUGLEVEL
>= 10) {
420 NDR_PRINT_IN_DEBUG(rap_WserverGetInfo
, r
);
423 result
= rap_cli_do_call(tree
, call
);
425 if (!NT_STATUS_IS_OK(result
))
428 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
429 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
430 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
432 switch(r
->in
.level
) {
434 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
435 r
->out
.info
.info0
.name
, 16));
438 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
439 r
->out
.info
.info1
.name
, 16));
440 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
441 &r
->out
.info
.info1
.version_major
, 1));
442 NDR_GOTO(ndr_pull_bytes(call
->ndr_pull_data
,
443 &r
->out
.info
.info1
.version_minor
, 1));
444 NDR_GOTO(ndr_pull_uint32(call
->ndr_pull_data
,
445 NDR_SCALARS
, &r
->out
.info
.info1
.servertype
));
446 RAP_GOTO(rap_pull_string(mem_ctx
, call
->ndr_pull_data
,
448 &r
->out
.info
.info1
.comment
));
451 if (DEBUGLEVEL
>= 10) {
452 NDR_PRINT_OUT_DEBUG(rap_WserverGetInfo
, r
);
459 static enum ndr_err_code
ndr_pull_rap_NetPrintQEnum_data(struct ndr_pull
*ndr
, struct rap_NetPrintQEnum
*r
)
461 uint32_t cntr_info_0
;
462 TALLOC_CTX
*_mem_save_info_0
;
464 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
465 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
466 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
467 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
468 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
469 NDR_CHECK(ndr_pull_rap_printq_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
471 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
472 NDR_CHECK(ndr_pull_rap_printq_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
474 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
476 return NDR_ERR_SUCCESS
;
479 NTSTATUS
smbcli_rap_netprintqenum(struct smbcli_tree
*tree
,
481 struct rap_NetPrintQEnum
*r
)
483 struct rap_call
*call
;
484 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
486 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQEnum
))) {
487 return NT_STATUS_NO_MEMORY
;
490 rap_cli_push_word(call
, r
->in
.level
);
491 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
492 rap_cli_expect_multiple_entries(call
);
494 switch(r
->in
.level
) {
496 rap_cli_expect_format(call
, "B13");
499 rap_cli_expect_format(call
, "B13BWWWzzzzzWW");
502 rap_cli_expect_format(call
, "B13BWWWzzzzzWN");
503 rap_cli_expect_extra_format(call
, "WB21BB16B10zWWzDDz");
506 rap_cli_expect_format(call
, "zWWWWzzzzWWzzl");
509 rap_cli_expect_format(call
, "zWWWWzzzzWNzzl");
510 rap_cli_expect_extra_format(call
, "WWzWWDDzz");
511 /* no mention of extra format in MS-RAP */
514 rap_cli_expect_format(call
, "z");
517 result
= NT_STATUS_INVALID_PARAMETER
;
521 if (DEBUGLEVEL
>= 10) {
522 NDR_PRINT_IN_DEBUG(rap_NetPrintQEnum
, r
);
525 result
= rap_cli_do_call(tree
, call
);
527 if (!NT_STATUS_IS_OK(result
))
530 result
= NT_STATUS_INVALID_PARAMETER
;
532 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
533 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
534 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
535 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
537 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
539 NDR_GOTO(ndr_pull_rap_NetPrintQEnum_data(call
->ndr_pull_data
, r
));
541 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
543 if (DEBUGLEVEL
>= 10) {
544 NDR_PRINT_OUT_DEBUG(rap_NetPrintQEnum
, r
);
547 result
= NT_STATUS_OK
;
554 NTSTATUS
smbcli_rap_netprintqgetinfo(struct smbcli_tree
*tree
,
556 struct rap_NetPrintQGetInfo
*r
)
558 struct rap_call
*call
;
559 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
561 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQGetInfo
))) {
562 return NT_STATUS_NO_MEMORY
;
565 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
566 rap_cli_push_word(call
, r
->in
.level
);
567 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
568 rap_cli_expect_word(call
);
570 switch(r
->in
.level
) {
572 rap_cli_expect_format(call
, "B13");
575 rap_cli_expect_format(call
, "B13BWWWzzzzzWW");
578 rap_cli_expect_format(call
, "B13BWWWzzzzzWN");
579 rap_cli_expect_extra_format(call
, "WB21BB16B10zWWzDDz");
582 rap_cli_expect_format(call
, "zWWWWzzzzWWzzl");
585 rap_cli_expect_format(call
, "zWWWWzzzzWNzzl");
586 rap_cli_expect_extra_format(call
, "WWzWWDDzz");
587 /* no mention of extra format in MS-RAP */
590 rap_cli_expect_format(call
, "z");
593 result
= NT_STATUS_INVALID_PARAMETER
;
597 if (DEBUGLEVEL
>= 10) {
598 NDR_PRINT_IN_DEBUG(rap_NetPrintQGetInfo
, r
);
601 result
= rap_cli_do_call(tree
, call
);
603 if (!NT_STATUS_IS_OK(result
))
606 result
= NT_STATUS_INVALID_PARAMETER
;
610 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
611 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
612 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
614 if (r
->out
.status
== 0) {
615 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
617 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
618 NDR_GOTO(ndr_pull_rap_printq_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
621 if (DEBUGLEVEL
>= 10) {
622 NDR_PRINT_OUT_DEBUG(rap_NetPrintQGetInfo
, r
);
625 result
= NT_STATUS_OK
;
631 NTSTATUS
smbcli_rap_netprintjobpause(struct smbcli_tree
*tree
,
633 struct rap_NetPrintJobPause
*r
)
635 struct rap_call
*call
;
636 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
638 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobPause
))) {
639 return NT_STATUS_NO_MEMORY
;
642 rap_cli_push_word(call
, r
->in
.JobID
);
644 rap_cli_expect_format(call
, "W");
646 if (DEBUGLEVEL
>= 10) {
647 NDR_PRINT_IN_DEBUG(rap_NetPrintJobPause
, r
);
650 result
= rap_cli_do_call(tree
, call
);
652 if (!NT_STATUS_IS_OK(result
))
655 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
656 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
658 if (DEBUGLEVEL
>= 10) {
659 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobPause
, r
);
667 NTSTATUS
smbcli_rap_netprintjobcontinue(struct smbcli_tree
*tree
,
669 struct rap_NetPrintJobContinue
*r
)
671 struct rap_call
*call
;
672 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
674 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobContinue
))) {
675 return NT_STATUS_NO_MEMORY
;
678 rap_cli_push_word(call
, r
->in
.JobID
);
680 rap_cli_expect_format(call
, "W");
682 if (DEBUGLEVEL
>= 10) {
683 NDR_PRINT_IN_DEBUG(rap_NetPrintJobContinue
, r
);
686 result
= rap_cli_do_call(tree
, call
);
688 if (!NT_STATUS_IS_OK(result
))
691 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
692 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
694 if (DEBUGLEVEL
>= 10) {
695 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobContinue
, r
);
703 NTSTATUS
smbcli_rap_netprintjobdelete(struct smbcli_tree
*tree
,
705 struct rap_NetPrintJobDelete
*r
)
707 struct rap_call
*call
;
708 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
710 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobDel
))) {
711 return NT_STATUS_NO_MEMORY
;
714 rap_cli_push_word(call
, r
->in
.JobID
);
716 rap_cli_expect_format(call
, "W");
718 if (DEBUGLEVEL
>= 10) {
719 NDR_PRINT_IN_DEBUG(rap_NetPrintJobDelete
, r
);
722 result
= rap_cli_do_call(tree
, call
);
724 if (!NT_STATUS_IS_OK(result
))
727 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
728 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
730 if (DEBUGLEVEL
>= 10) {
731 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobDelete
, r
);
739 NTSTATUS
smbcli_rap_netprintqueuepause(struct smbcli_tree
*tree
,
741 struct rap_NetPrintQueuePause
*r
)
743 struct rap_call
*call
;
744 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
746 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQPause
))) {
747 return NT_STATUS_NO_MEMORY
;
750 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
752 rap_cli_expect_format(call
, "");
754 if (DEBUGLEVEL
>= 10) {
755 NDR_PRINT_IN_DEBUG(rap_NetPrintQueuePause
, r
);
758 result
= rap_cli_do_call(tree
, call
);
760 if (!NT_STATUS_IS_OK(result
))
763 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
764 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
766 if (DEBUGLEVEL
>= 10) {
767 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueuePause
, r
);
775 NTSTATUS
smbcli_rap_netprintqueueresume(struct smbcli_tree
*tree
,
777 struct rap_NetPrintQueueResume
*r
)
779 struct rap_call
*call
;
780 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
782 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQContinue
))) {
783 return NT_STATUS_NO_MEMORY
;
786 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
788 rap_cli_expect_format(call
, "");
790 if (DEBUGLEVEL
>= 10) {
791 NDR_PRINT_IN_DEBUG(rap_NetPrintQueueResume
, r
);
794 result
= rap_cli_do_call(tree
, call
);
796 if (!NT_STATUS_IS_OK(result
))
799 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
800 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
802 if (DEBUGLEVEL
>= 10) {
803 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueueResume
, r
);
811 NTSTATUS
smbcli_rap_netprintqueuepurge(struct smbcli_tree
*tree
,
813 struct rap_NetPrintQueuePurge
*r
)
815 struct rap_call
*call
;
816 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
818 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintQPurge
))) {
819 return NT_STATUS_NO_MEMORY
;
822 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
824 rap_cli_expect_format(call
, "");
826 if (DEBUGLEVEL
>= 10) {
827 NDR_PRINT_IN_DEBUG(rap_NetPrintQueuePurge
, r
);
830 result
= rap_cli_do_call(tree
, call
);
832 if (!NT_STATUS_IS_OK(result
))
835 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
836 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
838 if (DEBUGLEVEL
>= 10) {
839 NDR_PRINT_OUT_DEBUG(rap_NetPrintQueuePurge
, r
);
847 static enum ndr_err_code
ndr_pull_rap_NetPrintJobEnum_data(struct ndr_pull
*ndr
, struct rap_NetPrintJobEnum
*r
)
849 uint32_t cntr_info_0
;
850 TALLOC_CTX
*_mem_save_info_0
;
852 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
853 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
854 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
855 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
856 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
857 NDR_CHECK(ndr_pull_rap_printj_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
859 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
860 NDR_CHECK(ndr_pull_rap_printj_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
862 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
864 return NDR_ERR_SUCCESS
;
867 NTSTATUS
smbcli_rap_netprintjobenum(struct smbcli_tree
*tree
,
869 struct rap_NetPrintJobEnum
*r
)
871 struct rap_call
*call
;
872 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
874 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobEnum
))) {
875 return NT_STATUS_NO_MEMORY
;
878 rap_cli_push_string(call
, r
->in
.PrintQueueName
);
879 rap_cli_push_word(call
, r
->in
.level
);
880 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
881 rap_cli_expect_multiple_entries(call
);
883 switch(r
->in
.level
) {
885 rap_cli_expect_format(call
, "W");
888 rap_cli_expect_format(call
, "WB21BB16B10zWWzDDz");
891 rap_cli_expect_format(call
, "WWzWWDDzz");
894 rap_cli_expect_format(call
, "WWzWWDDzzzzzzzzzzlz");
897 rap_cli_expect_format(call
, "WWzWWDDzzzzzDDDDDDD");
900 result
= NT_STATUS_INVALID_PARAMETER
;
904 if (DEBUGLEVEL
>= 10) {
905 NDR_PRINT_IN_DEBUG(rap_NetPrintJobEnum
, r
);
908 result
= rap_cli_do_call(tree
, call
);
910 if (!NT_STATUS_IS_OK(result
))
913 result
= NT_STATUS_INVALID_PARAMETER
;
915 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
916 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
917 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
918 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
920 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
922 NDR_GOTO(ndr_pull_rap_NetPrintJobEnum_data(call
->ndr_pull_data
, r
));
924 if (DEBUGLEVEL
>= 10) {
925 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobEnum
, r
);
928 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
930 result
= NT_STATUS_OK
;
937 NTSTATUS
smbcli_rap_netprintjobgetinfo(struct smbcli_tree
*tree
,
939 struct rap_NetPrintJobGetInfo
*r
)
941 struct rap_call
*call
;
942 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
944 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobGetInfo
))) {
945 return NT_STATUS_NO_MEMORY
;
948 rap_cli_push_word(call
, r
->in
.JobID
);
949 rap_cli_push_word(call
, r
->in
.level
);
950 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
951 rap_cli_expect_word(call
);
953 switch(r
->in
.level
) {
955 rap_cli_expect_format(call
, "W");
958 rap_cli_expect_format(call
, "WB21BB16B10zWWzDDz");
961 rap_cli_expect_format(call
, "WWzWWDDzz");
964 rap_cli_expect_format(call
, "WWzWWDDzzzzzzzzzzlz");
967 rap_cli_expect_format(call
, "WWzWWDDzzzzzDDDDDDD");
970 result
= NT_STATUS_INVALID_PARAMETER
;
974 if (DEBUGLEVEL
>= 10) {
975 NDR_PRINT_IN_DEBUG(rap_NetPrintJobGetInfo
, r
);
978 result
= rap_cli_do_call(tree
, call
);
980 if (!NT_STATUS_IS_OK(result
))
983 result
= NT_STATUS_INVALID_PARAMETER
;
985 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
986 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
987 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
989 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
991 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
992 NDR_GOTO(ndr_pull_rap_printj_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
994 if (DEBUGLEVEL
>= 10) {
995 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobGetInfo
, r
);
998 result
= NT_STATUS_OK
;
1005 NTSTATUS
smbcli_rap_netprintjobsetinfo(struct smbcli_tree
*tree
,
1006 TALLOC_CTX
*mem_ctx
,
1007 struct rap_NetPrintJobSetInfo
*r
)
1009 struct rap_call
*call
;
1010 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1012 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintJobSetInfo
))) {
1013 return NT_STATUS_NO_MEMORY
;
1016 rap_cli_push_word(call
, r
->in
.JobID
);
1017 rap_cli_push_word(call
, r
->in
.level
);
1018 rap_cli_push_sendbuf(call
, r
->in
.bufsize
);
1019 rap_cli_push_param(call
, r
->in
.ParamNum
);
1021 switch (r
->in
.ParamNum
) {
1022 case RAP_PARAM_JOBNUM
:
1023 case RAP_PARAM_JOBPOSITION
:
1024 case RAP_PARAM_JOBSTATUS
:
1025 NDR_GOTO(ndr_push_uint16(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.Param
.value
));
1027 case RAP_PARAM_USERNAME
:
1028 case RAP_PARAM_NOTIFYNAME
:
1029 case RAP_PARAM_DATATYPE
:
1030 case RAP_PARAM_PARAMETERS_STRING
:
1031 case RAP_PARAM_JOBSTATUSSTR
:
1032 case RAP_PARAM_JOBCOMMENT
:
1033 NDR_GOTO(ndr_push_string(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.Param
.string
));
1035 case RAP_PARAM_TIMESUBMITTED
:
1036 case RAP_PARAM_JOBSIZE
:
1037 NDR_GOTO(ndr_push_uint32(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.Param
.value4
));
1040 result
= NT_STATUS_INVALID_PARAMETER
;
1044 /* not really sure if this is correct */
1045 rap_cli_expect_format(call
, "WB21BB16B10zWWzDDz");
1047 if (DEBUGLEVEL
>= 10) {
1048 NDR_PRINT_IN_DEBUG(rap_NetPrintJobSetInfo
, r
);
1051 result
= rap_cli_do_call(tree
, call
);
1053 if (!NT_STATUS_IS_OK(result
))
1056 result
= NT_STATUS_INVALID_PARAMETER
;
1058 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1059 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1061 result
= NT_STATUS_OK
;
1063 if (!NT_STATUS_IS_OK(result
)) {
1067 if (DEBUGLEVEL
>= 10) {
1068 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobSetInfo
, r
);
1076 static enum ndr_err_code
ndr_pull_rap_NetPrintDestEnum_data(struct ndr_pull
*ndr
, struct rap_NetPrintDestEnum
*r
)
1078 uint32_t cntr_info_0
;
1079 TALLOC_CTX
*_mem_save_info_0
;
1081 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
1082 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
1083 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
1084 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1085 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
1086 NDR_CHECK(ndr_pull_rap_printdest_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
1088 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1089 NDR_CHECK(ndr_pull_rap_printdest_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
1091 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
1093 return NDR_ERR_SUCCESS
;
1097 NTSTATUS
smbcli_rap_netprintdestenum(struct smbcli_tree
*tree
,
1098 TALLOC_CTX
*mem_ctx
,
1099 struct rap_NetPrintDestEnum
*r
)
1101 struct rap_call
*call
;
1102 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1104 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintDestEnum
))) {
1105 return NT_STATUS_NO_MEMORY
;
1108 rap_cli_push_word(call
, r
->in
.level
);
1109 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1110 rap_cli_expect_multiple_entries(call
);
1112 switch(r
->in
.level
) {
1114 rap_cli_expect_format(call
, "B9");
1117 rap_cli_expect_format(call
, "B9B21WWzW");
1120 rap_cli_expect_format(call
, "z");
1123 rap_cli_expect_format(call
, "zzzWWzzzWW");
1126 result
= NT_STATUS_INVALID_PARAMETER
;
1130 if (DEBUGLEVEL
>= 10) {
1131 NDR_PRINT_IN_DEBUG(rap_NetPrintDestEnum
, r
);
1134 result
= rap_cli_do_call(tree
, call
);
1136 if (!NT_STATUS_IS_OK(result
))
1139 result
= NT_STATUS_INVALID_PARAMETER
;
1141 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1142 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1143 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
1144 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1146 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1148 NDR_GOTO(ndr_pull_rap_NetPrintDestEnum_data(call
->ndr_pull_data
, r
));
1150 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
1152 if (DEBUGLEVEL
>= 10) {
1153 NDR_PRINT_OUT_DEBUG(rap_NetPrintDestEnum
, r
);
1156 result
= NT_STATUS_OK
;
1163 NTSTATUS
smbcli_rap_netprintdestgetinfo(struct smbcli_tree
*tree
,
1164 TALLOC_CTX
*mem_ctx
,
1165 struct rap_NetPrintDestGetInfo
*r
)
1167 struct rap_call
*call
;
1168 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1170 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WPrintDestGetInfo
))) {
1171 return NT_STATUS_NO_MEMORY
;
1174 rap_cli_push_string(call
, r
->in
.PrintDestName
);
1175 rap_cli_push_word(call
, r
->in
.level
);
1176 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1177 rap_cli_expect_word(call
);
1179 switch(r
->in
.level
) {
1181 rap_cli_expect_format(call
, "B9");
1184 rap_cli_expect_format(call
, "B9B21WWzW");
1187 rap_cli_expect_format(call
, "z");
1190 rap_cli_expect_format(call
, "zzzWWzzzWW");
1193 result
= NT_STATUS_INVALID_PARAMETER
;
1197 if (DEBUGLEVEL
>= 10) {
1198 NDR_PRINT_IN_DEBUG(rap_NetPrintDestGetInfo
, r
);
1201 result
= rap_cli_do_call(tree
, call
);
1203 if (!NT_STATUS_IS_OK(result
))
1206 result
= NT_STATUS_INVALID_PARAMETER
;
1208 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1209 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1210 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1212 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1214 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
1215 NDR_GOTO(ndr_pull_rap_printdest_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1217 if (DEBUGLEVEL
>= 10) {
1218 NDR_PRINT_OUT_DEBUG(rap_NetPrintDestGetInfo
, r
);
1221 result
= NT_STATUS_OK
;
1228 NTSTATUS
smbcli_rap_netuserpasswordset2(struct smbcli_tree
*tree
,
1229 TALLOC_CTX
*mem_ctx
,
1230 struct rap_NetUserPasswordSet2
*r
)
1232 struct rap_call
*call
;
1233 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1235 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserPasswordSet2
))) {
1236 return NT_STATUS_NO_MEMORY
;
1239 rap_cli_push_string(call
, r
->in
.UserName
);
1240 rap_cli_push_paramdesc(call
, 'b');
1241 rap_cli_push_paramdesc(call
, '1');
1242 rap_cli_push_paramdesc(call
, '6');
1243 ndr_push_array_uint8(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.OldPassword
, 16);
1244 rap_cli_push_paramdesc(call
, 'b');
1245 rap_cli_push_paramdesc(call
, '1');
1246 rap_cli_push_paramdesc(call
, '6');
1247 ndr_push_array_uint8(call
->ndr_push_param
, NDR_SCALARS
, r
->in
.NewPassword
, 16);
1248 rap_cli_push_word(call
, r
->in
.EncryptedPassword
);
1249 rap_cli_push_word(call
, r
->in
.RealPasswordLength
);
1251 rap_cli_expect_format(call
, "");
1253 if (DEBUGLEVEL
>= 10) {
1254 NDR_PRINT_IN_DEBUG(rap_NetUserPasswordSet2
, r
);
1257 result
= rap_cli_do_call(tree
, call
);
1259 if (!NT_STATUS_IS_OK(result
))
1262 result
= NT_STATUS_INVALID_PARAMETER
;
1264 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1265 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1267 result
= NT_STATUS_OK
;
1269 if (!NT_STATUS_IS_OK(result
)) {
1273 if (DEBUGLEVEL
>= 10) {
1274 NDR_PRINT_OUT_DEBUG(rap_NetUserPasswordSet2
, r
);
1282 NTSTATUS
smbcli_rap_netoemchangepassword(struct smbcli_tree
*tree
,
1283 TALLOC_CTX
*mem_ctx
,
1284 struct rap_NetOEMChangePassword
*r
)
1286 struct rap_call
*call
;
1287 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1289 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_SamOEMChgPasswordUser2_P
))) {
1290 return NT_STATUS_NO_MEMORY
;
1293 rap_cli_push_string(call
, r
->in
.UserName
);
1294 rap_cli_push_sendbuf(call
, 532);
1295 ndr_push_array_uint8(call
->ndr_push_data
, NDR_SCALARS
, r
->in
.crypt_password
, 516);
1296 ndr_push_array_uint8(call
->ndr_push_data
, NDR_SCALARS
, r
->in
.password_hash
, 16);
1298 rap_cli_expect_format(call
, "B516B16");
1300 if (DEBUGLEVEL
>= 10) {
1301 NDR_PRINT_IN_DEBUG(rap_NetOEMChangePassword
, r
);
1304 result
= rap_cli_do_call(tree
, call
);
1306 if (!NT_STATUS_IS_OK(result
))
1309 result
= NT_STATUS_INVALID_PARAMETER
;
1311 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1312 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1314 result
= NT_STATUS_OK
;
1316 if (!NT_STATUS_IS_OK(result
)) {
1320 if (DEBUGLEVEL
>= 10) {
1321 NDR_PRINT_OUT_DEBUG(rap_NetOEMChangePassword
, r
);
1329 NTSTATUS
smbcli_rap_netusergetinfo(struct smbcli_tree
*tree
,
1330 TALLOC_CTX
*mem_ctx
,
1331 struct rap_NetUserGetInfo
*r
)
1333 struct rap_call
*call
;
1334 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1336 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserGetInfo
))) {
1337 return NT_STATUS_NO_MEMORY
;
1340 rap_cli_push_string(call
, r
->in
.UserName
);
1341 rap_cli_push_word(call
, r
->in
.level
);
1342 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1343 rap_cli_expect_word(call
);
1345 switch(r
->in
.level
) {
1347 rap_cli_expect_format(call
, "B21");
1350 rap_cli_expect_format(call
, "B21BB16DWzzWz");
1353 rap_cli_expect_format(call
, "B21BB16DWzzWzDzzzzDDDDWb21WWzWW");
1356 rap_cli_expect_format(call
, "B21Bzzz");
1359 rap_cli_expect_format(call
, "B21BzzzWDDzzDDWWzWzDWb21W");
1362 result
= NT_STATUS_INVALID_PARAMETER
;
1366 if (DEBUGLEVEL
>= 10) {
1367 NDR_PRINT_IN_DEBUG(rap_NetUserGetInfo
, r
);
1370 result
= rap_cli_do_call(tree
, call
);
1372 if (!NT_STATUS_IS_OK(result
))
1375 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1376 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1377 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1379 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1381 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
1382 NDR_GOTO(ndr_pull_rap_netuser_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1384 if (DEBUGLEVEL
>= 10) {
1385 NDR_PRINT_OUT_DEBUG(rap_NetUserGetInfo
, r
);
1388 result
= NT_STATUS_OK
;
1396 static enum ndr_err_code
ndr_pull_rap_NetSessionEnum_data(struct ndr_pull
*ndr
, struct rap_NetSessionEnum
*r
)
1398 uint32_t cntr_info_0
;
1399 TALLOC_CTX
*_mem_save_info_0
;
1401 NDR_PULL_ALLOC_N(ndr
, r
->out
.info
, r
->out
.count
);
1402 _mem_save_info_0
= NDR_PULL_GET_MEM_CTX(ndr
);
1403 NDR_PULL_SET_MEM_CTX(ndr
, r
->out
.info
, 0);
1404 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1405 NDR_CHECK(ndr_pull_set_switch_value(ndr
, &r
->out
.info
[cntr_info_0
], r
->in
.level
));
1406 NDR_CHECK(ndr_pull_rap_session_info(ndr
, NDR_SCALARS
, &r
->out
.info
[cntr_info_0
]));
1408 for (cntr_info_0
= 0; cntr_info_0
< r
->out
.count
; cntr_info_0
++) {
1409 NDR_CHECK(ndr_pull_rap_session_info(ndr
, NDR_BUFFERS
, &r
->out
.info
[cntr_info_0
]));
1411 NDR_PULL_SET_MEM_CTX(ndr
, _mem_save_info_0
, 0);
1413 return NDR_ERR_SUCCESS
;
1417 NTSTATUS
smbcli_rap_netsessionenum(struct smbcli_tree
*tree
,
1418 TALLOC_CTX
*mem_ctx
,
1419 struct rap_NetSessionEnum
*r
)
1421 struct rap_call
*call
;
1422 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1424 call
= new_rap_cli_call(tree
, RAP_WsessionEnum
);
1427 return NT_STATUS_NO_MEMORY
;
1429 rap_cli_push_word(call
, r
->in
.level
);
1430 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1431 rap_cli_expect_multiple_entries(call
);
1433 switch(r
->in
.level
) {
1435 rap_cli_expect_format(call
, "zzWWWDDDz");
1438 result
= NT_STATUS_INVALID_PARAMETER
;
1442 if (DEBUGLEVEL
>= 10) {
1443 NDR_PRINT_IN_DEBUG(rap_NetSessionEnum
, r
);
1446 result
= rap_cli_do_call(tree
, call
);
1448 if (!NT_STATUS_IS_OK(result
))
1451 result
= NT_STATUS_INVALID_PARAMETER
;
1453 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1454 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1455 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.count
));
1456 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1458 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1460 NDR_GOTO(ndr_pull_rap_NetSessionEnum_data(call
->ndr_pull_data
, r
));
1462 r
->out
.info
= talloc_steal(mem_ctx
, r
->out
.info
);
1464 if (DEBUGLEVEL
>= 10) {
1465 NDR_PRINT_OUT_DEBUG(rap_NetSessionEnum
, r
);
1468 result
= NT_STATUS_OK
;
1475 NTSTATUS
smbcli_rap_netsessiongetinfo(struct smbcli_tree
*tree
,
1476 TALLOC_CTX
*mem_ctx
,
1477 struct rap_NetSessionGetInfo
*r
)
1479 struct rap_call
*call
;
1480 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1482 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WsessionGetInfo
))) {
1483 return NT_STATUS_NO_MEMORY
;
1486 rap_cli_push_string(call
, r
->in
.SessionName
);
1487 rap_cli_push_word(call
, r
->in
.level
);
1488 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1489 rap_cli_expect_word(call
);
1491 switch(r
->in
.level
) {
1493 rap_cli_expect_format(call
, "zzWWWDDDz");
1496 result
= NT_STATUS_INVALID_PARAMETER
;
1500 if (DEBUGLEVEL
>= 10) {
1501 NDR_PRINT_IN_DEBUG(rap_NetSessionGetInfo
, r
);
1504 result
= rap_cli_do_call(tree
, call
);
1506 if (!NT_STATUS_IS_OK(result
))
1509 result
= NT_STATUS_INVALID_PARAMETER
;
1511 ZERO_STRUCT(r
->out
);
1513 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1514 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1515 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.available
));
1517 if (r
->out
.status
== 0 && r
->out
.available
) {
1518 call
->ndr_pull_data
->relative_rap_convert
= r
->out
.convert
;
1520 NDR_GOTO(ndr_pull_set_switch_value(call
->ndr_pull_data
, &r
->out
.info
, r
->in
.level
));
1521 NDR_GOTO(ndr_pull_rap_session_info(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.info
));
1524 if (DEBUGLEVEL
>= 10) {
1525 NDR_PRINT_OUT_DEBUG(rap_NetSessionGetInfo
, r
);
1528 result
= NT_STATUS_OK
;
1535 NTSTATUS
smbcli_rap_netuseradd(struct smbcli_tree
*tree
,
1536 TALLOC_CTX
*mem_ctx
,
1537 struct rap_NetUserAdd
*r
)
1539 struct rap_call
*call
;
1540 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1542 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserAdd2
))) {
1543 return NT_STATUS_NO_MEMORY
;
1546 rap_cli_push_word(call
, r
->in
.level
);
1547 rap_cli_push_sendbuf(call
, r
->in
.bufsize
);
1548 rap_cli_push_word(call
, r
->in
.pwdlength
);
1549 rap_cli_push_word(call
, r
->in
.unknown
);
1551 switch (r
->in
.level
) {
1553 rap_cli_expect_format(call
, "B21BB16DWzzWz");
1556 result
= NT_STATUS_INVALID_PARAMETER
;
1560 if (DEBUGLEVEL
>= 10) {
1561 NDR_PRINT_IN_DEBUG(rap_NetUserAdd
, r
);
1564 NDR_GOTO(ndr_push_set_switch_value(call
->ndr_push_data
, &r
->in
.info
, r
->in
.level
));
1565 NDR_GOTO(ndr_push_rap_netuser_info(call
->ndr_push_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->in
.info
));
1567 result
= rap_cli_do_call(tree
, call
);
1569 if (!NT_STATUS_IS_OK(result
))
1572 result
= NT_STATUS_INVALID_PARAMETER
;
1574 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1575 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1577 result
= NT_STATUS_OK
;
1579 if (!NT_STATUS_IS_OK(result
)) {
1583 if (DEBUGLEVEL
>= 10) {
1584 NDR_PRINT_OUT_DEBUG(rap_NetUserAdd
, r
);
1592 NTSTATUS
smbcli_rap_netuserdelete(struct smbcli_tree
*tree
,
1593 TALLOC_CTX
*mem_ctx
,
1594 struct rap_NetUserDelete
*r
)
1596 struct rap_call
*call
;
1597 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1599 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_WUserDel
))) {
1600 return NT_STATUS_NO_MEMORY
;
1603 rap_cli_push_string(call
, r
->in
.UserName
);
1605 rap_cli_expect_format(call
, "");
1606 rap_cli_expect_extra_format(call
, "");
1608 if (DEBUGLEVEL
>= 10) {
1609 NDR_PRINT_IN_DEBUG(rap_NetUserDelete
, r
);
1612 result
= rap_cli_do_call(tree
, call
);
1614 if (!NT_STATUS_IS_OK(result
))
1617 result
= NT_STATUS_INVALID_PARAMETER
;
1619 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1620 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1622 result
= NT_STATUS_OK
;
1624 if (!NT_STATUS_IS_OK(result
)) {
1628 if (DEBUGLEVEL
>= 10) {
1629 NDR_PRINT_OUT_DEBUG(rap_NetUserDelete
, r
);
1637 NTSTATUS
smbcli_rap_netremotetod(struct smbcli_tree
*tree
,
1638 TALLOC_CTX
*mem_ctx
,
1639 struct rap_NetRemoteTOD
*r
)
1641 struct rap_call
*call
;
1642 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
1644 if (!(call
= new_rap_cli_call(mem_ctx
, RAP_NetRemoteTOD
))) {
1645 return NT_STATUS_NO_MEMORY
;
1648 rap_cli_push_rcvbuf(call
, r
->in
.bufsize
);
1650 rap_cli_expect_format(call
, "DDBBBBWWBBWB");
1651 rap_cli_expect_extra_format(call
, "");
1653 if (DEBUGLEVEL
>= 10) {
1654 NDR_PRINT_IN_DEBUG(rap_NetRemoteTOD
, r
);
1657 result
= rap_cli_do_call(tree
, call
);
1659 if (!NT_STATUS_IS_OK(result
))
1662 result
= NT_STATUS_INVALID_PARAMETER
;
1664 NDR_GOTO(ndr_pull_rap_status(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.status
));
1665 NDR_GOTO(ndr_pull_uint16(call
->ndr_pull_param
, NDR_SCALARS
, &r
->out
.convert
));
1667 NDR_GOTO(ndr_pull_rap_TimeOfDayInfo(call
->ndr_pull_data
, NDR_SCALARS
|NDR_BUFFERS
, &r
->out
.tod
));
1669 result
= NT_STATUS_OK
;
1671 if (!NT_STATUS_IS_OK(result
)) {
1675 if (DEBUGLEVEL
>= 10) {
1676 NDR_PRINT_OUT_DEBUG(rap_NetRemoteTOD
, r
);