From b19b6aea1258de18eec6832199f2b736a930b095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Deschner?= Date: Mon, 9 Feb 2009 17:56:20 +0100 Subject: s3-rpcclient: add rpccli_spoolss_openprinter_ex() convenience wrapper. Guenther --- source3/include/proto.h | 5 ++++ source3/rpc_client/cli_spoolss.c | 49 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/source3/include/proto.h b/source3/include/proto.h index 849bed3b0b8..db277ffa423 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -5428,6 +5428,11 @@ NTSTATUS rpccli_try_samr_connects(struct rpc_pipe_client *cli, /* The following definitions come from rpc_client/cli_spoolss.c */ +WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *printername, + uint32_t access_desired, + struct policy_handle *handle); WERROR rpccli_spoolss_open_printer_ex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, const char *printername, const char *datatype, uint32 access_required, const char *station, const char *username, POLICY_HND *pol); diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c index 1ad8b5dd61e..780043aaab4 100644 --- a/source3/rpc_client/cli_spoolss.c +++ b/source3/rpc_client/cli_spoolss.c @@ -25,6 +25,55 @@ #include "includes.h" #include "rpc_client.h" +/********************************************************************** + convencience wrapper around rpccli_spoolss_OpenPrinterEx +**********************************************************************/ + +WERROR rpccli_spoolss_openprinter_ex(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + const char *printername, + uint32_t access_desired, + struct policy_handle *handle) +{ + NTSTATUS status; + WERROR werror; + struct spoolss_DevmodeContainer devmode_ctr; + union spoolss_UserLevel userlevel; + struct spoolss_UserLevel1 level1; + + ZERO_STRUCT(devmode_ctr); + + level1.size = 28; + level1.client = cli->srv_name_slash; + level1.user = cli->auth->user_name; + level1.build = 1381; + level1.major = 2; + level1.minor = 0; + level1.processor = 0; + + userlevel.level1 = &level1; + + status = rpccli_spoolss_OpenPrinterEx(cli, mem_ctx, + printername, + NULL, + devmode_ctr, + access_desired, + 1, /* level */ + userlevel, + handle, + &werror); + + if (!W_ERROR_IS_OK(werror)) { + return werror; + } + + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + return WERR_OK; +} + /********************************************************************* Decode various spoolss rpc's and info levels ********************************************************************/ -- cgit v1.2.1