vfs_ceph_new: Remove unused symbol for ceph_readdir
[Samba.git] / source3 / rpc_client / cli_spoolss.c
blob62747d8c6400f22abcbdcaed7f20cdfd71aa1eec
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
5 Copyright (C) Gerald Carter 2001-2005,
6 Copyright (C) Tim Potter 2000-2002,
7 Copyright (C) Andrew Tridgell 1994-2000,
8 Copyright (C) Jean-Francois Micouleau 1999-2000.
9 Copyright (C) Jeremy Allison 2005.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "includes.h"
26 #include "rpc_client/rpc_client.h"
27 #include "../librpc/gen_ndr/ndr_spoolss_c.h"
28 #include "rpc_client/cli_spoolss.h"
29 #include "auth/gensec/gensec.h"
30 #include "auth/credentials/credentials.h"
31 #include "rpc_client/init_spoolss.h"
33 /**********************************************************************
34 convenience wrapper around rpccli_spoolss_OpenPrinterEx
35 **********************************************************************/
37 WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli,
38 TALLOC_CTX *mem_ctx,
39 const char *printername,
40 uint32_t access_desired,
41 struct policy_handle *handle)
43 NTSTATUS status;
44 WERROR werror;
45 struct spoolss_DevmodeContainer devmode_ctr;
46 struct spoolss_UserLevelCtr userlevel_ctr;
47 struct spoolss_UserLevel1 level1;
48 struct dcerpc_binding_handle *b = cli->binding_handle;
50 ZERO_STRUCT(devmode_ctr);
52 werror = spoolss_init_spoolss_UserLevel1(mem_ctx,
53 cli->printer_username,
54 &level1);
55 if (!W_ERROR_IS_OK(werror)) {
56 return werror;
59 userlevel_ctr.level = 1;
60 userlevel_ctr.user_info.level1 = &level1;
62 status = dcerpc_spoolss_OpenPrinterEx(b, mem_ctx,
63 printername,
64 NULL,
65 devmode_ctr,
66 access_desired,
67 userlevel_ctr,
68 handle,
69 &werror);
71 if (!NT_STATUS_IS_OK(status)) {
72 return ntstatus_to_werror(status);
75 if (!W_ERROR_IS_OK(werror)) {
76 return werror;
79 return WERR_OK;
82 /**********************************************************************
83 convenience wrapper around rpccli_spoolss_GetPrinterDriver
84 **********************************************************************/
86 WERROR rpccli_spoolss_getprinterdriver(struct rpc_pipe_client *cli,
87 TALLOC_CTX *mem_ctx,
88 struct policy_handle *handle,
89 const char *architecture,
90 uint32_t level,
91 uint32_t offered,
92 union spoolss_DriverInfo *info)
94 NTSTATUS status;
95 WERROR werror;
96 uint32_t needed;
97 DATA_BLOB buffer;
98 struct dcerpc_binding_handle *b = cli->binding_handle;
100 if (offered > 0) {
101 buffer = data_blob_talloc_zero(mem_ctx, offered);
102 W_ERROR_HAVE_NO_MEMORY(buffer.data);
105 status = dcerpc_spoolss_GetPrinterDriver(b, mem_ctx,
106 handle,
107 architecture,
108 level,
109 (offered > 0) ? &buffer : NULL,
110 offered,
111 info,
112 &needed,
113 &werror);
114 if (!NT_STATUS_IS_OK(status)) {
115 return ntstatus_to_werror(status);
117 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
118 offered = needed;
119 buffer = data_blob_talloc_zero(mem_ctx, needed);
120 W_ERROR_HAVE_NO_MEMORY(buffer.data);
122 status = dcerpc_spoolss_GetPrinterDriver(b, mem_ctx,
123 handle,
124 architecture,
125 level,
126 &buffer,
127 offered,
128 info,
129 &needed,
130 &werror);
132 if (!NT_STATUS_IS_OK(status)) {
133 return ntstatus_to_werror(status);
136 return werror;
139 /**********************************************************************
140 convenience wrapper around rpccli_spoolss_GetPrinterDriver2
141 **********************************************************************/
143 WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
144 TALLOC_CTX *mem_ctx,
145 struct policy_handle *handle,
146 const char *architecture,
147 uint32_t level,
148 uint32_t offered,
149 uint32_t client_major_version,
150 uint32_t client_minor_version,
151 union spoolss_DriverInfo *info,
152 uint32_t *server_major_version,
153 uint32_t *server_minor_version)
155 NTSTATUS status;
156 WERROR werror;
157 uint32_t needed;
158 DATA_BLOB buffer;
159 struct dcerpc_binding_handle *b = cli->binding_handle;
161 if (offered > 0) {
162 buffer = data_blob_talloc_zero(mem_ctx, offered);
163 W_ERROR_HAVE_NO_MEMORY(buffer.data);
166 status = dcerpc_spoolss_GetPrinterDriver2(b, mem_ctx,
167 handle,
168 architecture,
169 level,
170 (offered > 0) ? &buffer : NULL,
171 offered,
172 client_major_version,
173 client_minor_version,
174 info,
175 &needed,
176 server_major_version,
177 server_minor_version,
178 &werror);
179 if (!NT_STATUS_IS_OK(status)) {
180 return ntstatus_to_werror(status);
183 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
184 offered = needed;
185 buffer = data_blob_talloc_zero(mem_ctx, needed);
186 W_ERROR_HAVE_NO_MEMORY(buffer.data);
188 status = dcerpc_spoolss_GetPrinterDriver2(b, mem_ctx,
189 handle,
190 architecture,
191 level,
192 &buffer,
193 offered,
194 client_major_version,
195 client_minor_version,
196 info,
197 &needed,
198 server_major_version,
199 server_minor_version,
200 &werror);
202 if (!NT_STATUS_IS_OK(status)) {
203 return ntstatus_to_werror(status);
206 return werror;
209 /**********************************************************************
210 convenience wrapper around rpccli_spoolss_AddPrinterEx
211 **********************************************************************/
213 WERROR rpccli_spoolss_addprinterex(struct rpc_pipe_client *cli,
214 TALLOC_CTX *mem_ctx,
215 struct spoolss_SetPrinterInfoCtr *info_ctr)
217 WERROR result;
218 NTSTATUS status;
219 struct spoolss_DevmodeContainer devmode_ctr;
220 struct sec_desc_buf secdesc_ctr;
221 struct spoolss_UserLevelCtr userlevel_ctr;
222 struct spoolss_UserLevel1 level1;
223 struct policy_handle handle;
224 struct dcerpc_binding_handle *b = cli->binding_handle;
226 ZERO_STRUCT(devmode_ctr);
227 ZERO_STRUCT(secdesc_ctr);
229 result = spoolss_init_spoolss_UserLevel1(mem_ctx,
230 cli->printer_username,
231 &level1);
232 if (!W_ERROR_IS_OK(result)) {
233 return result;
236 userlevel_ctr.level = 1;
237 userlevel_ctr.user_info.level1 = &level1;
239 status = dcerpc_spoolss_AddPrinterEx(b, mem_ctx,
240 cli->srv_name_slash,
241 info_ctr,
242 &devmode_ctr,
243 &secdesc_ctr,
244 &userlevel_ctr,
245 &handle,
246 &result);
247 if (!NT_STATUS_IS_OK(status)) {
248 return ntstatus_to_werror(status);
251 return result;
254 /**********************************************************************
255 convenience wrapper around rpccli_spoolss_GetPrinter
256 **********************************************************************/
258 WERROR rpccli_spoolss_getprinter(struct rpc_pipe_client *cli,
259 TALLOC_CTX *mem_ctx,
260 struct policy_handle *handle,
261 uint32_t level,
262 uint32_t offered,
263 union spoolss_PrinterInfo *info)
265 NTSTATUS status;
266 WERROR werror;
267 DATA_BLOB buffer;
268 uint32_t needed;
269 struct dcerpc_binding_handle *b = cli->binding_handle;
271 if (offered > 0) {
272 buffer = data_blob_talloc_zero(mem_ctx, offered);
273 W_ERROR_HAVE_NO_MEMORY(buffer.data);
276 status = dcerpc_spoolss_GetPrinter(b, mem_ctx,
277 handle,
278 level,
279 (offered > 0) ? &buffer : NULL,
280 offered,
281 info,
282 &needed,
283 &werror);
284 if (!NT_STATUS_IS_OK(status)) {
285 return ntstatus_to_werror(status);
288 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
290 offered = needed;
291 buffer = data_blob_talloc_zero(mem_ctx, offered);
292 W_ERROR_HAVE_NO_MEMORY(buffer.data);
294 status = dcerpc_spoolss_GetPrinter(b, mem_ctx,
295 handle,
296 level,
297 &buffer,
298 offered,
299 info,
300 &needed,
301 &werror);
303 if (!NT_STATUS_IS_OK(status)) {
304 return ntstatus_to_werror(status);
307 return werror;
310 /**********************************************************************
311 convenience wrapper around rpccli_spoolss_GetJob
312 **********************************************************************/
314 WERROR rpccli_spoolss_getjob(struct rpc_pipe_client *cli,
315 TALLOC_CTX *mem_ctx,
316 struct policy_handle *handle,
317 uint32_t job_id,
318 uint32_t level,
319 uint32_t offered,
320 union spoolss_JobInfo *info)
322 NTSTATUS status;
323 WERROR werror;
324 uint32_t needed;
325 DATA_BLOB buffer;
326 struct dcerpc_binding_handle *b = cli->binding_handle;
328 if (offered > 0) {
329 buffer = data_blob_talloc_zero(mem_ctx, offered);
330 W_ERROR_HAVE_NO_MEMORY(buffer.data);
333 status = dcerpc_spoolss_GetJob(b, mem_ctx,
334 handle,
335 job_id,
336 level,
337 (offered > 0) ? &buffer : NULL,
338 offered,
339 info,
340 &needed,
341 &werror);
342 if (!NT_STATUS_IS_OK(status)) {
343 return ntstatus_to_werror(status);
346 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
347 offered = needed;
348 buffer = data_blob_talloc_zero(mem_ctx, needed);
349 W_ERROR_HAVE_NO_MEMORY(buffer.data);
351 status = dcerpc_spoolss_GetJob(b, mem_ctx,
352 handle,
353 job_id,
354 level,
355 &buffer,
356 offered,
357 info,
358 &needed,
359 &werror);
361 if (!NT_STATUS_IS_OK(status)) {
362 return ntstatus_to_werror(status);
365 return werror;
368 /**********************************************************************
369 convenience wrapper around rpccli_spoolss_EnumForms
370 **********************************************************************/
372 WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli,
373 TALLOC_CTX *mem_ctx,
374 struct policy_handle *handle,
375 uint32_t level,
376 uint32_t offered,
377 uint32_t *count,
378 union spoolss_FormInfo **info)
380 NTSTATUS status;
381 WERROR werror;
382 uint32_t needed;
383 DATA_BLOB buffer;
384 struct dcerpc_binding_handle *b = cli->binding_handle;
386 if (offered > 0) {
387 buffer = data_blob_talloc_zero(mem_ctx, offered);
388 W_ERROR_HAVE_NO_MEMORY(buffer.data);
391 status = dcerpc_spoolss_EnumForms(b, mem_ctx,
392 handle,
393 level,
394 (offered > 0) ? &buffer : NULL,
395 offered,
396 count,
397 info,
398 &needed,
399 &werror);
400 if (!NT_STATUS_IS_OK(status)) {
401 return ntstatus_to_werror(status);
404 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
405 offered = needed;
406 buffer = data_blob_talloc_zero(mem_ctx, needed);
407 W_ERROR_HAVE_NO_MEMORY(buffer.data);
409 status = dcerpc_spoolss_EnumForms(b, mem_ctx,
410 handle,
411 level,
412 (offered > 0) ? &buffer : NULL,
413 offered,
414 count,
415 info,
416 &needed,
417 &werror);
419 if (!NT_STATUS_IS_OK(status)) {
420 return ntstatus_to_werror(status);
423 return werror;
426 /**********************************************************************
427 convenience wrapper around rpccli_spoolss_EnumPrintProcessors
428 **********************************************************************/
430 WERROR rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client *cli,
431 TALLOC_CTX *mem_ctx,
432 const char *servername,
433 const char *environment,
434 uint32_t level,
435 uint32_t offered,
436 uint32_t *count,
437 union spoolss_PrintProcessorInfo **info)
439 NTSTATUS status;
440 WERROR werror;
441 uint32_t needed;
442 DATA_BLOB buffer;
443 struct dcerpc_binding_handle *b = cli->binding_handle;
445 if (offered > 0) {
446 buffer = data_blob_talloc_zero(mem_ctx, offered);
447 W_ERROR_HAVE_NO_MEMORY(buffer.data);
450 status = dcerpc_spoolss_EnumPrintProcessors(b, mem_ctx,
451 servername,
452 environment,
453 level,
454 (offered > 0) ? &buffer : NULL,
455 offered,
456 count,
457 info,
458 &needed,
459 &werror);
460 if (!NT_STATUS_IS_OK(status)) {
461 return ntstatus_to_werror(status);
464 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
465 offered = needed;
466 buffer = data_blob_talloc_zero(mem_ctx, needed);
467 W_ERROR_HAVE_NO_MEMORY(buffer.data);
469 status = dcerpc_spoolss_EnumPrintProcessors(b, mem_ctx,
470 servername,
471 environment,
472 level,
473 (offered > 0) ? &buffer : NULL,
474 offered,
475 count,
476 info,
477 &needed,
478 &werror);
480 if (!NT_STATUS_IS_OK(status)) {
481 return ntstatus_to_werror(status);
484 return werror;
487 /**********************************************************************
488 convenience wrapper around rpccli_spoolss_EnumPrintProcessorDataTypes
489 **********************************************************************/
491 WERROR rpccli_spoolss_enumprintprocessordatatypes(struct rpc_pipe_client *cli,
492 TALLOC_CTX *mem_ctx,
493 const char *servername,
494 const char *print_processor_name,
495 uint32_t level,
496 uint32_t offered,
497 uint32_t *count,
498 union spoolss_PrintProcDataTypesInfo **info)
500 NTSTATUS status;
501 WERROR werror;
502 uint32_t needed;
503 DATA_BLOB buffer;
504 struct dcerpc_binding_handle *b = cli->binding_handle;
506 if (offered > 0) {
507 buffer = data_blob_talloc_zero(mem_ctx, offered);
508 W_ERROR_HAVE_NO_MEMORY(buffer.data);
511 status = dcerpc_spoolss_EnumPrintProcessorDataTypes(b, mem_ctx,
512 servername,
513 print_processor_name,
514 level,
515 (offered > 0) ? &buffer : NULL,
516 offered,
517 count,
518 info,
519 &needed,
520 &werror);
521 if (!NT_STATUS_IS_OK(status)) {
522 return ntstatus_to_werror(status);
525 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
526 offered = needed;
527 buffer = data_blob_talloc_zero(mem_ctx, needed);
528 W_ERROR_HAVE_NO_MEMORY(buffer.data);
530 status = dcerpc_spoolss_EnumPrintProcessorDataTypes(b, mem_ctx,
531 servername,
532 print_processor_name,
533 level,
534 (offered > 0) ? &buffer : NULL,
535 offered,
536 count,
537 info,
538 &needed,
539 &werror);
541 if (!NT_STATUS_IS_OK(status)) {
542 return ntstatus_to_werror(status);
545 return werror;
548 /**********************************************************************
549 convenience wrapper around rpccli_spoolss_EnumPorts
550 **********************************************************************/
552 WERROR rpccli_spoolss_enumports(struct rpc_pipe_client *cli,
553 TALLOC_CTX *mem_ctx,
554 const char *servername,
555 uint32_t level,
556 uint32_t offered,
557 uint32_t *count,
558 union spoolss_PortInfo **info)
560 NTSTATUS status;
561 WERROR werror;
562 uint32_t needed;
563 DATA_BLOB buffer;
564 struct dcerpc_binding_handle *b = cli->binding_handle;
566 if (offered > 0) {
567 buffer = data_blob_talloc_zero(mem_ctx, offered);
568 W_ERROR_HAVE_NO_MEMORY(buffer.data);
571 status = dcerpc_spoolss_EnumPorts(b, mem_ctx,
572 servername,
573 level,
574 (offered > 0) ? &buffer : NULL,
575 offered,
576 count,
577 info,
578 &needed,
579 &werror);
580 if (!NT_STATUS_IS_OK(status)) {
581 return ntstatus_to_werror(status);
584 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
585 offered = needed;
586 buffer = data_blob_talloc_zero(mem_ctx, needed);
587 W_ERROR_HAVE_NO_MEMORY(buffer.data);
589 status = dcerpc_spoolss_EnumPorts(b, mem_ctx,
590 servername,
591 level,
592 (offered > 0) ? &buffer : NULL,
593 offered,
594 count,
595 info,
596 &needed,
597 &werror);
599 if (!NT_STATUS_IS_OK(status)) {
600 return ntstatus_to_werror(status);
603 return werror;
606 /**********************************************************************
607 convenience wrapper around rpccli_spoolss_EnumMonitors
608 **********************************************************************/
610 WERROR rpccli_spoolss_enummonitors(struct rpc_pipe_client *cli,
611 TALLOC_CTX *mem_ctx,
612 const char *servername,
613 uint32_t level,
614 uint32_t offered,
615 uint32_t *count,
616 union spoolss_MonitorInfo **info)
618 NTSTATUS status;
619 WERROR werror;
620 uint32_t needed;
621 DATA_BLOB buffer;
622 struct dcerpc_binding_handle *b = cli->binding_handle;
624 if (offered > 0) {
625 buffer = data_blob_talloc_zero(mem_ctx, offered);
626 W_ERROR_HAVE_NO_MEMORY(buffer.data);
629 status = dcerpc_spoolss_EnumMonitors(b, mem_ctx,
630 servername,
631 level,
632 (offered > 0) ? &buffer : NULL,
633 offered,
634 count,
635 info,
636 &needed,
637 &werror);
638 if (!NT_STATUS_IS_OK(status)) {
639 return ntstatus_to_werror(status);
642 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
643 offered = needed;
644 buffer = data_blob_talloc_zero(mem_ctx, needed);
645 W_ERROR_HAVE_NO_MEMORY(buffer.data);
647 status = dcerpc_spoolss_EnumMonitors(b, mem_ctx,
648 servername,
649 level,
650 (offered > 0) ? &buffer : NULL,
651 offered,
652 count,
653 info,
654 &needed,
655 &werror);
657 if (!NT_STATUS_IS_OK(status)) {
658 return ntstatus_to_werror(status);
661 return werror;
664 /**********************************************************************
665 convenience wrapper around rpccli_spoolss_EnumJobs
666 **********************************************************************/
668 WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli,
669 TALLOC_CTX *mem_ctx,
670 struct policy_handle *handle,
671 uint32_t firstjob,
672 uint32_t numjobs,
673 uint32_t level,
674 uint32_t offered,
675 uint32_t *count,
676 union spoolss_JobInfo **info)
678 NTSTATUS status;
679 WERROR werror;
680 uint32_t needed;
681 DATA_BLOB buffer;
682 struct dcerpc_binding_handle *b = cli->binding_handle;
684 if (offered > 0) {
685 buffer = data_blob_talloc_zero(mem_ctx, offered);
686 W_ERROR_HAVE_NO_MEMORY(buffer.data);
689 status = dcerpc_spoolss_EnumJobs(b, mem_ctx,
690 handle,
691 firstjob,
692 numjobs,
693 level,
694 (offered > 0) ? &buffer : NULL,
695 offered,
696 count,
697 info,
698 &needed,
699 &werror);
700 if (!NT_STATUS_IS_OK(status)) {
701 return ntstatus_to_werror(status);
704 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
705 offered = needed;
706 buffer = data_blob_talloc_zero(mem_ctx, needed);
707 W_ERROR_HAVE_NO_MEMORY(buffer.data);
709 status = dcerpc_spoolss_EnumJobs(b, mem_ctx,
710 handle,
711 firstjob,
712 numjobs,
713 level,
714 (offered > 0) ? &buffer : NULL,
715 offered,
716 count,
717 info,
718 &needed,
719 &werror);
721 if (!NT_STATUS_IS_OK(status)) {
722 return ntstatus_to_werror(status);
725 return werror;
728 /**********************************************************************
729 convenience wrapper around rpccli_spoolss_EnumPrinterDrivers
730 **********************************************************************/
732 WERROR rpccli_spoolss_enumprinterdrivers(struct rpc_pipe_client *cli,
733 TALLOC_CTX *mem_ctx,
734 const char *server,
735 const char *environment,
736 uint32_t level,
737 uint32_t offered,
738 uint32_t *count,
739 union spoolss_DriverInfo **info)
741 NTSTATUS status;
742 WERROR werror;
743 uint32_t needed;
744 DATA_BLOB buffer;
745 struct dcerpc_binding_handle *b = cli->binding_handle;
747 if (offered > 0) {
748 buffer = data_blob_talloc_zero(mem_ctx, offered);
749 W_ERROR_HAVE_NO_MEMORY(buffer.data);
752 status = dcerpc_spoolss_EnumPrinterDrivers(b, mem_ctx,
753 server,
754 environment,
755 level,
756 (offered > 0) ? &buffer : NULL,
757 offered,
758 count,
759 info,
760 &needed,
761 &werror);
762 if (!NT_STATUS_IS_OK(status)) {
763 return ntstatus_to_werror(status);
766 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
767 offered = needed;
768 buffer = data_blob_talloc_zero(mem_ctx, needed);
769 W_ERROR_HAVE_NO_MEMORY(buffer.data);
771 status = dcerpc_spoolss_EnumPrinterDrivers(b, mem_ctx,
772 server,
773 environment,
774 level,
775 (offered > 0) ? &buffer : NULL,
776 offered,
777 count,
778 info,
779 &needed,
780 &werror);
782 if (!NT_STATUS_IS_OK(status)) {
783 return ntstatus_to_werror(status);
786 return werror;
789 /**********************************************************************
790 convenience wrapper around rpccli_spoolss_EnumPrinters
791 **********************************************************************/
793 WERROR rpccli_spoolss_enumprinters(struct rpc_pipe_client *cli,
794 TALLOC_CTX *mem_ctx,
795 uint32_t flags,
796 const char *server,
797 uint32_t level,
798 uint32_t offered,
799 uint32_t *count,
800 union spoolss_PrinterInfo **info)
802 NTSTATUS status;
803 WERROR werror;
804 uint32_t needed;
805 DATA_BLOB buffer;
806 struct dcerpc_binding_handle *b = cli->binding_handle;
808 if (offered > 0) {
809 buffer = data_blob_talloc_zero(mem_ctx, offered);
810 W_ERROR_HAVE_NO_MEMORY(buffer.data);
813 status = dcerpc_spoolss_EnumPrinters(b, mem_ctx,
814 flags,
815 server,
816 level,
817 (offered > 0) ? &buffer : NULL,
818 offered,
819 count,
820 info,
821 &needed,
822 &werror);
823 if (!NT_STATUS_IS_OK(status)) {
824 return ntstatus_to_werror(status);
827 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
828 offered = needed;
829 buffer = data_blob_talloc_zero(mem_ctx, needed);
830 W_ERROR_HAVE_NO_MEMORY(buffer.data);
832 status = dcerpc_spoolss_EnumPrinters(b, mem_ctx,
833 flags,
834 server,
835 level,
836 (offered > 0) ? &buffer : NULL,
837 offered,
838 count,
839 info,
840 &needed,
841 &werror);
843 if (!NT_STATUS_IS_OK(status)) {
844 return ntstatus_to_werror(status);
847 return werror;
850 /**********************************************************************
851 convenience wrapper around rpccli_spoolss_GetPrinterData
852 **********************************************************************/
854 WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli,
855 TALLOC_CTX *mem_ctx,
856 struct policy_handle *handle,
857 const char *value_name,
858 uint32_t offered,
859 enum winreg_Type *type,
860 uint32_t *needed_p,
861 uint8_t **data_p)
863 NTSTATUS status;
864 WERROR werror;
865 uint32_t needed;
866 uint8_t *data;
867 struct dcerpc_binding_handle *b = cli->binding_handle;
869 data = talloc_zero_array(mem_ctx, uint8_t, offered);
870 W_ERROR_HAVE_NO_MEMORY(data);
872 status = dcerpc_spoolss_GetPrinterData(b, mem_ctx,
873 handle,
874 value_name,
875 type,
876 data,
877 offered,
878 &needed,
879 &werror);
880 if (!NT_STATUS_IS_OK(status)) {
881 return ntstatus_to_werror(status);
884 if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
885 offered = needed;
886 data = talloc_zero_array(mem_ctx, uint8_t, offered);
887 W_ERROR_HAVE_NO_MEMORY(data);
889 status = dcerpc_spoolss_GetPrinterData(b, mem_ctx,
890 handle,
891 value_name,
892 type,
893 data,
894 offered,
895 &needed,
896 &werror);
898 if (!NT_STATUS_IS_OK(status)) {
899 return ntstatus_to_werror(status);
902 *data_p = data;
903 *needed_p = needed;
905 return werror;
908 /**********************************************************************
909 convenience wrapper around rpccli_spoolss_EnumPrinterKey
910 **********************************************************************/
912 WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
913 TALLOC_CTX *mem_ctx,
914 struct policy_handle *handle,
915 const char *key_name,
916 const char ***key_buffer,
917 uint32_t offered)
919 NTSTATUS status;
920 WERROR werror;
921 uint32_t needed;
922 union spoolss_KeyNames _key_buffer;
923 uint32_t _ndr_size;
924 struct dcerpc_binding_handle *b = cli->binding_handle;
926 status = dcerpc_spoolss_EnumPrinterKey(b, mem_ctx,
927 handle,
928 key_name,
929 &_ndr_size,
930 &_key_buffer,
931 offered,
932 &needed,
933 &werror);
934 if (!NT_STATUS_IS_OK(status)) {
935 return ntstatus_to_werror(status);
938 if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
939 offered = needed;
940 status = dcerpc_spoolss_EnumPrinterKey(b, mem_ctx,
941 handle,
942 key_name,
943 &_ndr_size,
944 &_key_buffer,
945 offered,
946 &needed,
947 &werror);
949 if (!NT_STATUS_IS_OK(status)) {
950 return ntstatus_to_werror(status);
953 *key_buffer = _key_buffer.string_array;
955 return werror;
958 /**********************************************************************
959 convenience wrapper around rpccli_spoolss_EnumPrinterDataEx
960 **********************************************************************/
962 WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli,
963 TALLOC_CTX *mem_ctx,
964 struct policy_handle *handle,
965 const char *key_name,
966 uint32_t offered,
967 uint32_t *count,
968 struct spoolss_PrinterEnumValues **info)
970 NTSTATUS status;
971 WERROR werror;
972 uint32_t needed;
973 struct dcerpc_binding_handle *b = cli->binding_handle;
975 status = dcerpc_spoolss_EnumPrinterDataEx(b, mem_ctx,
976 handle,
977 key_name,
978 offered,
979 count,
980 info,
981 &needed,
982 &werror);
983 if (!NT_STATUS_IS_OK(status)) {
984 return ntstatus_to_werror(status);
987 if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
988 offered = needed;
990 status = dcerpc_spoolss_EnumPrinterDataEx(b, mem_ctx,
991 handle,
992 key_name,
993 offered,
994 count,
995 info,
996 &needed,
997 &werror);
999 if (!NT_STATUS_IS_OK(status)) {
1000 return ntstatus_to_werror(status);
1003 return werror;