port latest changes from SAMBA_3_0 tree
[kai/samba.git] / source3 / rpc_client / cli_lsarpc.c
index 2b65c67f15690970faacc4d2b15e0862ae1aa89e..db873236e46b49790462d679211f3e70710b4f1e 100644 (file)
@@ -805,7 +805,8 @@ NTSTATUS cli_lsa_enum_privilege(struct cli_state *cli, TALLOC_CTX *mem_ctx,
 /** 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,
+                             POLICY_HND *pol, const char *name, 
+                             uint16 lang_id, uint16 lang_id_sys,
                              fstring description, uint16 *lang_id_desc)
 {
        prs_struct qbuf, rbuf;
@@ -1050,7 +1051,7 @@ NTSTATUS cli_lsa_enum_privsaccount(struct cli_state *cli, TALLOC_CTX *mem_ctx,
 /** Get a privilege value given its name */
 
 NTSTATUS cli_lsa_lookupprivvalue(struct cli_state *cli, TALLOC_CTX *mem_ctx,
-                             POLICY_HND *pol, char *name, LUID *luid)
+                                POLICY_HND *pol, const char *name, LUID *luid)
 {
        prs_struct qbuf, rbuf;
        LSA_Q_LOOKUPPRIVVALUE q;
@@ -1207,6 +1208,91 @@ done:
 }
 
 
+
+/* add account rights to an account. */
+
+NTSTATUS cli_lsa_add_account_rights(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+                                   POLICY_HND *pol, DOM_SID sid,
+                                   uint32 count, const char **privs_name)
+{
+       prs_struct qbuf, rbuf;
+       LSA_Q_ADD_ACCT_RIGHTS q;
+       LSA_R_ADD_ACCT_RIGHTS r;
+       NTSTATUS result;
+
+       ZERO_STRUCT(q);
+
+       /* 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_q_add_acct_rights(&q, pol, &sid, count, privs_name);
+
+       if (!lsa_io_q_add_acct_rights("", &q, &qbuf, 0) ||
+           !rpc_api_pipe_req(cli, LSA_ADDACCTRIGHTS, &qbuf, &rbuf)) {
+               result = NT_STATUS_UNSUCCESSFUL;
+               goto done;
+       }
+
+       /* Unmarshall response */
+
+       if (!lsa_io_r_add_acct_rights("", &r, &rbuf, 0)) {
+               result = NT_STATUS_UNSUCCESSFUL;
+               goto done;
+       }
+
+       if (!NT_STATUS_IS_OK(result = r.status)) {
+               goto done;
+       }
+done:
+
+       return result;
+}
+
+
+/* remove account rights for an account. */
+
+NTSTATUS cli_lsa_remove_account_rights(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+                                      POLICY_HND *pol, DOM_SID sid, BOOL removeall,
+                                      uint32 count, const char **privs_name)
+{
+       prs_struct qbuf, rbuf;
+       LSA_Q_REMOVE_ACCT_RIGHTS q;
+       LSA_R_REMOVE_ACCT_RIGHTS r;
+       NTSTATUS result;
+
+       ZERO_STRUCT(q);
+
+       /* 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_q_remove_acct_rights(&q, pol, &sid, removeall?1:0, count, privs_name);
+
+       if (!lsa_io_q_remove_acct_rights("", &q, &qbuf, 0) ||
+           !rpc_api_pipe_req(cli, LSA_REMOVEACCTRIGHTS, &qbuf, &rbuf)) {
+               result = NT_STATUS_UNSUCCESSFUL;
+               goto done;
+       }
+
+       /* Unmarshall response */
+
+       if (!lsa_io_r_remove_acct_rights("", &r, &rbuf, 0)) {
+               result = NT_STATUS_UNSUCCESSFUL;
+               goto done;
+       }
+
+       if (!NT_STATUS_IS_OK(result = r.status)) {
+               goto done;
+       }
+done:
+
+       return result;
+}
+
+
 #if 0
 
 /** An example of how to use the routines in this file.  Fetch a DOMAIN