From cf8571531924d723ccf0bbc9747c35d962b5cfa7 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Tue, 18 Jan 2005 18:28:34 +0000 Subject: r4821: finish off 'net rpc rights [list|grant|revoke]' one small todo item is to add a 'accounts' sub option to 'net rpc list' so enumerate all privileged SIDs and their associated rights. (This used to be commit bf4385c79a0ce2e4983ffa11d39367dbf1d4dcfd) --- source3/rpc_client/cli_lsarpc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'source3/rpc_client/cli_lsarpc.c') diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c index b360d8e622..bf2c0353c0 100644 --- a/source3/rpc_client/cli_lsarpc.c +++ b/source3/rpc_client/cli_lsarpc.c @@ -1217,7 +1217,7 @@ NTSTATUS cli_lsa_query_secobj(struct cli_state *cli, TALLOC_CTX *mem_ctx, */ NTSTATUS cli_lsa_enum_account_rights(struct cli_state *cli, TALLOC_CTX *mem_ctx, - POLICY_HND *pol, DOM_SID sid, + POLICY_HND *pol, DOM_SID *sid, uint32 *count, char ***privs_name) { prs_struct qbuf, rbuf; @@ -1225,6 +1225,7 @@ NTSTATUS cli_lsa_enum_account_rights(struct cli_state *cli, TALLOC_CTX *mem_ctx, LSA_R_ENUM_ACCT_RIGHTS r; NTSTATUS result; int i; + fstring *privileges; ZERO_STRUCT(q); ZERO_STRUCT(r); @@ -1235,7 +1236,7 @@ NTSTATUS cli_lsa_enum_account_rights(struct cli_state *cli, TALLOC_CTX *mem_ctx, prs_init(&rbuf, 0, mem_ctx, UNMARSHALL); /* Marshall data and send request */ - init_q_enum_acct_rights(&q, pol, 2, &sid); + init_q_enum_acct_rights(&q, pol, 2, sid); if (!lsa_io_q_enum_acct_rights("", &q, &qbuf, 0) || !rpc_api_pipe_req(cli, PI_LSARPC, LSA_ENUMACCTRIGHTS, &qbuf, &rbuf)) { @@ -1257,9 +1258,16 @@ NTSTATUS cli_lsa_enum_account_rights(struct cli_state *cli, TALLOC_CTX *mem_ctx, goto done; } + + privileges = TALLOC_ARRAY(mem_ctx, fstring, *count); *privs_name = TALLOC_ARRAY(mem_ctx, char *, *count); - for (i=0;i<*count;i++) { - pull_ucs2_talloc(mem_ctx, &(*privs_name)[i], r.rights.strings[i].string.buffer); + for ( i=0; i<*count; i++ ) { + /* ensure NULL termination ... what a hack */ + pull_ucs2(NULL, privileges[i], r.rights.strings[i].string.buffer, + sizeof(fstring), r.rights.strings[i].string.uni_str_len*2 , 0); + + /* now copy to the return array */ + *privs_name[i] = talloc_strdup( mem_ctx, privileges[i] ); } done: -- cgit