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_GetPrinterDriver2
80 **********************************************************************/
82 WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
84 struct policy_handle *handle,
85 const char *architecture,
88 uint32_t client_major_version,
89 uint32_t client_minor_version,
90 union spoolss_DriverInfo *info,
91 uint32_t *server_major_version,
92 uint32_t *server_minor_version)
100 buffer = data_blob_talloc_zero(mem_ctx, offered);
101 W_ERROR_HAVE_NO_MEMORY(buffer.data);
104 status = rpccli_spoolss_GetPrinterDriver2(cli, mem_ctx,
108 (offered > 0) ? &buffer : NULL,
110 client_major_version,
111 client_minor_version,
114 server_major_version,
115 server_minor_version,
117 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
119 buffer = data_blob_talloc_zero(mem_ctx, needed);
120 W_ERROR_HAVE_NO_MEMORY(buffer.data);
122 status = rpccli_spoolss_GetPrinterDriver2(cli, mem_ctx,
128 client_major_version,
129 client_minor_version,
132 server_major_version,
133 server_minor_version,
140 /**********************************************************************
141 convencience wrapper around rpccli_spoolss_AddPrinterEx
142 **********************************************************************/
144 WERROR rpccli_spoolss_addprinterex(struct rpc_pipe_client *cli,
146 struct spoolss_SetPrinterInfoCtr *info_ctr)
150 struct spoolss_DevmodeContainer devmode_ctr;
151 struct sec_desc_buf secdesc_ctr;
152 struct spoolss_UserLevelCtr userlevel_ctr;
153 struct spoolss_UserLevel1 level1;
154 struct policy_handle handle;
156 ZERO_STRUCT(devmode_ctr);
157 ZERO_STRUCT(secdesc_ctr);
163 level1.processor = 0;
164 level1.client = talloc_asprintf(mem_ctx, "\\\\%s", global_myname());
165 W_ERROR_HAVE_NO_MEMORY(level1.client);
166 level1.user = cli->auth->user_name;
168 userlevel_ctr.level = 1;
169 userlevel_ctr.user_info.level1 = &level1;
171 status = rpccli_spoolss_AddPrinterEx(cli, mem_ctx,
182 /**********************************************************************
183 convencience wrapper around rpccli_spoolss_GetPrinter
184 **********************************************************************/
186 WERROR rpccli_spoolss_getprinter(struct rpc_pipe_client *cli,
188 struct policy_handle *handle,
191 union spoolss_PrinterInfo *info)
199 buffer = data_blob_talloc_zero(mem_ctx, offered);
200 W_ERROR_HAVE_NO_MEMORY(buffer.data);
203 status = rpccli_spoolss_GetPrinter(cli, mem_ctx,
206 (offered > 0) ? &buffer : NULL,
212 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
215 buffer = data_blob_talloc_zero(mem_ctx, offered);
216 W_ERROR_HAVE_NO_MEMORY(buffer.data);
218 status = rpccli_spoolss_GetPrinter(cli, mem_ctx,
231 /**********************************************************************
232 convencience wrapper around rpccli_spoolss_GetJob
233 **********************************************************************/
235 WERROR rpccli_spoolss_getjob(struct rpc_pipe_client *cli,
237 struct policy_handle *handle,
241 union spoolss_JobInfo *info)
249 buffer = data_blob_talloc_zero(mem_ctx, offered);
250 W_ERROR_HAVE_NO_MEMORY(buffer.data);
253 status = rpccli_spoolss_GetJob(cli, mem_ctx,
257 (offered > 0) ? &buffer : NULL,
263 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
265 buffer = data_blob_talloc_zero(mem_ctx, needed);
266 W_ERROR_HAVE_NO_MEMORY(buffer.data);
268 status = rpccli_spoolss_GetJob(cli, mem_ctx,
282 /**********************************************************************
283 convencience wrapper around rpccli_spoolss_EnumForms
284 **********************************************************************/
286 WERROR rpccli_spoolss_enumforms(struct rpc_pipe_client *cli,
288 struct policy_handle *handle,
292 union spoolss_FormInfo **info)
300 buffer = data_blob_talloc_zero(mem_ctx, offered);
301 W_ERROR_HAVE_NO_MEMORY(buffer.data);
304 status = rpccli_spoolss_EnumForms(cli, mem_ctx,
307 (offered > 0) ? &buffer : NULL,
314 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
316 buffer = data_blob_talloc_zero(mem_ctx, needed);
317 W_ERROR_HAVE_NO_MEMORY(buffer.data);
319 status = rpccli_spoolss_EnumForms(cli, mem_ctx,
322 (offered > 0) ? &buffer : NULL,
333 /**********************************************************************
334 convencience wrapper around rpccli_spoolss_EnumPrintProcessors
335 **********************************************************************/
337 WERROR rpccli_spoolss_enumprintprocessors(struct rpc_pipe_client *cli,
339 const char *servername,
340 const char *environment,
344 union spoolss_PrintProcessorInfo **info)
352 buffer = data_blob_talloc_zero(mem_ctx, offered);
353 W_ERROR_HAVE_NO_MEMORY(buffer.data);
356 status = rpccli_spoolss_EnumPrintProcessors(cli, mem_ctx,
360 (offered > 0) ? &buffer : NULL,
367 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
369 buffer = data_blob_talloc_zero(mem_ctx, needed);
370 W_ERROR_HAVE_NO_MEMORY(buffer.data);
372 status = rpccli_spoolss_EnumPrintProcessors(cli, mem_ctx,
376 (offered > 0) ? &buffer : NULL,
387 /**********************************************************************
388 convencience wrapper around rpccli_spoolss_EnumPrintProcDataTypes
389 **********************************************************************/
391 WERROR rpccli_spoolss_enumprintprocessordatatypes(struct rpc_pipe_client *cli,
393 const char *servername,
394 const char *print_processor_name,
398 union spoolss_PrintProcDataTypesInfo **info)
406 buffer = data_blob_talloc_zero(mem_ctx, offered);
407 W_ERROR_HAVE_NO_MEMORY(buffer.data);
410 status = rpccli_spoolss_EnumPrintProcDataTypes(cli, mem_ctx,
412 print_processor_name,
414 (offered > 0) ? &buffer : NULL,
421 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
423 buffer = data_blob_talloc_zero(mem_ctx, needed);
424 W_ERROR_HAVE_NO_MEMORY(buffer.data);
426 status = rpccli_spoolss_EnumPrintProcDataTypes(cli, mem_ctx,
428 print_processor_name,
430 (offered > 0) ? &buffer : NULL,
441 /**********************************************************************
442 convencience wrapper around rpccli_spoolss_EnumPorts
443 **********************************************************************/
445 WERROR rpccli_spoolss_enumports(struct rpc_pipe_client *cli,
447 const char *servername,
451 union spoolss_PortInfo **info)
459 buffer = data_blob_talloc_zero(mem_ctx, offered);
460 W_ERROR_HAVE_NO_MEMORY(buffer.data);
463 status = rpccli_spoolss_EnumPorts(cli, mem_ctx,
466 (offered > 0) ? &buffer : NULL,
473 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
475 buffer = data_blob_talloc_zero(mem_ctx, needed);
476 W_ERROR_HAVE_NO_MEMORY(buffer.data);
478 status = rpccli_spoolss_EnumPorts(cli, mem_ctx,
481 (offered > 0) ? &buffer : NULL,
492 /**********************************************************************
493 convencience wrapper around rpccli_spoolss_EnumMonitors
494 **********************************************************************/
496 WERROR rpccli_spoolss_enummonitors(struct rpc_pipe_client *cli,
498 const char *servername,
502 union spoolss_MonitorInfo **info)
510 buffer = data_blob_talloc_zero(mem_ctx, offered);
511 W_ERROR_HAVE_NO_MEMORY(buffer.data);
514 status = rpccli_spoolss_EnumMonitors(cli, mem_ctx,
517 (offered > 0) ? &buffer : NULL,
524 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
526 buffer = data_blob_talloc_zero(mem_ctx, needed);
527 W_ERROR_HAVE_NO_MEMORY(buffer.data);
529 status = rpccli_spoolss_EnumMonitors(cli, mem_ctx,
532 (offered > 0) ? &buffer : NULL,
543 /**********************************************************************
544 convencience wrapper around rpccli_spoolss_EnumJobs
545 **********************************************************************/
547 WERROR rpccli_spoolss_enumjobs(struct rpc_pipe_client *cli,
549 struct policy_handle *handle,
555 union spoolss_JobInfo **info)
563 buffer = data_blob_talloc_zero(mem_ctx, offered);
564 W_ERROR_HAVE_NO_MEMORY(buffer.data);
567 status = rpccli_spoolss_EnumJobs(cli, mem_ctx,
572 (offered > 0) ? &buffer : NULL,
579 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
581 buffer = data_blob_talloc_zero(mem_ctx, needed);
582 W_ERROR_HAVE_NO_MEMORY(buffer.data);
584 status = rpccli_spoolss_EnumJobs(cli, mem_ctx,
589 (offered > 0) ? &buffer : NULL,
600 /**********************************************************************
601 convencience wrapper around rpccli_spoolss_EnumPrinterDrivers
602 **********************************************************************/
604 WERROR rpccli_spoolss_enumprinterdrivers(struct rpc_pipe_client *cli,
607 const char *environment,
611 union spoolss_DriverInfo **info)
619 buffer = data_blob_talloc_zero(mem_ctx, offered);
620 W_ERROR_HAVE_NO_MEMORY(buffer.data);
623 status = rpccli_spoolss_EnumPrinterDrivers(cli, mem_ctx,
627 (offered > 0) ? &buffer : NULL,
634 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
636 buffer = data_blob_talloc_zero(mem_ctx, needed);
637 W_ERROR_HAVE_NO_MEMORY(buffer.data);
639 status = rpccli_spoolss_EnumPrinterDrivers(cli, mem_ctx,
643 (offered > 0) ? &buffer : NULL,
654 /**********************************************************************
655 convencience wrapper around rpccli_spoolss_EnumPrinters
656 **********************************************************************/
658 WERROR rpccli_spoolss_enumprinters(struct rpc_pipe_client *cli,
665 union spoolss_PrinterInfo **info)
673 buffer = data_blob_talloc_zero(mem_ctx, offered);
674 W_ERROR_HAVE_NO_MEMORY(buffer.data);
677 status = rpccli_spoolss_EnumPrinters(cli, mem_ctx,
681 (offered > 0) ? &buffer : NULL,
688 if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
690 buffer = data_blob_talloc_zero(mem_ctx, needed);
691 W_ERROR_HAVE_NO_MEMORY(buffer.data);
693 status = rpccli_spoolss_EnumPrinters(cli, mem_ctx,
697 (offered > 0) ? &buffer : NULL,
708 /**********************************************************************
709 convencience wrapper around rpccli_spoolss_GetPrinterData
710 **********************************************************************/
712 WERROR rpccli_spoolss_getprinterdata(struct rpc_pipe_client *cli,
714 struct policy_handle *handle,
715 const char *value_name,
717 enum winreg_Type *type,
718 union spoolss_PrinterData *data)
724 status = rpccli_spoolss_GetPrinterData(cli, mem_ctx,
733 if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
736 status = rpccli_spoolss_GetPrinterData(cli, mem_ctx,
749 /**********************************************************************
750 convencience wrapper around rpccli_spoolss_EnumPrinterKey
751 **********************************************************************/
753 WERROR rpccli_spoolss_enumprinterkey(struct rpc_pipe_client *cli,
755 struct policy_handle *handle,
756 const char *key_name,
757 const char ***key_buffer,
764 status = rpccli_spoolss_EnumPrinterKey(cli, mem_ctx,
772 if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
775 status = rpccli_spoolss_EnumPrinterKey(cli, mem_ctx,
787 /**********************************************************************
788 convencience wrapper around rpccli_spoolss_EnumPrinterDataEx
789 **********************************************************************/
791 WERROR rpccli_spoolss_enumprinterdataex(struct rpc_pipe_client *cli,
793 struct policy_handle *handle,
794 const char *key_name,
797 struct spoolss_PrinterEnumValues **info)
803 status = rpccli_spoolss_EnumPrinterDataEx(cli, mem_ctx,
812 if (W_ERROR_EQUAL(werror, WERR_MORE_DATA)) {
815 status = rpccli_spoolss_EnumPrinterDataEx(cli, mem_ctx,