From: Günther Deschner Date: Thu, 1 Dec 2016 20:32:18 +0000 (+0100) Subject: s3-rpcclient: add enumpermachineconnections command X-Git-Tag: ldb-2.1.0~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce00972afc205af4f93cde5c3e30a07ec222670c;p=thirdparty%2Fsamba.git s3-rpcclient: add enumpermachineconnections 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 dbcfd17dba2..ce604227bf5 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -3994,6 +3994,57 @@ static WERROR cmd_spoolss_get_core_printer_drivers(struct rpc_pipe_client *cli, return WERR_OK; } +static WERROR cmd_spoolss_enum_permachineconnections(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; + DATA_BLOB in = data_blob_null; + DATA_BLOB out = data_blob_null; + uint32_t needed, count; + + if (argc > 2) { + printf("usage: %s [servername]\n", argv[0]); + return WERR_OK; + } + + if (argc > 1) { + servername = argv[1]; + } + + status = dcerpc_spoolss_EnumPerMachineConnections(b, mem_ctx, + servername, + &in, + in.length, + &out, + &needed, + &count, + &result); + if (!NT_STATUS_IS_OK(status)) { + return ntstatus_to_werror(status); + } + + if (W_ERROR_EQUAL(result, WERR_INSUFFICIENT_BUFFER)) { + in = data_blob_talloc_zero(mem_ctx, needed); + status = dcerpc_spoolss_EnumPerMachineConnections(b, mem_ctx, + servername, + &in, + in.length, + &out, + &needed, + &count, + &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[] = { @@ -4392,7 +4443,16 @@ struct cmd_set spoolss_commands[] = { .description = "Get CorePrinterDriver", .usage = "", }, - + { + .name = "enumpermachineconnections", + .returntype = RPC_RTYPE_WERROR, + .ntfn = NULL, + .wfn = cmd_spoolss_enum_permachineconnections, + .table = &ndr_table_spoolss, + .rpc_pipe = NULL, + .description = "Enumerate Per Machine Connections", + .usage = "", + }, { .name = NULL, },