From 1a27d29686e6a4e05f138488d3456ae4b86c4642 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Feb 2008 20:22:01 +0100 Subject: Add cmd_lsa_get_username command to rpcclient. Guenther (This used to be commit 66aac1d7f2a340d30dbbcff9b1589a2e24bacdaa) --- source3/rpcclient/cmd_lsarpc.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'source3/rpcclient/cmd_lsarpc.c') diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 075ba6e118..2fe06831f3 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -1091,6 +1091,46 @@ static NTSTATUS cmd_lsa_query_trustdominfo(struct rpc_pipe_client *cli, return result; } +static NTSTATUS cmd_lsa_get_username(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + POLICY_HND pol; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + const char *servername = cli->cli->desthost; + struct lsa_String *account_name = NULL; + struct lsa_String *authority_name = NULL; + + if (argc > 2) { + printf("Usage: %s servername\n", argv[0]); + return NT_STATUS_OK; + } + + result = rpccli_lsa_open_policy(cli, mem_ctx, true, + SEC_RIGHTS_MAXIMUM_ALLOWED, + &pol); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + result = rpccli_lsa_GetUserName(cli, mem_ctx, + servername, + &account_name, + &authority_name); + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + /* Print results */ + + printf("Account Name: %s, Authority Name: %s\n", + account_name->string, authority_name->string); + + rpccli_lsa_Close(cli, mem_ctx, &pol); + done: + return result; +} /* List of commands exported by this module */ @@ -1121,6 +1161,7 @@ struct cmd_set lsarpc_commands[] = { { "lsaquerytrustdominfo",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfo, NULL, PI_LSARPC, NULL, "Query LSA trusted domains info (given a SID)", "" }, { "lsaquerytrustdominfobyname",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobyname, NULL, PI_LSARPC, NULL, "Query LSA trusted domains info (given a name), only works for Windows > 2k", "" }, { "lsaquerytrustdominfobysid",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobysid, NULL, PI_LSARPC, NULL, "Query LSA trusted domains info (given a SID)", "" }, + { "getusername", RPC_RTYPE_NTSTATUS, cmd_lsa_get_username, NULL, PI_LSARPC, NULL, "Get username", "" }, { NULL } }; -- cgit