summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2003-11-20 03:18:07 +0000
committerAndrew Tridgell <tridge@samba.org>2003-11-20 03:18:07 +0000
commit52cae6b9088cae3c2daa8d195dcaba0c481a87d3 (patch)
tree6f3166e981ea43726dd511b1439d2970225040fe
parent308cc429eb7c07d94609f2818e9d81239cb4cbb9 (diff)
downloadsamba-52cae6b9088cae3c2daa8d195dcaba0c481a87d3.tar.gz
samba-52cae6b9088cae3c2daa8d195dcaba0c481a87d3.tar.bz2
samba-52cae6b9088cae3c2daa8d195dcaba0c481a87d3.zip
added samr_LookupRids() and test code
(This used to be commit c32c33a791dd42676ca7fa47aae264e8d8ea8339)
-rw-r--r--source4/librpc/idl/samr.idl15
-rw-r--r--source4/librpc/ndr/ndr_samr.c78
-rw-r--r--source4/librpc/ndr/ndr_samr.h14
-rw-r--r--source4/librpc/rpc/rpc_samr.c12
-rw-r--r--source4/torture/rpc/samr.c17
5 files changed, 120 insertions, 16 deletions
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;
diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c
index 404456ddee..4774a62ebd 100644
--- a/source4/torture/rpc/samr.c
+++ b/source4/torture/rpc/samr.c
@@ -338,6 +338,7 @@ static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
int i;
BOOL ret = True;
struct samr_LookupNames n;
+ struct samr_LookupRids lr ;
printf("Testing EnumDomainUsers\n");
@@ -377,7 +378,21 @@ static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
status = dcerpc_samr_LookupNames(p, mem_ctx, &n);
if (!NT_STATUS_IS_OK(status)) {
printf("LookupNames failed - %s\n", nt_errstr(status));
- return False;
+ ret = False;
+ }
+
+
+ printf("Testing LookupRids\n");
+ lr.in.handle = handle;
+ lr.in.num_rids = r.out.sam->count;
+ lr.in.rids = talloc(mem_ctx, r.out.sam->count * sizeof(uint32));
+ for (i=0;i<r.out.sam->count;i++) {
+ lr.in.rids[i] = r.out.sam->entries[i].idx;
+ }
+ status = dcerpc_samr_LookupRids(p, mem_ctx, &lr);
+ if (!NT_STATUS_IS_OK(status)) {
+ printf("LookupRids failed - %s\n", nt_errstr(status));
+ ret = False;
}
return ret;