s3-spoolss: add rpccli_spoolss_addprinterex convenience wrapper.
authorGünther Deschner <gd@samba.org>
Wed, 25 Feb 2009 00:07:50 +0000 (01:07 +0100)
committerGünther Deschner <gd@samba.org>
Wed, 25 Feb 2009 09:32:09 +0000 (10:32 +0100)
Guenther

source3/include/proto.h
source3/rpc_client/cli_spoolss.c

index 9366607..5c9e5d3 100644 (file)
@@ -5476,6 +5476,9 @@ WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
                                        union spoolss_DriverInfo *info,
                                        uint32_t *server_major_version,
                                        uint32_t *server_minor_version);
+WERROR rpccli_spoolss_addprinterex(struct rpc_pipe_client *cli,
+                                  TALLOC_CTX *mem_ctx,
+                                  struct spoolss_SetPrinterInfoCtr *info_ctr);
 WERROR rpccli_spoolss_enum_printers(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
                                 char *name, uint32 flags, uint32 level,
                                 uint32 *num_printers, PRINTER_INFO_CTR *ctr);
index 19e9aae..20599d1 100644 (file)
@@ -137,6 +137,48 @@ WERROR rpccli_spoolss_getprinterdriver2(struct rpc_pipe_client *cli,
        return werror;
 }
 
+/**********************************************************************
+ convencience wrapper around rpccli_spoolss_AddPrinterEx
+**********************************************************************/
+
+WERROR rpccli_spoolss_addprinterex(struct rpc_pipe_client *cli,
+                                  TALLOC_CTX *mem_ctx,
+                                  struct spoolss_SetPrinterInfoCtr *info_ctr)
+{
+       WERROR result;
+       NTSTATUS status;
+       struct spoolss_DevmodeContainer devmode_ctr;
+       struct sec_desc_buf secdesc_ctr;
+       struct spoolss_UserLevelCtr userlevel_ctr;
+       struct spoolss_UserLevel1 level1;
+       struct policy_handle handle;
+
+       ZERO_STRUCT(devmode_ctr);
+       ZERO_STRUCT(secdesc_ctr);
+
+       level1.size             = 28;
+       level1.build            = 1381;
+       level1.major            = 2;
+       level1.minor            = 0;
+       level1.processor        = 0;
+       level1.client           = talloc_asprintf(mem_ctx, "\\\\%s", global_myname());
+       W_ERROR_HAVE_NO_MEMORY(level1.client);
+       level1.user             = cli->auth->user_name;
+
+       userlevel_ctr.level = 1;
+       userlevel_ctr.user_info.level1 = &level1;
+
+       status = rpccli_spoolss_AddPrinterEx(cli, mem_ctx,
+                                            cli->srv_name_slash,
+                                            info_ctr,
+                                            &devmode_ctr,
+                                            &secdesc_ctr,
+                                            &userlevel_ctr,
+                                            &handle,
+                                            &result);
+       return result;
+}
+
 /*********************************************************************
  Decode various spoolss rpc's and info levels
  ********************************************************************/