summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2004-06-10 13:07:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:51:55 -0500
commitb76daee923df4c59df99e2f48151319ac5807e3e (patch)
treecb7520267b27cc5e4e02c3aedfe015524b491454 /source3
parent459cb00785c1eb71a1886c5960b5176e85c48d57 (diff)
downloadsamba-b76daee923df4c59df99e2f48151319ac5807e3e.tar.gz
samba-b76daee923df4c59df99e2f48151319ac5807e3e.tar.bz2
samba-b76daee923df4c59df99e2f48151319ac5807e3e.zip
r1101: Implement 'rpcclient setprintername'.
Thanks to Guenther Deschner <gd@sernet.de>. This needs to be generalized somewhat. Jerry, which of the parameters in the printer_info_2 struct are settable via cli_spoolss_setprinter? Volker (This used to be commit 473dd03833f5b742499750c5f3c91ea515c78f7e)
Diffstat (limited to 'source3')
-rw-r--r--source3/rpcclient/cmd_spoolss.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index f5a440c024..d33d1cc90e 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -547,6 +547,76 @@ static WERROR cmd_spoolss_setprinter(struct cli_state *cli,
}
/***********************************************************************
+ * Set printer name - use a level2 set.
+ */
+static WERROR cmd_spoolss_setprintername(struct cli_state *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, const char **argv)
+{
+ POLICY_HND pol;
+ WERROR result;
+ uint32 needed;
+ uint32 info_level = 2;
+ BOOL opened_hnd = False;
+ PRINTER_INFO_CTR ctr;
+ fstring printername,
+ servername,
+ user,
+ new_printername;
+
+ if (argc == 1 || argc > 3) {
+ printf("Usage: %s printername new_printername\n", argv[0]);
+
+ return WERR_OK;
+ }
+
+ /* Open a printer handle */
+ if (argc == 3) {
+ fstrcpy(new_printername, argv[2]);
+ }
+
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
+ strupper_m(servername);
+ fstrcpy(printername, argv[1]);
+ fstrcpy(user, cli->user_name);
+
+ /* get a printer handle */
+ result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
+ PRINTER_ALL_ACCESS, servername,
+ user, &pol);
+
+ if (!W_ERROR_IS_OK(result))
+ goto done;
+
+ opened_hnd = True;
+
+ /* Get printer info */
+ result = cli_spoolss_getprinter(cli, mem_ctx, 0, &needed, &pol, info_level, &ctr);
+
+ if (W_ERROR_V(result) == ERRinsufficientbuffer)
+ result = cli_spoolss_getprinter(cli, mem_ctx, needed, NULL, &pol, info_level, &ctr);
+
+ if (!W_ERROR_IS_OK(result))
+ goto done;
+
+
+ /* Modify the printername. */
+ init_unistr(&ctr.printers_2->printername, new_printername);
+ ctr.printers_2->devmode = NULL;
+ ctr.printers_2->secdesc = NULL;
+
+ result = cli_spoolss_setprinter(cli, mem_ctx, &pol, info_level, &ctr, 0);
+ if (W_ERROR_IS_OK(result))
+ printf("Success in setting printername.\n");
+
+ done:
+ if (opened_hnd)
+ cli_spoolss_close_printer(cli, mem_ctx, &pol);
+
+ return result;
+}
+
+/***********************************************************************
* Get printer information
*/
static WERROR cmd_spoolss_getprinter(struct cli_state *cli,
@@ -2331,6 +2401,7 @@ struct cmd_set spoolss_commands[] = {
{ "deleteform", RPC_RTYPE_WERROR, NULL, cmd_spoolss_deleteform, PI_SPOOLSS, "Delete form", "" },
{ "enumforms", RPC_RTYPE_WERROR, NULL, cmd_spoolss_enum_forms, PI_SPOOLSS, "Enumerate forms", "" },
{ "setprinter", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprinter, PI_SPOOLSS, "Set printer comment", "" },
+ { "setprintername", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprintername, PI_SPOOLSS, "Set printername", "" },
{ "setprinterdata", RPC_RTYPE_WERROR, NULL, cmd_spoolss_setprinterdata, PI_SPOOLSS, "Set REG_SZ printer data", "" },
{ "rffpcnex", RPC_RTYPE_WERROR, NULL, cmd_spoolss_rffpcnex, PI_SPOOLSS, "Rffpcnex test", "" },