From 4659d4f9e2bfdbd253ff14e9181dd65023ff6c6a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 10 Nov 2003 12:12:22 +0000 Subject: added IDL and test for lsa_EnumAccountRights() interestingly, win2000 doesn't return the same list of rights via lsa_EnumAccountRights() and lsa_EnumPrivsAccount() (This used to be commit 447c5f13d40d05a49b8bfa1c28c2797371ff5352) --- source4/librpc/idl/lsa.idl | 18 ++++++++++- source4/librpc/ndr/ndr_lsa.c | 74 ++++++++++++++++++++++++++++++++++++++++++-- source4/librpc/ndr/ndr_lsa.h | 16 ++++++++-- source4/librpc/rpc/rpc_lsa.c | 8 ++--- 4 files changed, 107 insertions(+), 9 deletions(-) (limited to 'source4/librpc') diff --git a/source4/librpc/idl/lsa.idl b/source4/librpc/idl/lsa.idl index 6766775c9c..fc8fddd85d 100644 --- a/source4/librpc/idl/lsa.idl +++ b/source4/librpc/idl/lsa.idl @@ -288,8 +288,24 @@ NTSTATUS DELETEOBJECT (); /* Function: 0x23 */ NTSTATUS ENUMACCTWITHRIGHT (); + /* Function: 0x24 */ - NTSTATUS ENUMACCTRIGHTS (); + typedef struct { + unistr *name; + } lsa_RightAttribute; + + typedef struct { + uint32 count; + [size_is(count)] lsa_Name *names; + } lsa_RightSet; + + NTSTATUS lsa_EnumAccountRights ( + [in,ref] policy_handle *handle, + [in,ref] dom_sid2 *sid, + [out,ref] lsa_RightSet *rights + ); + + /* Function: 0x25 */ NTSTATUS ADDACCTRIGHTS (); /* Function: 0x26 */ diff --git a/source4/librpc/ndr/ndr_lsa.c b/source4/librpc/ndr/ndr_lsa.c index 59d3fc9b7b..1b73482e9c 100644 --- a/source4/librpc/ndr/ndr_lsa.c +++ b/source4/librpc/ndr/ndr_lsa.c @@ -1179,14 +1179,84 @@ NTSTATUS ndr_pull_ENUMACCTWITHRIGHT(struct ndr_pull *ndr, struct ENUMACCTWITHRIG return NT_STATUS_OK; } -NTSTATUS ndr_push_ENUMACCTRIGHTS(struct ndr_push *ndr, struct ENUMACCTRIGHTS *r) +static NTSTATUS ndr_push_lsa_RightAttribute(struct ndr_push *ndr, int ndr_flags, struct lsa_RightAttribute *r) { + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_ptr(ndr, r->name)); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + if (r->name) { + NDR_CHECK(ndr_push_unistr(ndr, r->name)); + } +done: + return NT_STATUS_OK; +} + +static NTSTATUS ndr_pull_lsa_RightAttribute(struct ndr_pull *ndr, int ndr_flags, struct lsa_RightAttribute *r) +{ + uint32 _ptr_name; + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_name)); + if (_ptr_name) { + NDR_ALLOC(ndr, r->name); + } else { + r->name = NULL; + } +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + if (r->name) { + NDR_CHECK(ndr_pull_unistr(ndr, &r->name)); + } +done: + return NT_STATUS_OK; +} + +static NTSTATUS ndr_push_lsa_RightSet(struct ndr_push *ndr, int ndr_flags, struct lsa_RightSet *r) +{ + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_push_uint32(ndr, r->count)); + NDR_CHECK(ndr_push_ptr(ndr, r->names)); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + if (r->names) { + NDR_CHECK(ndr_push_array(ndr, ndr_flags, r->names, sizeof(r->names[0]), r->count, (ndr_push_flags_fn_t)ndr_push_lsa_Name)); + } +done: + return NT_STATUS_OK; +} + +static NTSTATUS ndr_pull_lsa_RightSet(struct ndr_pull *ndr, int ndr_flags, struct lsa_RightSet *r) +{ + uint32 _ptr_names; + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_uint32(ndr, &r->count)); + NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_names)); + if (_ptr_names) { + NDR_ALLOC(ndr, r->names); + } else { + r->names = NULL; + } +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + if (r->names) { + NDR_ALLOC_N_SIZE(ndr, r->names, r->count, sizeof(r->names[0])); + NDR_CHECK(ndr_pull_array(ndr, ndr_flags, (void **)r->names, sizeof(r->names[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_lsa_Name)); + } +done: + return NT_STATUS_OK; +} + +NTSTATUS ndr_push_lsa_EnumAccountRights(struct ndr_push *ndr, struct lsa_EnumAccountRights *r) +{ + NDR_CHECK(ndr_push_policy_handle(ndr, r->in.handle)); + NDR_CHECK(ndr_push_dom_sid2(ndr, r->in.sid)); return NT_STATUS_OK; } -NTSTATUS ndr_pull_ENUMACCTRIGHTS(struct ndr_pull *ndr, struct ENUMACCTRIGHTS *r) +NTSTATUS ndr_pull_lsa_EnumAccountRights(struct ndr_pull *ndr, struct lsa_EnumAccountRights *r) { + NDR_CHECK(ndr_pull_lsa_RightSet(ndr, NDR_SCALARS|NDR_BUFFERS, r->out.rights)); NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); return NT_STATUS_OK; diff --git a/source4/librpc/ndr/ndr_lsa.h b/source4/librpc/ndr/ndr_lsa.h index f8c4ab5f6a..a3d395760c 100644 --- a/source4/librpc/ndr/ndr_lsa.h +++ b/source4/librpc/ndr/ndr_lsa.h @@ -504,11 +504,23 @@ struct ENUMACCTWITHRIGHT { }; -struct ENUMACCTRIGHTS { +struct lsa_RightAttribute { + const char *name; +}; + +struct lsa_RightSet { + uint32 count; + struct lsa_Name *names; +}; + +struct lsa_EnumAccountRights { struct { + struct policy_handle *handle; + struct dom_sid2 *sid; } in; struct { + struct lsa_RightSet *rights; NTSTATUS result; } out; @@ -654,7 +666,7 @@ struct QUERYINFO2 { #define DCERPC_PRIV_GET_DISPNAME 33 #define DCERPC_DELETEOBJECT 34 #define DCERPC_ENUMACCTWITHRIGHT 35 -#define DCERPC_ENUMACCTRIGHTS 36 +#define DCERPC_LSA_ENUMACCOUNTRIGHTS 36 #define DCERPC_ADDACCTRIGHTS 37 #define DCERPC_REMOVEACCTRIGHTS 38 #define DCERPC_QUERYTRUSTDOMINFO 39 diff --git a/source4/librpc/rpc/rpc_lsa.c b/source4/librpc/rpc/rpc_lsa.c index c514cdbb78..dce1c7037e 100644 --- a/source4/librpc/rpc/rpc_lsa.c +++ b/source4/librpc/rpc/rpc_lsa.c @@ -507,12 +507,12 @@ NTSTATUS dcerpc_ENUMACCTWITHRIGHT(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, st return r->out.result; } -NTSTATUS dcerpc_ENUMACCTRIGHTS(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct ENUMACCTRIGHTS *r) +NTSTATUS dcerpc_lsa_EnumAccountRights(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct lsa_EnumAccountRights *r) { NTSTATUS status; - status = dcerpc_ndr_request(p, DCERPC_ENUMACCTRIGHTS, mem_ctx, - (ndr_push_fn_t) ndr_push_ENUMACCTRIGHTS, - (ndr_pull_fn_t) ndr_pull_ENUMACCTRIGHTS, + status = dcerpc_ndr_request(p, DCERPC_LSA_ENUMACCOUNTRIGHTS, mem_ctx, + (ndr_push_fn_t) ndr_push_lsa_EnumAccountRights, + (ndr_pull_fn_t) ndr_pull_lsa_EnumAccountRights, r); if (!NT_STATUS_IS_OK(status)) { return status; -- cgit