dsdb: Use WERR_DS_ATT_NOT_DEF_IN_SCHEMA for failed schema lookups
[Samba.git] / source3 / rpc_client / cli_spoolss.c
blob1a8903d82a154e1f86ef8f1f042133c960d07310
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"
30 /**********************************************************************
31 convencience wrapper around rpccli_spoolss_OpenPrinterEx
32 **********************************************************************/
34 WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli,
35 TALLOC_CTX *mem_ctx,
36 const char *printername,
37 uint32_t access_desired,
38 struct policy_handle *handle)
40 NTSTATUS status;
41 WERROR werror;
42 struct spoolss_DevmodeContainer devmode_ctr;
43 struct spoolss_UserLevelCtr userlevel_ctr;
44 struct spoolss_UserLevel1 level1;
45 struct dcerpc_binding_handle *b = cli->binding_handle;
47 ZERO_STRUCT(devmode_ctr);
49 level1.size = 28;
50 level1.client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name());
51 W_ERROR_HAVE_NO_MEMORY(level1.client);
52 level1.user = cli->auth->user_name;
53 level1.build = 1381;
54 level1.major = 2;
55 level1.minor = 0;
56 level1.processor = 0;
58 userlevel_ctr.level = 1;
59 userlevel_ctr.user_info.level1 = &level1;
61 status = dcerpc_spoolss_OpenPrinterEx(b, mem_ctx,
62 printername,
63 NULL,
64 devmode_ctr,
65 access_desired,
66 userlevel_ctr,
67 handle,
68 &werror);
70 if (!NT_STATUS_IS_OK(status)) {
71 return ntstatus_to_werror(status);
74 if (!W_ERROR_IS_OK(werror)) {
75 return werror;
78 return WERR_OK;
81 /**********************************************************************
82 convencience wrapper around rpccli_spoolss_GetPrinterDriver
83 **********************************************************************/
85 WERROR rpccli_spoolss_getprinterdriver(struct rpc_pipe_client *cli,
86 TALLOC_CTX *mem_ctx,
87 struct policy_handle *handle,
88 const char *architecture,
89 uint32_t level,
90 uint32_t offered,
91 union spoolss_DriverInfo *info)
93 NTSTATUS status;
94 WERROR werror;
95 uint32_t needed;
96 DATA_BLOB buffer;
97 struct dcerpc_binding_handle *b = cli->binding_handle;
99 if (offered > 0) {
100 buffer = data_blob_talloc_zero(mem_ctx, offered);
101 W_ERROR_HAVE_NO_MEMORY(buffer.data);
104 status = dcerpc_spoolss_GetPrinterDriver(b, mem_ctx,
105 handle,
106 architecture,
107 level,
108 (offered > 0) ? &buffer : NULL,
109 offered,
110 info,
111 &needed,
112 &werror);
113 if (!NT_STATUS_IS_OK(status)) {
114 return ntstatus_to_werror(status);
116 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
117 offered = needed;
118 buffer = data_blob_talloc_zero(mem_ctx, needed);
119 W_ERROR_HAVE_NO_MEMORY(buffer.data);
121 status = dcerpc_spoolss_GetPrinterDriver(b, mem_ctx,
122 handle,
123 architecture,
124 level,
125 &buffer,
126 offered,
127 info,
128 &needed,
129 &werror);
131 if (!NT_STATUS_IS_OK(status)) {
132 return ntstatus_to_werror(status);
135 return werror;
138 /**********************************************************************
139 convencience wrapper around rpccli_spoolss_GetPrinterDriver2
140 **********************************************************************/
142 WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
143 TALLOC_CTX *mem_ctx,
144 struct policy_handle *handle,
145 const char *architecture,
146 uint32_t level,
147 uint32_t offered,
148 uint32_t client_major_version,
149 uint32_t client_minor_version,
150 union spoolss_DriverInfo *info,
151 uint32_t *server_major_version,
152 uint32_t *server_minor_version)
154 NTSTATUS status;
155 WERROR werror;
156 uint32_t needed;
157 DATA_BLOB buffer;
158 struct dcerpc_binding_handle *b = cli->binding_handle;
160 if (offered > 0) {
161 buffer = data_blob_talloc_zero(mem_ctx, offered);
162 W_ERROR_HAVE_NO_MEMORY(buffer.data);
165 status = dcerpc_spoolss_GetPrinterDriver2(b, mem_ctx,
166 handle,
167 architecture,
168 level,
169 (offered > 0) ? &buffer : NULL,
170 offered,
171 client_major_version,
172 client_minor_version,
173 info,
174 &needed,
175 server_major_version,
176 server_minor_version,
177 &werror);
178 if (!NT_STATUS_IS_OK(status)) {
179 return ntstatus_to_werror(status);
182 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
183 offered = needed;
184 buffer = data_blob_talloc_zero(mem_ctx, needed);
185 W_ERROR_HAVE_NO_MEMORY(buffer.data);
187 status = dcerpc_spoolss_GetPrinterDriver2(b, mem_ctx,
188 handle,
189 architecture,
190 level,
191 &buffer,
192 offered,
193 client_major_version,
194 client_minor_version,
195 info,
196 &needed,
197 server_major_version,
198 server_minor_version,
199 &werror);
201 if (!NT_STATUS_IS_OK(status)) {
202 return ntstatus_to_werror(status);
205 return werror;
208 /**********************************************************************
209 convencience wrapper around rpccli_spoolss_AddPrinterEx
210 **********************************************************************/
212 WERROR rpccli_spoolss_addprinterex(struct rpc_pipe_client *cli,
213 TALLOC_CTX *mem_ctx,
214 struct spoolss_SetPrinterInfoCtr *info_ctr)
216 WERROR result;
217 NTSTATUS status;
218 struct spoolss_DevmodeContainer devmode_ctr;
219 struct sec_desc_buf secdesc_ctr;
220 struct spoolss_UserLevelCtr userlevel_ctr;
221 struct spoolss_UserLevel1 level1;
222 struct policy_handle handle;
223 struct dcerpc_binding_handle *b = cli->binding_handle;
225 ZERO_STRUCT(devmode_ctr);
226 ZERO_STRUCT(secdesc_ctr);
228 level1.size = 28;
229 level1.build = 1381;
230 level1.major = 2;
231 level1.minor = 0;
232 level1.processor = 0;
233 level1.client = talloc_asprintf(mem_ctx, "\\\\%s", lp_netbios_name());
234 W_ERROR_HAVE_NO_MEMORY(level1.client);
235 level1.user = cli->auth->user_name;
237 userlevel_ctr.level = 1;
238 userlevel_ctr.user_info.level1 = &level1;
240 status = dcerpc_spoolss_AddPrinterEx(b, mem_ctx,
241 cli->srv_name_slash,
242 info_ctr,
243 &devmode_ctr,
244 &secdesc_ctr,
245 &userlevel_ctr,
246 &handle,
247 &result);
248 if (!NT_STATUS_IS_OK(status)) {
249 return ntstatus_to_werror(status);
252 return result;
255 /**********************************************************************
256 convencience wrapper around rpccli_spoolss_GetPrinter
257 **********************************************************************/
259 WERROR rpccli_spoolss_getprinter(struct rpc_pipe_client *cli,
260 TALLOC_CTX *mem_ctx,
261 struct policy_handle *handle,
262 uint32_t level,
263 uint32_t offered,
264 union spoolss_PrinterInfo *info)
266 NTSTATUS status;
267 WERROR werror;
268 DATA_BLOB buffer;
269 uint32_t needed;
270 struct dcerpc_binding_handle *b = cli->binding_handle;
272 if (offered > 0) {
273 buffer = data_blob_talloc_zero(mem_ctx, offered);
274 W_ERROR_HAVE_NO_MEMORY(buffer.data);
277 status = dcerpc_spoolss_GetPrinter(b, mem_ctx,
278 handle,
279 level,
280 (offered > 0) ? &buffer : NULL,
281 offered,
282 info,
283 &needed,
284 &werror);
285 if (!NT_STATUS_IS_OK(status)) {
286 return ntstatus_to_werror(status);
289 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
291 offered = needed;
292 buffer = data_blob_talloc_zero(mem_ctx, offered);
293 W_ERROR_HAVE_NO_MEMORY(buffer.data);
295 status = dcerpc_spoolss_GetPrinter(b, mem_ctx,
296 handle,
297 level,
298 &buffer,
299 offered,
300 info,
301 &needed,
302 &werror);
304 if (!NT_STATUS_IS_OK(status)) {
305 return ntstatus_to_werror(status);
308 return werror;
311 /**********************************************************************
312 convencience wrapper around rpccli_spoolss_GetJob
313 **********************************************************************/
315 WERROR rpccli_spoolss_getjob(struct rpc_pipe_client *cli,
316 TALLOC_CTX *mem_ctx,
317 struct policy_handle *handle,
318 uint32_t job_id,
319 uint32_t level,
320 uint32_t offered,
321 union spoolss_JobInfo *info)
323 NTSTATUS status;
324 WERROR werror;
325 uint32_t needed;
326 DATA_BLOB buffer;
327 struct dcerpc_binding_handle *b = cli->binding_handle;
329 if (offered > 0) {
330 buffer = data_blob_talloc_zero(mem_ctx, offered);
331 W_ERROR_HAVE_NO_MEMORY(buffer.data);
334 status = dcerpc_spoolss_GetJob(b, mem_ctx,
335 handle,
336 job_id,
337 level,
338 (offered > 0) ? &buffer : NULL,
339 offered,
340 info,
341 &needed,
342 &werror);
343 if (!NT_STATUS_IS_OK(status)) {
344 return ntstatus_to_werror(status);
347 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
348 offered = needed;
349 buffer = data_blob_talloc_zero(mem_ctx, needed);
350 W_ERROR_HAVE_NO_MEMORY(buffer.data);
352 status = dcerpc_spoolss_GetJob(b, mem_ctx,
353 handle,
354 job_id,
355 level,
356 &buffer,
357 offered,
358 info,
359 &needed,
360 &werror);
362 if (!NT_STATUS_IS_OK(status)) {
363 return ntstatus_to_werror(status);
366 return werror;
369 /**********************************************************************
370 convencience wrapper around rpccli_spoolss_EnumForms
371 **********************************************************************/
373 WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli,
374 TALLOC_CTX *mem_ctx,
375 struct policy_handle *handle,
376 uint32_t level,
377 uint32_t offered,
378 uint32_t *count,
379 union spoolss_FormInfo **info)
381 NTSTATUS status;
382 WERROR werror;
383 uint32_t needed;
384 DATA_BLOB buffer;
385 struct dcerpc_binding_handle *b = cli->binding_handle;
387 if (offered > 0) {
388 buffer = data_blob_talloc_zero(mem_ctx, offered);
389 W_ERROR_HAVE_NO_MEMORY(buffer.data);
392 status = dcerpc_spoolss_EnumForms(b, mem_ctx,
393 handle,
394 level,
395 (offered > 0) ? &buffer : NULL,
396 offered,
397 count,
398 info,
399 &needed,
400 &werror);
401 if (!NT_STATUS_IS_OK(status)) {
402 return ntstatus_to_werror(status);
405 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
406 offered = needed;
407 buffer = data_blob_talloc_zero(mem_ctx, needed);
408 W_ERROR_HAVE_NO_MEMORY(buffer.data);
410 status = dcerpc_spoolss_EnumForms(b, mem_ctx,
411 handle,
412 level,
413 (offered > 0) ? &buffer : NULL,
414 offered,
415 count,
416 info,
417 &needed,
418 &werror);
420 if (!NT_STATUS_IS_OK(status)) {
421 return ntstatus_to_werror(status);
424 return werror;
427 /**********************************************************************
428 convencience wrapper around rpccli_spoolss_EnumPrintProcessors
429 **********************************************************************/
431 WERROR rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client *cli,
432 TALLOC_CTX *mem_ctx,
433 const char *servername,
434 const char *environment,
435 uint32_t level,
436 uint32_t offered,
437 uint32_t *count,
438 union spoolss_PrintProcessorInfo **info)
440 NTSTATUS status;
441 WERROR werror;
442 uint32_t needed;
443 DATA_BLOB buffer;
444 struct dcerpc_binding_handle *b = cli->binding_handle;
446 if (offered > 0) {
447 buffer = data_blob_talloc_zero(mem_ctx, offered);
448 W_ERROR_HAVE_NO_MEMORY(buffer.data);
451 status = dcerpc_spoolss_EnumPrintProcessors(b, mem_ctx,
452 servername,
453 environment,
454 level,
455 (offered > 0) ? &buffer : NULL,
456 offered,
457 count,
458 info,
459 &needed,
460 &werror);
461 if (!NT_STATUS_IS_OK(status)) {
462 return ntstatus_to_werror(status);
465 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
466 offered = needed;
467 buffer = data_blob_talloc_zero(mem_ctx, needed);
468 W_ERROR_HAVE_NO_MEMORY(buffer.data);
470 status = dcerpc_spoolss_EnumPrintProcessors(b, mem_ctx,
471 servername,
472 environment,
473 level,
474 (offered > 0) ? &buffer : NULL,
475 offered,
476 count,
477 info,
478 &needed,
479 &werror);
481 if (!NT_STATUS_IS_OK(status)) {
482 return ntstatus_to_werror(status);
485 return werror;
488 /**********************************************************************
489 convencience wrapper around rpccli_spoolss_EnumPrintProcDataTypes
490 **********************************************************************/
492 WERROR rpccli_spoolss_enumprintprocessordatatypes(struct rpc_pipe_client *cli,
493 TALLOC_CTX *mem_ctx,
494 const char *servername,
495 const char *print_processor_name,
496 uint32_t level,
497 uint32_t offered,
498 uint32_t *count,
499 union spoolss_PrintProcDataTypesInfo **info)
501 NTSTATUS status;
502 WERROR werror;
503 uint32_t needed;
504 DATA_BLOB buffer;
505 struct dcerpc_binding_handle *b = cli->binding_handle;
507 if (offered > 0) {
508 buffer = data_blob_talloc_zero(mem_ctx, offered);
509 W_ERROR_HAVE_NO_MEMORY(buffer.data);
512 status = dcerpc_spoolss_EnumPrintProcDataTypes(b, mem_ctx,
513 servername,
514 print_processor_name,
515 level,
516 (offered > 0) ? &buffer : NULL,
517 offered,
518 count,
519 info,
520 &needed,
521 &werror);
522 if (!NT_STATUS_IS_OK(status)) {
523 return ntstatus_to_werror(status);
526 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
527 offered = needed;
528 buffer = data_blob_talloc_zero(mem_ctx, needed);
529 W_ERROR_HAVE_NO_MEMORY(buffer.data);
531 status = dcerpc_spoolss_EnumPrintProcDataTypes(b, mem_ctx,
532 servername,
533 print_processor_name,
534 level,
535 (offered > 0) ? &buffer : NULL,
536 offered,
537 count,
538 info,
539 &needed,
540 &werror);
542 if (!NT_STATUS_IS_OK(status)) {
543 return ntstatus_to_werror(status);
546 return werror;
549 /**********************************************************************
550 convencience wrapper around rpccli_spoolss_EnumPorts
551 **********************************************************************/
553 WERROR rpccli_spoolss_enumports(struct rpc_pipe_client *cli,
554 TALLOC_CTX *mem_ctx,
555 const char *servername,
556 uint32_t level,
557 uint32_t offered,
558 uint32_t *count,
559 union spoolss_PortInfo **info)
561 NTSTATUS status;
562 WERROR werror;
563 uint32_t needed;
564 DATA_BLOB buffer;
565 struct dcerpc_binding_handle *b = cli->binding_handle;
567 if (offered > 0) {
568 buffer = data_blob_talloc_zero(mem_ctx, offered);
569 W_ERROR_HAVE_NO_MEMORY(buffer.data);
572 status = dcerpc_spoolss_EnumPorts(b, mem_ctx,
573 servername,
574 level,
575 (offered > 0) ? &buffer : NULL,
576 offered,
577 count,
578 info,
579 &needed,
580 &werror);
581 if (!NT_STATUS_IS_OK(status)) {
582 return ntstatus_to_werror(status);
585 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
586 offered = needed;
587 buffer = data_blob_talloc_zero(mem_ctx, needed);
588 W_ERROR_HAVE_NO_MEMORY(buffer.data);
590 status = dcerpc_spoolss_EnumPorts(b, mem_ctx,
591 servername,
592 level,
593 (offered > 0) ? &buffer : NULL,
594 offered,
595 count,
596 info,
597 &needed,
598 &werror);
600 if (!NT_STATUS_IS_OK(status)) {
601 return ntstatus_to_werror(status);
604 return werror;
607 /**********************************************************************
608 convencience wrapper around rpccli_spoolss_EnumMonitors
609 **********************************************************************/
611 WERROR rpccli_spoolss_enummonitors(struct rpc_pipe_client *cli,
612 TALLOC_CTX *mem_ctx,
613 const char *servername,
614 uint32_t level,
615 uint32_t offered,
616 uint32_t *count,
617 union spoolss_MonitorInfo **info)
619 NTSTATUS status;
620 WERROR werror;
621 uint32_t needed;
622 DATA_BLOB buffer;
623 struct dcerpc_binding_handle *b = cli->binding_handle;
625 if (offered > 0) {
626 buffer = data_blob_talloc_zero(mem_ctx, offered);
627 W_ERROR_HAVE_NO_MEMORY(buffer.data);
630 status = dcerpc_spoolss_EnumMonitors(b, mem_ctx,
631 servername,
632 level,
633 (offered > 0) ? &buffer : NULL,
634 offered,
635 count,
636 info,
637 &needed,
638 &werror);
639 if (!NT_STATUS_IS_OK(status)) {
640 return ntstatus_to_werror(status);
643 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
644 offered = needed;
645 buffer = data_blob_talloc_zero(mem_ctx, needed);
646 W_ERROR_HAVE_NO_MEMORY(buffer.data);
648 status = dcerpc_spoolss_EnumMonitors(b, mem_ctx,
649 servername,
650 level,
651 (offered > 0) ? &buffer : NULL,
652 offered,
653 count,
654 info,
655 &needed,
656 &werror);
658 if (!NT_STATUS_IS_OK(status)) {
659 return ntstatus_to_werror(status);
662 return werror;
665 /**********************************************************************
666 convencience wrapper around rpccli_spoolss_EnumJobs
667 **********************************************************************/
669 WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli,
670 TALLOC_CTX *mem_ctx,
671 struct policy_handle *handle,
672 uint32_t firstjob,
673 uint32_t numjobs,
674 uint32_t level,
675 uint32_t offered,
676 uint32_t *count,
677 union spoolss_JobInfo **info)
679 NTSTATUS status;
680 WERROR werror;
681 uint32_t needed;
682 DATA_BLOB buffer;
683 struct dcerpc_binding_handle *b = cli->binding_handle;
685 if (offered > 0) {
686 buffer = data_blob_talloc_zero(mem_ctx, offered);
687 W_ERROR_HAVE_NO_MEMORY(buffer.data);
690 status = dcerpc_spoolss_EnumJobs(b, mem_ctx,
691 handle,
692 firstjob,
693 numjobs,
694 level,
695 (offered > 0) ? &buffer : NULL,
696 offered,
697 count,
698 info,
699 &needed,
700 &werror);
701 if (!NT_STATUS_IS_OK(status)) {
702 return ntstatus_to_werror(status);
705 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
706 offered = needed;
707 buffer = data_blob_talloc_zero(mem_ctx, needed);
708 W_ERROR_HAVE_NO_MEMORY(buffer.data);
710 status = dcerpc_spoolss_EnumJobs(b, mem_ctx,
711 handle,
712 firstjob,
713 numjobs,
714 level,
715 (offered > 0) ? &buffer : NULL,
716 offered,
717 count,
718 info,
719 &needed,
720 &werror);
722 if (!NT_STATUS_IS_OK(status)) {
723 return ntstatus_to_werror(status);
726 return werror;
729 /**********************************************************************
730 convencience wrapper around rpccli_spoolss_EnumPrinterDrivers
731 **********************************************************************/
733 WERROR rpccli_spoolss_enumprinterdrivers(struct rpc_pipe_client *cli,
734 TALLOC_CTX *mem_ctx,
735 const char *server,
736 const char *environment,
737 uint32_t level,
738 uint32_t offered,
739 uint32_t *count,
740 union spoolss_DriverInfo **info)
742 NTSTATUS status;
743 WERROR werror;
744 uint32_t needed;
745 DATA_BLOB buffer;
746 struct dcerpc_binding_handle *b = cli->binding_handle;
748 if (offered > 0) {
749 buffer = data_blob_talloc_zero(mem_ctx, offered);
750 W_ERROR_HAVE_NO_MEMORY(buffer.data);
753 status = dcerpc_spoolss_EnumPrinterDrivers(b, mem_ctx,
754 server,
755 environment,
756 level,
757 (offered > 0) ? &buffer : NULL,
758 offered,
759 count,
760 info,
761 &needed,
762 &werror);
763 if (!NT_STATUS_IS_OK(status)) {
764 return ntstatus_to_werror(status);
767 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
768 offered = needed;
769 buffer = data_blob_talloc_zero(mem_ctx, needed);
770 W_ERROR_HAVE_NO_MEMORY(buffer.data);
772 status = dcerpc_spoolss_EnumPrinterDrivers(b, mem_ctx,
773 server,
774 environment,
775 level,
776 (offered > 0) ? &buffer : NULL,
777 offered,
778 count,
779 info,
780 &needed,
781 &werror);
783 if (!NT_STATUS_IS_OK(status)) {
784 return ntstatus_to_werror(status);
787 return werror;
790 /**********************************************************************
791 convencience wrapper around rpccli_spoolss_EnumPrinters
792 **********************************************************************/
794 WERROR rpccli_spoolss_enumprinters(struct rpc_pipe_client *cli,
795 TALLOC_CTX *mem_ctx,
796 uint32_t flags,
797 const char *server,
798 uint32_t level,
799 uint32_t offered,
800 uint32_t *count,
801 union spoolss_PrinterInfo **info)
803 NTSTATUS status;
804 WERROR werror;
805 uint32_t needed;
806 DATA_BLOB buffer;
807 struct dcerpc_binding_handle *b = cli->binding_handle;
809 if (offered > 0) {
810 buffer = data_blob_talloc_zero(mem_ctx, offered);
811 W_ERROR_HAVE_NO_MEMORY(buffer.data);
814 status = dcerpc_spoolss_EnumPrinters(b, mem_ctx,
815 flags,
816 server,
817 level,
818 (offered > 0) ? &buffer : NULL,
819 offered,
820 count,
821 info,
822 &needed,
823 &werror);
824 if (!NT_STATUS_IS_OK(status)) {
825 return ntstatus_to_werror(status);
828 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
829 offered = needed;
830 buffer = data_blob_talloc_zero(mem_ctx, needed);
831 W_ERROR_HAVE_NO_MEMORY(buffer.data);
833 status = dcerpc_spoolss_EnumPrinters(b, mem_ctx,
834 flags,
835 server,
836 level,
837 (offered > 0) ? &buffer : NULL,
838 offered,
839 count,
840 info,
841 &needed,
842 &werror);
844 if (!NT_STATUS_IS_OK(status)) {
845 return ntstatus_to_werror(status);
848 return werror;
851 /**********************************************************************
852 convencience wrapper around rpccli_spoolss_GetPrinterData
853 **********************************************************************/
855 WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli,
856 TALLOC_CTX *mem_ctx,
857 struct policy_handle *handle,
858 const char *value_name,
859 uint32_t offered,
860 enum winreg_Type *type,
861 uint32_t *needed_p,
862 uint8_t **data_p)
864 NTSTATUS status;
865 WERROR werror;
866 uint32_t needed;
867 uint8_t *data;
868 struct dcerpc_binding_handle *b = cli->binding_handle;
870 data = talloc_zero_array(mem_ctx, uint8_t, offered);
871 W_ERROR_HAVE_NO_MEMORY(data);
873 status = dcerpc_spoolss_GetPrinterData(b, mem_ctx,
874 handle,
875 value_name,
876 type,
877 data,
878 offered,
879 &needed,
880 &werror);
881 if (!NT_STATUS_IS_OK(status)) {
882 return ntstatus_to_werror(status);
885 if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
886 offered = needed;
887 data = talloc_zero_array(mem_ctx, uint8_t, offered);
888 W_ERROR_HAVE_NO_MEMORY(data);
890 status = dcerpc_spoolss_GetPrinterData(b, mem_ctx,
891 handle,
892 value_name,
893 type,
894 data,
895 offered,
896 &needed,
897 &werror);
899 if (!NT_STATUS_IS_OK(status)) {
900 return ntstatus_to_werror(status);
903 *data_p = data;
904 *needed_p = needed;
906 return werror;
909 /**********************************************************************
910 convencience wrapper around rpccli_spoolss_EnumPrinterKey
911 **********************************************************************/
913 WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
914 TALLOC_CTX *mem_ctx,
915 struct policy_handle *handle,
916 const char *key_name,
917 const char ***key_buffer,
918 uint32_t offered)
920 NTSTATUS status;
921 WERROR werror;
922 uint32_t needed;
923 union spoolss_KeyNames _key_buffer;
924 uint32_t _ndr_size;
925 struct dcerpc_binding_handle *b = cli->binding_handle;
927 status = dcerpc_spoolss_EnumPrinterKey(b, mem_ctx,
928 handle,
929 key_name,
930 &_ndr_size,
931 &_key_buffer,
932 offered,
933 &needed,
934 &werror);
935 if (!NT_STATUS_IS_OK(status)) {
936 return ntstatus_to_werror(status);
939 if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
940 offered = needed;
941 status = dcerpc_spoolss_EnumPrinterKey(b, mem_ctx,
942 handle,
943 key_name,
944 &_ndr_size,
945 &_key_buffer,
946 offered,
947 &needed,
948 &werror);
950 if (!NT_STATUS_IS_OK(status)) {
951 return ntstatus_to_werror(status);
954 *key_buffer = _key_buffer.string_array;
956 return werror;
959 /**********************************************************************
960 convencience wrapper around rpccli_spoolss_EnumPrinterDataEx
961 **********************************************************************/
963 WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli,
964 TALLOC_CTX *mem_ctx,
965 struct policy_handle *handle,
966 const char *key_name,
967 uint32_t offered,
968 uint32_t *count,
969 struct spoolss_PrinterEnumValues **info)
971 NTSTATUS status;
972 WERROR werror;
973 uint32_t needed;
974 struct dcerpc_binding_handle *b = cli->binding_handle;
976 status = dcerpc_spoolss_EnumPrinterDataEx(b, mem_ctx,
977 handle,
978 key_name,
979 offered,
980 count,
981 info,
982 &needed,
983 &werror);
984 if (!NT_STATUS_IS_OK(status)) {
985 return ntstatus_to_werror(status);
988 if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
989 offered = needed;
991 status = dcerpc_spoolss_EnumPrinterDataEx(b, mem_ctx,
992 handle,
993 key_name,
994 offered,
995 count,
996 info,
997 &needed,
998 &werror);
1000 if (!NT_STATUS_IS_OK(status)) {
1001 return ntstatus_to_werror(status);
1004 return werror;