librpc: Shorten dcerpc_binding_handle_call a bit
[Samba/gebeck_regimport.git] / source4 / libcli / rap / rap.c
blob9f41e17d278705d693f0c1dabd0139a60a77d906
1 /*
2 Unix SMB/CIFS implementation.
3 RAP client
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/>.
23 #include "includes.h"
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);
34 if (call == NULL) {
35 return NULL;
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) {
43 talloc_free(call);
44 return 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) {
50 talloc_free(call);
51 return NULL;
53 call->ndr_push_data->flags = RAPNDR_FLAGS;
55 call->pull_mem_ctx = mem_ctx;
57 return call;
60 static void rap_cli_push_paramdesc(struct rap_call *call, char desc)
62 int len = 0;
64 if (call->paramdesc != NULL)
65 len = strlen(call->paramdesc);
67 call->paramdesc = talloc_realloc(call,
68 call->paramdesc,
69 char,
70 len+2);
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)
124 if (str == NULL) {
125 rap_cli_push_paramdesc(call, 'O');
126 return;
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;
146 uint16_t ignore;
147 const char *p;
148 size_t len;
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);
167 return NT_STATUS_OK;
170 NTSTATUS rap_cli_do_call(struct smbcli_tree *tree,
171 struct rap_call *call)
173 NTSTATUS result;
174 DATA_BLOB param_blob;
175 DATA_BLOB data_blob;
176 struct ndr_push *params;
177 struct ndr_push *data;
178 struct smb_trans2 trans;
180 params = ndr_push_init_ctx(call);
182 if (params == NULL)
183 return NT_STATUS_NO_MEMORY;
185 params->flags = RAPNDR_FLAGS;
187 data = ndr_push_init_ctx(call);
189 if (data == NULL)
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;
197 trans.in.flags = 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));
204 if (call->paramdesc)
205 NDR_RETURN(ndr_push_string(params, NDR_SCALARS, call->paramdesc));
206 if (call->datadesc)
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,
211 param_blob.length));
213 data_blob = ndr_push_blob(call->ndr_push_data);
214 NDR_RETURN(ndr_push_bytes(data, data_blob.data,
215 data_blob.length));
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))
226 return 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;
235 return result;
239 NTSTATUS smbcli_rap_netshareenum(struct smbcli_tree *tree,
240 TALLOC_CTX *mem_ctx,
241 struct rap_NetShareEnum *r)
243 struct rap_call *call;
244 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
245 int i;
247 call = new_rap_cli_call(tree, RAP_WshareEnum);
249 if (call == NULL)
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) {
257 case 0:
258 rap_cli_expect_format(call, "B13");
259 break;
260 case 1:
261 rap_cli_expect_format(call, "B13BWz");
262 break;
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))
272 goto done;
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;
283 goto done;
286 for (i=0; i<r->out.count; i++) {
287 switch(r->in.level) {
288 case 0:
289 NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
290 r->out.info[i].info0.share_name, 13));
291 break;
292 case 1:
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,
300 r->out.convert,
301 &r->out.info[i].info1.comment));
302 break;
306 if (DEBUGLEVEL >= 10) {
307 NDR_PRINT_OUT_DEBUG(rap_NetShareEnum, r);
309 result = NT_STATUS_OK;
311 done:
312 talloc_free(call);
313 return result;
316 NTSTATUS smbcli_rap_netserverenum2(struct smbcli_tree *tree,
317 TALLOC_CTX *mem_ctx,
318 struct rap_NetServerEnum2 *r)
320 struct rap_call *call;
321 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
322 int i;
324 call = new_rap_cli_call(mem_ctx, RAP_NetServerEnum2);
326 if (call == NULL)
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) {
336 case 0:
337 rap_cli_expect_format(call, "B16");
338 break;
339 case 1:
340 rap_cli_expect_format(call, "B16BBDz");
341 break;
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))
351 goto done;
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;
364 goto done;
367 for (i=0; i<r->out.count; i++) {
368 switch(r->in.level) {
369 case 0:
370 NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
371 r->out.info[i].info0.name, 16));
372 break;
373 case 1:
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,
383 r->out.convert,
384 &r->out.info[i].info1.comment));
388 if (DEBUGLEVEL >= 10) {
389 NDR_PRINT_OUT_DEBUG(rap_NetServerEnum2, r);
392 result = NT_STATUS_OK;
394 done:
395 talloc_free(call);
396 return result;
399 NTSTATUS smbcli_rap_netservergetinfo(struct smbcli_tree *tree,
400 TALLOC_CTX *mem_ctx,
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) {
415 case 0:
416 rap_cli_expect_format(call, "B16");
417 break;
418 case 1:
419 rap_cli_expect_format(call, "B16BBDz");
420 break;
421 default:
422 result = NT_STATUS_INVALID_PARAMETER;
423 goto done;
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))
433 goto done;
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) {
440 case 0:
441 NDR_GOTO(ndr_pull_bytes(call->ndr_pull_data,
442 r->out.info.info0.name, 16));
443 break;
444 case 1:
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,
454 r->out.convert,
455 &r->out.info.info1.comment));
458 if (DEBUGLEVEL >= 10) {
459 NDR_PRINT_OUT_DEBUG(rap_WserverGetInfo, r);
461 done:
462 talloc_free(call);
463 return result;
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,
487 TALLOC_CTX *mem_ctx,
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) {
502 case 0:
503 rap_cli_expect_format(call, "B13");
504 break;
505 case 1:
506 rap_cli_expect_format(call, "B13BWWWzzzzzWW");
507 break;
508 case 2:
509 rap_cli_expect_format(call, "B13BWWWzzzzzWN");
510 rap_cli_expect_extra_format(call, "WB21BB16B10zWWzDDz");
511 break;
512 case 3:
513 rap_cli_expect_format(call, "zWWWWzzzzWWzzl");
514 break;
515 case 4:
516 rap_cli_expect_format(call, "zWWWWzzzzWNzzl");
517 rap_cli_expect_extra_format(call, "WWzWWDDzz");
518 /* no mention of extra format in MS-RAP */
519 break;
520 case 5:
521 rap_cli_expect_format(call, "z");
522 break;
523 default:
524 result = NT_STATUS_INVALID_PARAMETER;
525 goto done;
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))
535 goto done;
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;
556 done:
557 talloc_free(call);
558 return result;
561 NTSTATUS smbcli_rap_netprintqgetinfo(struct smbcli_tree *tree,
562 TALLOC_CTX *mem_ctx,
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) {
578 case 0:
579 rap_cli_expect_format(call, "B13");
580 break;
581 case 1:
582 rap_cli_expect_format(call, "B13BWWWzzzzzWW");
583 break;
584 case 2:
585 rap_cli_expect_format(call, "B13BWWWzzzzzWN");
586 rap_cli_expect_extra_format(call, "WB21BB16B10zWWzDDz");
587 break;
588 case 3:
589 rap_cli_expect_format(call, "zWWWWzzzzWWzzl");
590 break;
591 case 4:
592 rap_cli_expect_format(call, "zWWWWzzzzWNzzl");
593 rap_cli_expect_extra_format(call, "WWzWWDDzz");
594 /* no mention of extra format in MS-RAP */
595 break;
596 case 5:
597 rap_cli_expect_format(call, "z");
598 break;
599 default:
600 result = NT_STATUS_INVALID_PARAMETER;
601 goto done;
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))
611 goto done;
613 result = NT_STATUS_INVALID_PARAMETER;
615 ZERO_STRUCT(r->out);
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;
633 done:
634 talloc_free(call);
635 return result;
638 NTSTATUS smbcli_rap_netprintjobpause(struct smbcli_tree *tree,
639 TALLOC_CTX *mem_ctx,
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))
660 goto done;
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);
669 done:
670 talloc_free(call);
671 return result;
674 NTSTATUS smbcli_rap_netprintjobcontinue(struct smbcli_tree *tree,
675 TALLOC_CTX *mem_ctx,
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))
696 goto done;
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);
705 done:
706 talloc_free(call);
707 return result;
710 NTSTATUS smbcli_rap_netprintjobdelete(struct smbcli_tree *tree,
711 TALLOC_CTX *mem_ctx,
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))
732 goto done;
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);
741 done:
742 talloc_free(call);
743 return result;
746 NTSTATUS smbcli_rap_netprintqueuepause(struct smbcli_tree *tree,
747 TALLOC_CTX *mem_ctx,
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))
768 goto done;
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);
777 done:
778 talloc_free(call);
779 return result;
782 NTSTATUS smbcli_rap_netprintqueueresume(struct smbcli_tree *tree,
783 TALLOC_CTX *mem_ctx,
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))
804 goto done;
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);
813 done:
814 talloc_free(call);
815 return result;
818 NTSTATUS smbcli_rap_netprintqueuepurge(struct smbcli_tree *tree,
819 TALLOC_CTX *mem_ctx,
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))
840 goto done;
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);
849 done:
850 talloc_free(call);
851 return result;
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,
875 TALLOC_CTX *mem_ctx,
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) {
891 case 0:
892 rap_cli_expect_format(call, "W");
893 break;
894 case 1:
895 rap_cli_expect_format(call, "WB21BB16B10zWWzDDz");
896 break;
897 case 2:
898 rap_cli_expect_format(call, "WWzWWDDzz");
899 break;
900 case 3:
901 rap_cli_expect_format(call, "WWzWWDDzzzzzzzzzzlz");
902 break;
903 case 4:
904 rap_cli_expect_format(call, "WWzWWDDzzzzzDDDDDDD");
905 break;
906 default:
907 result = NT_STATUS_INVALID_PARAMETER;
908 goto done;
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))
918 goto done;
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;
939 done:
940 talloc_free(call);
941 return result;
944 NTSTATUS smbcli_rap_netprintjobgetinfo(struct smbcli_tree *tree,
945 TALLOC_CTX *mem_ctx,
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) {
961 case 0:
962 rap_cli_expect_format(call, "W");
963 break;
964 case 1:
965 rap_cli_expect_format(call, "WB21BB16B10zWWzDDz");
966 break;
967 case 2:
968 rap_cli_expect_format(call, "WWzWWDDzz");
969 break;
970 case 3:
971 rap_cli_expect_format(call, "WWzWWDDzzzzzzzzzzlz");
972 break;
973 case 4:
974 rap_cli_expect_format(call, "WWzWWDDzzzzzDDDDDDD");
975 break;
976 default:
977 result = NT_STATUS_INVALID_PARAMETER;
978 goto done;
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))
988 goto done;
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;
1007 done:
1008 talloc_free(call);
1009 return result;
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));
1033 break;
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));
1041 break;
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));
1045 break;
1046 default:
1047 result = NT_STATUS_INVALID_PARAMETER;
1048 break;
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))
1061 goto done;
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)) {
1071 goto done;
1074 if (DEBUGLEVEL >= 10) {
1075 NDR_PRINT_OUT_DEBUG(rap_NetPrintJobSetInfo, r);
1078 done:
1079 talloc_free(call);
1080 return result;
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) {
1120 case 0:
1121 rap_cli_expect_format(call, "B9");
1122 break;
1123 case 1:
1124 rap_cli_expect_format(call, "B9B21WWzW");
1125 break;
1126 case 2:
1127 rap_cli_expect_format(call, "z");
1128 break;
1129 case 3:
1130 rap_cli_expect_format(call, "zzzWWzzzWW");
1131 break;
1132 default:
1133 result = NT_STATUS_INVALID_PARAMETER;
1134 goto done;
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))
1144 goto done;
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;
1165 done:
1166 talloc_free(call);
1167 return result;
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) {
1187 case 0:
1188 rap_cli_expect_format(call, "B9");
1189 break;
1190 case 1:
1191 rap_cli_expect_format(call, "B9B21WWzW");
1192 break;
1193 case 2:
1194 rap_cli_expect_format(call, "z");
1195 break;
1196 case 3:
1197 rap_cli_expect_format(call, "zzzWWzzzWW");
1198 break;
1199 default:
1200 result = NT_STATUS_INVALID_PARAMETER;
1201 goto done;
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))
1211 goto done;
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;
1230 done:
1231 talloc_free(call);
1232 return result;
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))
1267 goto done;
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)) {
1277 goto done;
1280 if (DEBUGLEVEL >= 10) {
1281 NDR_PRINT_OUT_DEBUG(rap_NetUserPasswordSet2, r);
1284 done:
1285 talloc_free(call);
1286 return result;
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))
1314 goto done;
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)) {
1324 goto done;
1327 if (DEBUGLEVEL >= 10) {
1328 NDR_PRINT_OUT_DEBUG(rap_NetOEMChangePassword, r);
1331 done:
1332 talloc_free(call);
1333 return result;
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) {
1353 case 0:
1354 rap_cli_expect_format(call, "B21");
1355 break;
1356 case 1:
1357 rap_cli_expect_format(call, "B21BB16DWzzWz");
1358 break;
1359 case 2:
1360 rap_cli_expect_format(call, "B21BB16DWzzWzDzzzzDDDDWb21WWzWW");
1361 break;
1362 case 10:
1363 rap_cli_expect_format(call, "B21Bzzz");
1364 break;
1365 case 11:
1366 rap_cli_expect_format(call, "B21BzzzWDDzzDDWWzWzDWb21W");
1367 break;
1368 default:
1369 result = NT_STATUS_INVALID_PARAMETER;
1370 goto done;
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))
1380 goto done;
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;
1397 done:
1398 talloc_free(call);
1399 return result;
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);
1433 if (call == NULL)
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) {
1441 case 2:
1442 rap_cli_expect_format(call, "zzWWWDDDz");
1443 break;
1444 default:
1445 result = NT_STATUS_INVALID_PARAMETER;
1446 goto done;
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))
1456 goto done;
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;
1477 done:
1478 talloc_free(call);
1479 return result;
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) {
1499 case 2:
1500 rap_cli_expect_format(call, "zzWWWDDDz");
1501 break;
1502 default:
1503 result = NT_STATUS_INVALID_PARAMETER;
1504 break;
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))
1514 goto done;
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;
1536 done:
1537 talloc_free(call);
1538 return result;
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) {
1559 case 1:
1560 rap_cli_expect_format(call, "B21BB16DWzzWz");
1561 break;
1562 default:
1563 result = NT_STATUS_INVALID_PARAMETER;
1564 break;
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))
1577 goto done;
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)) {
1587 goto done;
1590 if (DEBUGLEVEL >= 10) {
1591 NDR_PRINT_OUT_DEBUG(rap_NetUserAdd, r);
1594 done:
1595 talloc_free(call);
1596 return result;
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))
1622 goto done;
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)) {
1632 goto done;
1635 if (DEBUGLEVEL >= 10) {
1636 NDR_PRINT_OUT_DEBUG(rap_NetUserDelete, r);
1639 done:
1640 talloc_free(call);
1641 return result;
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))
1667 goto done;
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)) {
1679 goto done;
1682 if (DEBUGLEVEL >= 10) {
1683 NDR_PRINT_OUT_DEBUG(rap_NetRemoteTOD, r);
1686 done:
1687 talloc_free(call);
1688 return result;