From: Günther Deschner Date: Mon, 23 Dec 2019 11:42:53 +0000 (+0100) Subject: s3-rpcclient: add addpermachineconnection command X-Git-Tag: ldb-2.1.0~80 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3c2833f1bb5622c438ec1c7b287e53fce83a6c2;p=thirdparty%2Fsamba.git s3-rpcclient: add addpermachineconnection command Guenther Signed-off-by: Guenther Deschner Reviewed-by: Jeremy Allison --- diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index ce604227bf5..d1349b6c1d9 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -4045,6 +4045,55 @@ static WERROR cmd_spoolss_enum_permachineconnections(struct rpc_pipe_client *cli return result; } +static WERROR cmd_spoolss_add_permachineconnection(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + NTSTATUS status; + WERROR result; + struct dcerpc_binding_handle *b = cli->binding_handle; + const char *servername = cli->srv_name_slash; + const char *printername = "Microsoft Print to PDF"; + const char *printserver = "samba.org"; + const char *provider = ""; /* refers to Win32spl.dll then */ + const char *composed_printername; + + if (argc > 5) { + printf("usage: %s [servername] [printername] [printserver] [provider]\n", argv[0]); + return WERR_OK; + } + + if (argc > 1) { + servername = argv[1]; + } + if (argc > 2) { + printername = argv[2]; + } + if (argc > 3) { + printserver = argv[3]; + } + if (argc > 4) { + provider = argv[4]; + } + + composed_printername = talloc_asprintf(mem_ctx, "%s\\%s", servername, + printername); + if (composed_printername == NULL) { + return WERR_NOT_ENOUGH_MEMORY; + } + status = dcerpc_spoolss_AddPerMachineConnection(b, mem_ctx, + servername, + composed_printername, + printserver, + provider, + &result); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + return result; +} + /* List of commands exported by this module */ struct cmd_set spoolss_commands[] = { @@ -4453,6 +4502,16 @@ struct cmd_set spoolss_commands[] = { .description = "Enumerate Per Machine Connections", .usage = "", }, + { + .name = "addpermachineconnection", + .returntype = RPC_RTYPE_WERROR, + .ntfn = NULL, + .wfn = cmd_spoolss_add_permachineconnection, + .table = &ndr_table_spoolss, + .rpc_pipe = NULL, + .description = "Add Per Machine Connection", + .usage = "", + }, { .name = NULL, },