2 Unix SMB/CIFS implementation.
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/>.
26 #include "rpc_client.h"
28 /**********************************************************************
29 convencience wrapper around rpccli_spoolss_OpenPrinterEx
30 **********************************************************************/
32 WERROR
rpccli_spoolss_openprinter_ex(struct rpc_pipe_client
*cli
,
34 const char *printername
,
35 uint32_t access_desired
,
36 struct policy_handle
*handle
)
40 struct spoolss_DevmodeContainer devmode_ctr
;
41 union spoolss_UserLevel userlevel
;
42 struct spoolss_UserLevel1 level1
;
44 ZERO_STRUCT(devmode_ctr
);
47 level1
.client
= talloc_asprintf(mem_ctx
, "\\\\%s", global_myname());
48 W_ERROR_HAVE_NO_MEMORY(level1
.client
);
49 level1
.user
= cli
->auth
->user_name
;
55 userlevel
.level1
= &level1
;
57 status
= rpccli_spoolss_OpenPrinterEx(cli
, mem_ctx
,
67 if (!W_ERROR_IS_OK(werror
)) {
71 if (!NT_STATUS_IS_OK(status
)) {
72 return ntstatus_to_werror(status
);
78 /**********************************************************************
79 convencience wrapper around rpccli_spoolss_GetPrinterDriver
80 **********************************************************************/
82 WERROR
rpccli_spoolss_getprinterdriver(struct rpc_pipe_client
*cli
,
84 struct policy_handle
*handle
,
85 const char *architecture
,
88 union spoolss_DriverInfo
*info
)
96 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
97 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
100 status
= rpccli_spoolss_GetPrinterDriver(cli
, mem_ctx
,
104 (offered
> 0) ? &buffer
: NULL
,
109 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
111 buffer
= data_blob_talloc_zero(mem_ctx
, needed
);
112 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
114 status
= rpccli_spoolss_GetPrinterDriver(cli
, mem_ctx
,
128 /**********************************************************************
129 convencience wrapper around rpccli_spoolss_GetPrinterDriver2
130 **********************************************************************/
132 WERROR
rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client
*cli
,
134 struct policy_handle
*handle
,
135 const char *architecture
,
138 uint32_t client_major_version
,
139 uint32_t client_minor_version
,
140 union spoolss_DriverInfo
*info
,
141 uint32_t *server_major_version
,
142 uint32_t *server_minor_version
)
150 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
151 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
154 status
= rpccli_spoolss_GetPrinterDriver2(cli
, mem_ctx
,
158 (offered
> 0) ? &buffer
: NULL
,
160 client_major_version
,
161 client_minor_version
,
164 server_major_version
,
165 server_minor_version
,
167 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
169 buffer
= data_blob_talloc_zero(mem_ctx
, needed
);
170 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
172 status
= rpccli_spoolss_GetPrinterDriver2(cli
, mem_ctx
,
178 client_major_version
,
179 client_minor_version
,
182 server_major_version
,
183 server_minor_version
,
190 /**********************************************************************
191 convencience wrapper around rpccli_spoolss_AddPrinterEx
192 **********************************************************************/
194 WERROR
rpccli_spoolss_addprinterex(struct rpc_pipe_client
*cli
,
196 struct spoolss_SetPrinterInfoCtr
*info_ctr
)
200 struct spoolss_DevmodeContainer devmode_ctr
;
201 struct sec_desc_buf secdesc_ctr
;
202 struct spoolss_UserLevelCtr userlevel_ctr
;
203 struct spoolss_UserLevel1 level1
;
204 struct policy_handle handle
;
206 ZERO_STRUCT(devmode_ctr
);
207 ZERO_STRUCT(secdesc_ctr
);
213 level1
.processor
= 0;
214 level1
.client
= talloc_asprintf(mem_ctx
, "\\\\%s", global_myname());
215 W_ERROR_HAVE_NO_MEMORY(level1
.client
);
216 level1
.user
= cli
->auth
->user_name
;
218 userlevel_ctr
.level
= 1;
219 userlevel_ctr
.user_info
.level1
= &level1
;
221 status
= rpccli_spoolss_AddPrinterEx(cli
, mem_ctx
,
232 /**********************************************************************
233 convencience wrapper around rpccli_spoolss_GetPrinter
234 **********************************************************************/
236 WERROR
rpccli_spoolss_getprinter(struct rpc_pipe_client
*cli
,
238 struct policy_handle
*handle
,
241 union spoolss_PrinterInfo
*info
)
249 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
250 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
253 status
= rpccli_spoolss_GetPrinter(cli
, mem_ctx
,
256 (offered
> 0) ? &buffer
: NULL
,
262 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
265 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
266 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
268 status
= rpccli_spoolss_GetPrinter(cli
, mem_ctx
,
281 /**********************************************************************
282 convencience wrapper around rpccli_spoolss_GetJob
283 **********************************************************************/
285 WERROR
rpccli_spoolss_getjob(struct rpc_pipe_client
*cli
,
287 struct policy_handle
*handle
,
291 union spoolss_JobInfo
*info
)
299 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
300 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
303 status
= rpccli_spoolss_GetJob(cli
, mem_ctx
,
307 (offered
> 0) ? &buffer
: NULL
,
313 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
315 buffer
= data_blob_talloc_zero(mem_ctx
, needed
);
316 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
318 status
= rpccli_spoolss_GetJob(cli
, mem_ctx
,
332 /**********************************************************************
333 convencience wrapper around rpccli_spoolss_EnumForms
334 **********************************************************************/
336 WERROR
rpccli_spoolss_enumforms(struct rpc_pipe_client
*cli
,
338 struct policy_handle
*handle
,
342 union spoolss_FormInfo
**info
)
350 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
351 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
354 status
= rpccli_spoolss_EnumForms(cli
, mem_ctx
,
357 (offered
> 0) ? &buffer
: NULL
,
364 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
366 buffer
= data_blob_talloc_zero(mem_ctx
, needed
);
367 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
369 status
= rpccli_spoolss_EnumForms(cli
, mem_ctx
,
372 (offered
> 0) ? &buffer
: NULL
,
383 /**********************************************************************
384 convencience wrapper around rpccli_spoolss_EnumPrintProcessors
385 **********************************************************************/
387 WERROR
rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client
*cli
,
389 const char *servername
,
390 const char *environment
,
394 union spoolss_PrintProcessorInfo
**info
)
402 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
403 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
406 status
= rpccli_spoolss_EnumPrintProcessors(cli
, mem_ctx
,
410 (offered
> 0) ? &buffer
: NULL
,
417 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
419 buffer
= data_blob_talloc_zero(mem_ctx
, needed
);
420 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
422 status
= rpccli_spoolss_EnumPrintProcessors(cli
, mem_ctx
,
426 (offered
> 0) ? &buffer
: NULL
,
437 /**********************************************************************
438 convencience wrapper around rpccli_spoolss_EnumPrintProcDataTypes
439 **********************************************************************/
441 WERROR
rpccli_spoolss_enumprintprocessordatatypes(struct rpc_pipe_client
*cli
,
443 const char *servername
,
444 const char *print_processor_name
,
448 union spoolss_PrintProcDataTypesInfo
**info
)
456 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
457 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
460 status
= rpccli_spoolss_EnumPrintProcDataTypes(cli
, mem_ctx
,
462 print_processor_name
,
464 (offered
> 0) ? &buffer
: NULL
,
471 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
473 buffer
= data_blob_talloc_zero(mem_ctx
, needed
);
474 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
476 status
= rpccli_spoolss_EnumPrintProcDataTypes(cli
, mem_ctx
,
478 print_processor_name
,
480 (offered
> 0) ? &buffer
: NULL
,
491 /**********************************************************************
492 convencience wrapper around rpccli_spoolss_EnumPorts
493 **********************************************************************/
495 WERROR
rpccli_spoolss_enumports(struct rpc_pipe_client
*cli
,
497 const char *servername
,
501 union spoolss_PortInfo
**info
)
509 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
510 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
513 status
= rpccli_spoolss_EnumPorts(cli
, mem_ctx
,
516 (offered
> 0) ? &buffer
: NULL
,
523 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
525 buffer
= data_blob_talloc_zero(mem_ctx
, needed
);
526 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
528 status
= rpccli_spoolss_EnumPorts(cli
, mem_ctx
,
531 (offered
> 0) ? &buffer
: NULL
,
542 /**********************************************************************
543 convencience wrapper around rpccli_spoolss_EnumMonitors
544 **********************************************************************/
546 WERROR
rpccli_spoolss_enummonitors(struct rpc_pipe_client
*cli
,
548 const char *servername
,
552 union spoolss_MonitorInfo
**info
)
560 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
561 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
564 status
= rpccli_spoolss_EnumMonitors(cli
, mem_ctx
,
567 (offered
> 0) ? &buffer
: NULL
,
574 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
576 buffer
= data_blob_talloc_zero(mem_ctx
, needed
);
577 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
579 status
= rpccli_spoolss_EnumMonitors(cli
, mem_ctx
,
582 (offered
> 0) ? &buffer
: NULL
,
593 /**********************************************************************
594 convencience wrapper around rpccli_spoolss_EnumJobs
595 **********************************************************************/
597 WERROR
rpccli_spoolss_enumjobs(struct rpc_pipe_client
*cli
,
599 struct policy_handle
*handle
,
605 union spoolss_JobInfo
**info
)
613 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
614 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
617 status
= rpccli_spoolss_EnumJobs(cli
, mem_ctx
,
622 (offered
> 0) ? &buffer
: NULL
,
629 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
631 buffer
= data_blob_talloc_zero(mem_ctx
, needed
);
632 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
634 status
= rpccli_spoolss_EnumJobs(cli
, mem_ctx
,
639 (offered
> 0) ? &buffer
: NULL
,
650 /**********************************************************************
651 convencience wrapper around rpccli_spoolss_EnumPrinterDrivers
652 **********************************************************************/
654 WERROR
rpccli_spoolss_enumprinterdrivers(struct rpc_pipe_client
*cli
,
657 const char *environment
,
661 union spoolss_DriverInfo
**info
)
669 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
670 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
673 status
= rpccli_spoolss_EnumPrinterDrivers(cli
, mem_ctx
,
677 (offered
> 0) ? &buffer
: NULL
,
684 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
686 buffer
= data_blob_talloc_zero(mem_ctx
, needed
);
687 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
689 status
= rpccli_spoolss_EnumPrinterDrivers(cli
, mem_ctx
,
693 (offered
> 0) ? &buffer
: NULL
,
704 /**********************************************************************
705 convencience wrapper around rpccli_spoolss_EnumPrinters
706 **********************************************************************/
708 WERROR
rpccli_spoolss_enumprinters(struct rpc_pipe_client
*cli
,
715 union spoolss_PrinterInfo
**info
)
723 buffer
= data_blob_talloc_zero(mem_ctx
, offered
);
724 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
727 status
= rpccli_spoolss_EnumPrinters(cli
, mem_ctx
,
731 (offered
> 0) ? &buffer
: NULL
,
738 if (W_ERROR_EQUAL(werror
, WERR_INSUFFICIENT_BUFFER
)) {
740 buffer
= data_blob_talloc_zero(mem_ctx
, needed
);
741 W_ERROR_HAVE_NO_MEMORY(buffer
.data
);
743 status
= rpccli_spoolss_EnumPrinters(cli
, mem_ctx
,
747 (offered
> 0) ? &buffer
: NULL
,
758 /**********************************************************************
759 convencience wrapper around rpccli_spoolss_GetPrinterData
760 **********************************************************************/
762 WERROR
rpccli_spoolss_getprinterdata(struct rpc_pipe_client
*cli
,
764 struct policy_handle
*handle
,
765 const char *value_name
,
767 enum winreg_Type
*type
,
768 union spoolss_PrinterData
*data
)
774 status
= rpccli_spoolss_GetPrinterData(cli
, mem_ctx
,
783 if (W_ERROR_EQUAL(werror
, WERR_MORE_DATA
)) {
786 status
= rpccli_spoolss_GetPrinterData(cli
, mem_ctx
,
799 /**********************************************************************
800 convencience wrapper around rpccli_spoolss_EnumPrinterKey
801 **********************************************************************/
803 WERROR
rpccli_spoolss_enumprinterkey(struct rpc_pipe_client
*cli
,
805 struct policy_handle
*handle
,
806 const char *key_name
,
807 const char ***key_buffer
,
814 status
= rpccli_spoolss_EnumPrinterKey(cli
, mem_ctx
,
822 if (W_ERROR_EQUAL(werror
, WERR_MORE_DATA
)) {
825 status
= rpccli_spoolss_EnumPrinterKey(cli
, mem_ctx
,
837 /**********************************************************************
838 convencience wrapper around rpccli_spoolss_EnumPrinterDataEx
839 **********************************************************************/
841 WERROR
rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client
*cli
,
843 struct policy_handle
*handle
,
844 const char *key_name
,
847 struct spoolss_PrinterEnumValues
**info
)
853 status
= rpccli_spoolss_EnumPrinterDataEx(cli
, mem_ctx
,
862 if (W_ERROR_EQUAL(werror
, WERR_MORE_DATA
)) {
865 status
= rpccli_spoolss_EnumPrinterDataEx(cli
, mem_ctx
,