]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3-rpcclient: add enumpermachineconnections command
authorGünther Deschner <gd@samba.org>
Thu, 1 Dec 2016 20:32:18 +0000 (21:32 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 8 Jan 2020 23:51:30 +0000 (23:51 +0000)
Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/rpcclient/cmd_spoolss.c

index dbcfd17dba22130c594d8c21e104505328d547ff..ce604227bf518e70bc8f8234fa46b6fc8d41f107 100644 (file)
@@ -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,
        },