From 52cae6b9088cae3c2daa8d195dcaba0c481a87d3 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 20 Nov 2003 03:18:07 +0000 Subject: added samr_LookupRids() and test code (This used to be commit c32c33a791dd42676ca7fa47aae264e8d8ea8339) --- source4/librpc/idl/samr.idl | 15 ++++++++- source4/librpc/ndr/ndr_samr.c | 78 +++++++++++++++++++++++++++++++++++++++---- source4/librpc/ndr/ndr_samr.h | 14 ++++++-- source4/librpc/rpc/rpc_samr.c | 12 +++---- 4 files changed, 104 insertions(+), 15 deletions(-) (limited to 'source4/librpc') diff --git a/source4/librpc/idl/samr.idl b/source4/librpc/idl/samr.idl index 55df200c22..8092e64d5b 100644 --- a/source4/librpc/idl/samr.idl +++ b/source4/librpc/idl/samr.idl @@ -284,9 +284,22 @@ [out] samr_Ids types ); + /************************/ /* Function 0x12 */ - NTSTATUS samr_LOOKUP_RIDS(); + + typedef struct { + uint32 count; + [size_is(count)] samr_Name *names; + } samr_Names; + + NTSTATUS samr_LookupRids( + [in,ref] policy_handle *handle, + [in] uint32 num_rids, + [in,ref,size_is(1000),length_is(num_rids)] uint32 *rids, + [out] samr_Names names, + [out] samr_Ids types + ); /************************/ /* Function 0x13 */ diff --git a/source4/librpc/ndr/ndr_samr.c b/source4/librpc/ndr/ndr_samr.c index 9297a2781b..a39c4a6aa8 100644 --- a/source4/librpc/ndr/ndr_samr.c +++ b/source4/librpc/ndr/ndr_samr.c @@ -190,8 +190,16 @@ NTSTATUS ndr_push_samr_LookupNames(struct ndr_push *ndr, struct samr_LookupNames return NT_STATUS_OK; } -NTSTATUS ndr_push_samr_LOOKUP_RIDS(struct ndr_push *ndr, struct samr_LOOKUP_RIDS *r) +NTSTATUS ndr_push_samr_LookupRids(struct ndr_push *ndr, struct samr_LookupRids *r) { + NDR_CHECK(ndr_push_policy_handle(ndr, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, r->in.num_rids)); + if (r->in.rids) { + NDR_CHECK(ndr_push_uint32(ndr, 1000)); + NDR_CHECK(ndr_push_uint32(ndr, 0)); + NDR_CHECK(ndr_push_uint32(ndr, r->in.num_rids)); + NDR_CHECK(ndr_push_array_uint32(ndr, NDR_SCALARS|NDR_BUFFERS, r->in.rids, r->in.num_rids)); + } return NT_STATUS_OK; } @@ -1175,8 +1183,41 @@ NTSTATUS ndr_pull_samr_LookupNames(struct ndr_pull *ndr, struct samr_LookupNames return NT_STATUS_OK; } -NTSTATUS ndr_pull_samr_LOOKUP_RIDS(struct ndr_pull *ndr, struct samr_LOOKUP_RIDS *r) +NTSTATUS ndr_pull_samr_Names(struct ndr_pull *ndr, int ndr_flags, struct samr_Names *r) { + uint32 _ptr_names; + NDR_CHECK(ndr_pull_struct_start(ndr)); + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_align(ndr, 4)); + 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; + } + ndr_pull_struct_end(ndr); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + if (r->names) { + { + uint32 _array_size; + NDR_CHECK(ndr_pull_uint32(ndr, &_array_size)); + if (r->count > _array_size) { + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should be %u", _array_size, r->count); + } + } + NDR_ALLOC_N_SIZE(ndr, r->names, r->count, sizeof(r->names[0])); + NDR_CHECK(ndr_pull_array(ndr, NDR_SCALARS|NDR_BUFFERS, (void **)r->names, sizeof(r->names[0]), r->count, (ndr_pull_flags_fn_t)ndr_pull_samr_Name)); + } +done: + return NT_STATUS_OK; +} + +NTSTATUS ndr_pull_samr_LookupRids(struct ndr_pull *ndr, struct samr_LookupRids *r) +{ + NDR_CHECK(ndr_pull_samr_Names(ndr, NDR_SCALARS|NDR_BUFFERS, &r->out.names)); + NDR_CHECK(ndr_pull_samr_Ids(ndr, NDR_SCALARS|NDR_BUFFERS, &r->out.types)); NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); return NT_STATUS_OK; @@ -3186,18 +3227,43 @@ void ndr_print_samr_LookupNames(struct ndr_print *ndr, const char *name, int fla ndr->depth--; } -void ndr_print_samr_LOOKUP_RIDS(struct ndr_print *ndr, const char *name, int flags, struct samr_LOOKUP_RIDS *r) +void ndr_print_samr_Names(struct ndr_print *ndr, const char *name, struct samr_Names *r) { - ndr_print_struct(ndr, name, "samr_LOOKUP_RIDS"); + ndr_print_struct(ndr, name, "samr_Names"); + ndr->depth++; + ndr_print_uint32(ndr, "count", r->count); + ndr_print_ptr(ndr, "names", r->names); + ndr->depth++; + if (r->names) { + ndr_print_array(ndr, "names", r->names, sizeof(r->names[0]), r->count, (ndr_print_fn_t)ndr_print_samr_Name); + } + ndr->depth--; + ndr->depth--; +} + +void ndr_print_samr_LookupRids(struct ndr_print *ndr, const char *name, int flags, struct samr_LookupRids *r) +{ + ndr_print_struct(ndr, name, "samr_LookupRids"); ndr->depth++; if (flags & NDR_IN) { - ndr_print_struct(ndr, "in", "samr_LOOKUP_RIDS"); + ndr_print_struct(ndr, "in", "samr_LookupRids"); + ndr->depth++; + ndr_print_ptr(ndr, "handle", r->in.handle); ndr->depth++; + ndr_print_policy_handle(ndr, "handle", r->in.handle); + ndr->depth--; + ndr_print_uint32(ndr, "num_rids", r->in.num_rids); + ndr_print_ptr(ndr, "rids", r->in.rids); + ndr->depth++; + ndr_print_array_uint32(ndr, "rids", r->in.rids, r->in.num_rids); + ndr->depth--; ndr->depth--; } if (flags & NDR_OUT) { - ndr_print_struct(ndr, "out", "samr_LOOKUP_RIDS"); + ndr_print_struct(ndr, "out", "samr_LookupRids"); ndr->depth++; + ndr_print_samr_Names(ndr, "names", &r->out.names); + ndr_print_samr_Ids(ndr, "types", &r->out.types); ndr_print_NTSTATUS(ndr, "result", &r->out.result); ndr->depth--; } diff --git a/source4/librpc/ndr/ndr_samr.h b/source4/librpc/ndr/ndr_samr.h index 452822b15e..18b1d68042 100644 --- a/source4/librpc/ndr/ndr_samr.h +++ b/source4/librpc/ndr/ndr_samr.h @@ -22,7 +22,7 @@ #define DCERPC_SAMR_ENUMDOMAINALIASES 15 #define DCERPC_SAMR_GETALIASMEMBERSHIP 16 #define DCERPC_SAMR_LOOKUPNAMES 17 -#define DCERPC_SAMR_LOOKUP_RIDS 18 +#define DCERPC_SAMR_LOOKUPRIDS 18 #define DCERPC_SAMR_OPENGROUP 19 #define DCERPC_SAMR_QUERYGROUPINFO 20 #define DCERPC_SAMR_SET_GROUPINFO 21 @@ -437,11 +437,21 @@ struct samr_LookupNames { }; -struct samr_LOOKUP_RIDS { +struct samr_Names { + uint32 count; + struct samr_Name *names; +}; + +struct samr_LookupRids { struct { + struct policy_handle *handle; + uint32 num_rids; + uint32 *rids; } in; struct { + struct samr_Names names; + struct samr_Ids types; NTSTATUS result; } out; diff --git a/source4/librpc/rpc/rpc_samr.c b/source4/librpc/rpc/rpc_samr.c index 16bb74aee1..a3b06ef81d 100644 --- a/source4/librpc/rpc/rpc_samr.c +++ b/source4/librpc/rpc/rpc_samr.c @@ -381,21 +381,21 @@ NTSTATUS dcerpc_samr_LookupNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, str return status; } -NTSTATUS dcerpc_samr_LOOKUP_RIDS(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_LOOKUP_RIDS *r) +NTSTATUS dcerpc_samr_LookupRids(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_LookupRids *r) { NTSTATUS status; if (p->flags & DCERPC_DEBUG_PRINT_IN) { - NDR_PRINT_IN_DEBUG(samr_LOOKUP_RIDS, r); + NDR_PRINT_IN_DEBUG(samr_LookupRids, r); } - status = dcerpc_ndr_request(p, DCERPC_SAMR_LOOKUP_RIDS, mem_ctx, - (ndr_push_fn_t) ndr_push_samr_LOOKUP_RIDS, - (ndr_pull_fn_t) ndr_pull_samr_LOOKUP_RIDS, + status = dcerpc_ndr_request(p, DCERPC_SAMR_LOOKUPRIDS, mem_ctx, + (ndr_push_fn_t) ndr_push_samr_LookupRids, + (ndr_pull_fn_t) ndr_pull_samr_LookupRids, r); if (NT_STATUS_IS_OK(status) && (p->flags & DCERPC_DEBUG_PRINT_OUT)) { - NDR_PRINT_OUT_DEBUG(samr_LOOKUP_RIDS, r); + NDR_PRINT_OUT_DEBUG(samr_LookupRids, r); } if (NT_STATUS_IS_OK(status)) status = r->out.result; -- cgit