diff options
author | Günther Deschner <gd@samba.org> | 2008-03-09 20:55:19 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-03-10 03:43:40 +0100 |
commit | 28d53070345e23e6a3b7bea91602a619eb5792bd (patch) | |
tree | 1b4071e48b5b7aee497d1ff0827d2d2edd6d1ff8 /source3 | |
parent | 4c67f6c542d779f6bfa24d0d5abec1b8492728e6 (diff) | |
download | samba-28d53070345e23e6a3b7bea91602a619eb5792bd.tar.gz samba-28d53070345e23e6a3b7bea91602a619eb5792bd.tar.bz2 samba-28d53070345e23e6a3b7bea91602a619eb5792bd.zip |
Add netsessenum command to rpcclient.
Guenther
(This used to be commit f90306bd24bc243c8f30a16c0414031d69d05c03)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/rpcclient/cmd_srvsvc.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c index 351b0cb5c0..3e0050c728 100644 --- a/source3/rpcclient/cmd_srvsvc.c +++ b/source3/rpcclient/cmd_srvsvc.c @@ -661,6 +661,89 @@ static WERROR cmd_srvsvc_net_sess_del(struct rpc_pipe_client *cli, return result; } +static WERROR cmd_srvsvc_net_sess_enum(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, + int argc, const char **argv) +{ + WERROR result; + NTSTATUS status; + struct srvsvc_NetSessInfoCtr info_ctr; + struct srvsvc_NetSessCtr0 ctr0; + struct srvsvc_NetSessCtr1 ctr1; + struct srvsvc_NetSessCtr2 ctr2; + struct srvsvc_NetSessCtr10 ctr10; + struct srvsvc_NetSessCtr502 ctr502; + uint32_t total_entries = 0; + uint32_t resume_handle = 0; + uint32_t level = 1; + const char *client = NULL; + const char *user = NULL; + + if (argc > 5) { + printf("Usage: %s [client] [user]\n", argv[0]); + return WERR_OK; + } + + if (argc >= 2) { + client = argv[1]; + } + + if (argc >= 3) { + user = argv[2]; + } + + if (argc >= 4) { + level = atoi(argv[3]); + } + + ZERO_STRUCT(info_ctr); + + info_ctr.level = level; + + d_printf("trying level: %d\n", level); + + switch (level) { + case 0: + ZERO_STRUCT(ctr0); + info_ctr.ctr.ctr0 = &ctr0; + break; + case 1: + ZERO_STRUCT(ctr1); + info_ctr.ctr.ctr1 = &ctr1; + break; + case 2: + ZERO_STRUCT(ctr2); + info_ctr.ctr.ctr2 = &ctr2; + break; + case 10: + ZERO_STRUCT(ctr10); + info_ctr.ctr.ctr10 = &ctr10; + break; + case 502: + ZERO_STRUCT(ctr502); + info_ctr.ctr.ctr502 = &ctr502; + break; + } + + status = rpccli_srvsvc_NetSessEnum(cli, mem_ctx, + cli->cli->desthost, + client, + user, + &info_ctr, + 0xffffffff, + &total_entries, + &resume_handle, + &result); + + if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { + goto done; + } + + done: + return result; +} + + /* List of commands exported by this module */ @@ -678,6 +761,7 @@ struct cmd_set srvsvc_commands[] = { { "netnamevalidate", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_name_validate, PI_SRVSVC, NULL, "Validate sharename", "" }, { "netfilegetsec", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_file_get_sec, PI_SRVSVC, NULL, "Get File security", "" }, { "netsessdel", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_sess_del, PI_SRVSVC, NULL, "Delete Session", "" }, + { "netsessenum", RPC_RTYPE_WERROR, NULL, cmd_srvsvc_net_sess_enum, PI_SRVSVC, NULL, "Enumerate Sessions", "" }, { NULL } }; |