diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-12-14 06:10:45 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:07:25 -0500 |
commit | 463ba76d4440c7f229a51ef8e565a31107a55b2c (patch) | |
tree | 01d6a6e9c7356f0501c7d785efda828d100dc16a /source4/rpc_server/lsa/dcesrv_lsa.c | |
parent | 5bb1939e9e65e6b0c27310e412bfa94d67ee977e (diff) | |
download | samba-463ba76d4440c7f229a51ef8e565a31107a55b2c.tar.gz samba-463ba76d4440c7f229a51ef8e565a31107a55b2c.tar.bz2 samba-463ba76d4440c7f229a51ef8e565a31107a55b2c.zip |
r4198: - added server side code for lsa_AddAccountRights
(This used to be commit ba87142586672a1082200048e7d1ae865d266d6c)
Diffstat (limited to 'source4/rpc_server/lsa/dcesrv_lsa.c')
-rw-r--r-- | source4/rpc_server/lsa/dcesrv_lsa.c | 68 |
1 files changed, 63 insertions, 5 deletions
diff --git a/source4/rpc_server/lsa/dcesrv_lsa.c b/source4/rpc_server/lsa/dcesrv_lsa.c index 9f708dac10..9f205d6ef0 100644 --- a/source4/rpc_server/lsa/dcesrv_lsa.c +++ b/source4/rpc_server/lsa/dcesrv_lsa.c @@ -1031,18 +1031,76 @@ static NTSTATUS lsa_EnumAccountRights(struct dcesrv_call_state *dce_call, /* lsa_AddAccountRights */ -static NTSTATUS lsa_AddAccountRights(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct lsa_AddAccountRights *r) +static NTSTATUS lsa_AddAccountRights(struct dcesrv_call_state *dce_call, + TALLOC_CTX *mem_ctx, + struct lsa_AddAccountRights *r) { - DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); + struct dcesrv_handle *h; + struct lsa_policy_state *state; + const char *sidstr; + struct ldb_message msg; + struct ldb_message_element el; + int i, ret; + const char *dn; + + DCESRV_PULL_HANDLE(h, r->in.handle, LSA_HANDLE_POLICY); + + state = h->data; + + sidstr = dom_sid_string(mem_ctx, r->in.sid); + if (sidstr == NULL) { + return NT_STATUS_NO_MEMORY; + } + + dn = samdb_search_string(state->sam_ctx, mem_ctx, NULL, "dn", + "objectSid=%s", sidstr); + if (dn == NULL) { + return NT_STATUS_NO_SUCH_USER; + } + + msg.dn = talloc_strdup(mem_ctx, dn); + if (msg.dn == NULL) { + return NT_STATUS_NO_MEMORY; + } + msg.num_elements = 1; + msg.elements = ⪙ + el.flags = LDB_FLAG_MOD_ADD; + el.name = talloc_strdup(mem_ctx, "privilege"); + if (el.name == NULL) { + return NT_STATUS_NO_MEMORY; + } + el.num_values = r->in.rights->count; + el.values = talloc_array_p(mem_ctx, struct ldb_val, el.num_values); + if (el.values == NULL) { + return NT_STATUS_NO_MEMORY; + } + for (i=0;i<el.num_values;i++) { + if (sec_privilege_id(r->in.rights->names[i].string) == -1) { + return NT_STATUS_NO_SUCH_PRIVILEGE; + } + el.values[i].length = strlen(r->in.rights->names[i].string); + el.values[i].data = talloc_strdup(mem_ctx, + r->in.rights->names[i].string); + if (el.values[i].data == NULL) { + return NT_STATUS_NO_MEMORY; + } + } + + ret = samdb_modify(state->sam_ctx, mem_ctx, &msg); + if (ret != 0) { + return NT_STATUS_UNEXPECTED_IO_ERROR; + } + + return NT_STATUS_OK; } /* lsa_RemoveAccountRights */ -static NTSTATUS lsa_RemoveAccountRights(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, - struct lsa_RemoveAccountRights *r) +static NTSTATUS lsa_RemoveAccountRights(struct dcesrv_call_state *dce_call, + TALLOC_CTX *mem_ctx, + struct lsa_RemoveAccountRights *r) { DCESRV_FAULT(DCERPC_FAULT_OP_RNG_ERROR); } |