add another command to rpcclient: getdispname. Show the full description
authorJean-François Micouleau <jfm@samba.org>
Thu, 22 Nov 2001 16:54:48 +0000 (16:54 +0000)
committerJean-François Micouleau <jfm@samba.org>
Thu, 22 Nov 2001 16:54:48 +0000 (16:54 +0000)
of a privilege.

J.F.

source/libsmb/cli_lsarpc.c
source/rpc_parse/parse_lsa.c
source/rpcclient/cmd_lsarpc.c

index e8ed50206cea85d0e085b8af0aaa5dc127d8ac9b..c789badc72dbced9a32584ff66ecb830e0ee92a8 100644 (file)
@@ -689,4 +689,57 @@ NTSTATUS cli_lsa_enum_privilege(struct cli_state *cli, TALLOC_CTX *mem_ctx,
        return result;
 }
 
+/** Get privilege name */
+
+NTSTATUS cli_lsa_get_dispname(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+                             POLICY_HND *pol, char *name, uint16 lang_id, uint16 lang_id_sys,
+                             fstring description, uint16 *lang_id_desc)
+{
+       prs_struct qbuf, rbuf;
+       LSA_Q_PRIV_GET_DISPNAME q;
+       LSA_R_PRIV_GET_DISPNAME r;
+       NTSTATUS result;
+       int i;
+
+       ZERO_STRUCT(q);
+       ZERO_STRUCT(r);
+
+       /* Initialise parse structures */
+
+       prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+       prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
+
+       /* Marshall data and send request */
+
+       init_lsa_priv_get_dispname(&q, pol, name, lang_id, lang_id_sys);
+
+       if (!lsa_io_q_priv_get_dispname("", &q, &qbuf, 0) ||
+           !rpc_api_pipe_req(cli, LSA_PRIV_GET_DISPNAME, &qbuf, &rbuf)) {
+               result = NT_STATUS_UNSUCCESSFUL;
+               goto done;
+       }
+
+       /* Unmarshall response */
+
+       if (!lsa_io_r_priv_get_dispname("", &r, &rbuf, 0)) {
+               result = NT_STATUS_UNSUCCESSFUL;
+               goto done;
+       }
+
+       if (!NT_STATUS_IS_OK(result = r.status)) {
+               goto done;
+       }
+
+       /* Return output parameters */
+       
+       rpcstr_pull_unistr2_fstring(description , &r.desc);
+       *lang_id_desc = r.lang_id;
+
+ done:
+       prs_mem_free(&qbuf);
+       prs_mem_free(&rbuf);
+
+       return result;
+}
+
 /** @} **/
index 34feac32a709463c1d75b03cbe775adcab9a7945..767eb5ef190e0da8ddccbf5706c2f5f239591780 100644 (file)
@@ -1416,6 +1416,21 @@ BOOL lsa_io_r_enum_privs(char *desc, LSA_R_ENUM_PRIVS *r_q, prs_struct *ps, int
        return True;
 }
 
+void init_lsa_priv_get_dispname(LSA_Q_PRIV_GET_DISPNAME *trn, POLICY_HND *hnd, char *name, uint16 lang_id, uint16 lang_id_sys)
+{
+       int len_name = strlen(name);
+
+       if(len_name == 0)
+               len_name = 1;
+
+       memcpy(&trn->pol, hnd, sizeof(trn->pol));
+
+       init_uni_hdr(&trn->hdr_name, len_name);
+       init_unistr2(&trn->name, name, len_name);
+       trn->lang_id = lang_id;
+       trn->lang_id_sys = lang_id_sys;
+}
+
 /*******************************************************************
 reads or writes a structure.
 ********************************************************************/
index 766938408e513d86cba963ed01b36f2684474e2d..5b566cb238eb8d2d743c30b3c2ead837064d9c85 100644 (file)
@@ -269,6 +269,43 @@ static NTSTATUS cmd_lsa_enum_privilege(struct cli_state *cli,
        return result;
 }
 
+/* Get privilege name */
+
+static NTSTATUS cmd_lsa_get_dispname(struct cli_state *cli, 
+                                     TALLOC_CTX *mem_ctx, int argc, 
+                                     char **argv) 
+{
+       POLICY_HND pol;
+       NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+
+       uint16 lang_id=0;
+       uint16 lang_id_sys=0;
+       uint16 lang_id_desc;
+       fstring description;
+
+       if (argc != 2) {
+               printf("Usage: %s privilege name\n", argv[0]);
+               return NT_STATUS_OK;
+       }
+
+       result = cli_lsa_open_policy(cli, mem_ctx, True, 
+                                    SEC_RIGHTS_MAXIMUM_ALLOWED,
+                                    &pol);
+
+       if (!NT_STATUS_IS_OK(result))
+               goto done;
+
+       result = cli_lsa_get_dispname(cli, mem_ctx, &pol, argv[1], lang_id, lang_id_sys, description, &lang_id_desc);
+
+       if (!NT_STATUS_IS_OK(result))
+               goto done;
+
+       /* Print results */
+       printf("%s -> %s (language: 0x%x)\n", argv[1], description, lang_id_desc);
+
+ done:
+       return result;
+}
 /* List of commands exported by this module */
 
 struct cmd_set lsarpc_commands[] = {
@@ -280,6 +317,7 @@ struct cmd_set lsarpc_commands[] = {
        { "lookupnames", cmd_lsa_lookup_names,          PIPE_LSARPC, "Convert names to SIDs",     "" },
        { "enumtrust",   cmd_lsa_enum_trust_dom,        PIPE_LSARPC, "Enumerate trusted domains", "" },
        { "enumprivs",   cmd_lsa_enum_privilege,        PIPE_LSARPC, "Enumerate privileges",      "" },
+       { "getdispname", cmd_lsa_get_dispname,          PIPE_LSARPC, "Get the privilege name",    "" },
 
        { NULL }
 };