1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-13 13:18:06 +03:00

added samr_LookupRids() and test code

This commit is contained in:
Andrew Tridgell 0001-01-01 00:00:00 +00:00
parent f8397cbc85
commit c32c33a791
5 changed files with 120 additions and 16 deletions

View File

@ -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 */

View File

@ -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--;
}

View File

@ -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;

View File

@ -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;

View File

@ -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;