diff options
-rw-r--r-- | source4/librpc/idl/samr.idl | 40 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_samr.c | 222 | ||||
-rw-r--r-- | source4/librpc/ndr/ndr_samr.h | 55 | ||||
-rw-r--r-- | source4/librpc/rpc/rpc_samr.c | 16 | ||||
-rw-r--r-- | source4/torture/rpc/samr.c | 75 |
5 files changed, 363 insertions, 45 deletions
diff --git a/source4/librpc/idl/samr.idl b/source4/librpc/idl/samr.idl index 90e7a923d8..d906978466 100644 --- a/source4/librpc/idl/samr.idl +++ b/source4/librpc/idl/samr.idl @@ -245,11 +245,47 @@ /************************/ /* Function 0x13 */ - NTSTATUS samr_OPEN_GROUP(); + NTSTATUS samr_OpenGroup( + [in,ref] policy_handle *handle, + [in] uint32 access_mask, + [in] uint32 rid, + [out,ref] policy_handle *acct_handle + ); /************************/ /* Function 0x14 */ - NTSTATUS samr_QUERY_GROUPINFO(); + + typedef struct { + samr_Name name; + uint32 unknown; + uint32 members; + samr_Name description; + } samr_GroupInfoAll; + + typedef struct { + samr_Name Name; + } samr_GroupInfoName; + + typedef struct { + uint32 unknown; + } samr_GroupInfoX; + + typedef struct { + samr_Name description; + } samr_GroupInfoDesciption; + + typedef union { + case(1) samr_GroupInfoAll all; + case(2) samr_GroupInfoName name; + case(3) samr_GroupInfoX unknown; + case(4) samr_GroupInfoDesciption description; + } samr_GroupInfo; + + NTSTATUS samr_QueryGroupInfo( + [in,ref] policy_handle *handle, + [in] uint16 level, + [out,switch_is(level)] samr_GroupInfo *info + ); /************************/ /* Function 0x15 */ diff --git a/source4/librpc/ndr/ndr_samr.c b/source4/librpc/ndr/ndr_samr.c index 7077a97e17..423483a13a 100644 --- a/source4/librpc/ndr/ndr_samr.c +++ b/source4/librpc/ndr/ndr_samr.c @@ -157,14 +157,19 @@ NTSTATUS ndr_push_samr_LOOKUP_RIDS(struct ndr_push *ndr, struct samr_LOOKUP_RIDS return NT_STATUS_OK; } -NTSTATUS ndr_push_samr_OPEN_GROUP(struct ndr_push *ndr, struct samr_OPEN_GROUP *r) +NTSTATUS ndr_push_samr_OpenGroup(struct ndr_push *ndr, struct samr_OpenGroup *r) { + NDR_CHECK(ndr_push_policy_handle(ndr, r->in.handle)); + NDR_CHECK(ndr_push_uint32(ndr, r->in.access_mask)); + NDR_CHECK(ndr_push_uint32(ndr, r->in.rid)); return NT_STATUS_OK; } -NTSTATUS ndr_push_samr_QUERY_GROUPINFO(struct ndr_push *ndr, struct samr_QUERY_GROUPINFO *r) +NTSTATUS ndr_push_samr_QueryGroupInfo(struct ndr_push *ndr, struct samr_QueryGroupInfo *r) { + NDR_CHECK(ndr_push_policy_handle(ndr, r->in.handle)); + NDR_CHECK(ndr_push_uint16(ndr, r->in.level)); return NT_STATUS_OK; } @@ -626,19 +631,19 @@ static NTSTATUS ndr_pull_samr_DomInfo2(struct ndr_pull *ndr, int ndr_flags, stru if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->force_logoff_time)); - NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->unknown_name)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->unknown1)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->domain)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->primary)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->sequence_num)); - NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown_2)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown2)); NDR_CHECK(ndr_pull_uint32(ndr, &r->role)); - NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown_3)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown3)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_users)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_groups)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_aliases)); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; - NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->unknown_name)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->unknown1)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->domain)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->primary)); done: @@ -660,10 +665,10 @@ static NTSTATUS ndr_pull_samr_DomInfo4(struct ndr_pull *ndr, int ndr_flags, stru { if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 4)); - NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->unknown_name)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->unknown)); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; - NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->unknown_name)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->unknown)); done: return NT_STATUS_OK; } @@ -731,13 +736,13 @@ static NTSTATUS ndr_pull_samr_DomInfo11(struct ndr_pull *ndr, int ndr_flags, str if (!(ndr_flags & NDR_SCALARS)) goto buffers; NDR_CHECK(ndr_pull_align(ndr, 8)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->force_logoff_time)); - NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->unknown_name)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->unknown1)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->domain)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->primary)); NDR_CHECK(ndr_pull_HYPER_T(ndr, &r->sequence_num)); - NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown_2)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown2)); NDR_CHECK(ndr_pull_uint32(ndr, &r->role)); - NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown_3)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown3)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_users)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_groups)); NDR_CHECK(ndr_pull_uint32(ndr, &r->num_aliases)); @@ -746,7 +751,7 @@ static NTSTATUS ndr_pull_samr_DomInfo11(struct ndr_pull *ndr, int ndr_flags, str NDR_CHECK(ndr_pull_uint16(ndr, &r->lockout_threshold)); buffers: if (!(ndr_flags & NDR_BUFFERS)) goto done; - NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->unknown_name)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->unknown1)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->domain)); NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->primary)); done: @@ -1020,15 +1025,130 @@ NTSTATUS ndr_pull_samr_LOOKUP_RIDS(struct ndr_pull *ndr, struct samr_LOOKUP_RIDS return NT_STATUS_OK; } -NTSTATUS ndr_pull_samr_OPEN_GROUP(struct ndr_pull *ndr, struct samr_OPEN_GROUP *r) +NTSTATUS ndr_pull_samr_OpenGroup(struct ndr_pull *ndr, struct samr_OpenGroup *r) { + NDR_CHECK(ndr_pull_policy_handle(ndr, r->out.acct_handle)); NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); return NT_STATUS_OK; } -NTSTATUS ndr_pull_samr_QUERY_GROUPINFO(struct ndr_pull *ndr, struct samr_QUERY_GROUPINFO *r) +static NTSTATUS ndr_pull_samr_GroupInfoAll(struct ndr_pull *ndr, int ndr_flags, struct samr_GroupInfoAll *r) +{ + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->name)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->members)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->description)); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->name)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->description)); +done: + return NT_STATUS_OK; +} + +static NTSTATUS ndr_pull_samr_GroupInfoName(struct ndr_pull *ndr, int ndr_flags, struct samr_GroupInfoName *r) +{ + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->Name)); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->Name)); +done: + return NT_STATUS_OK; +} + +static NTSTATUS ndr_pull_samr_GroupInfoX(struct ndr_pull *ndr, int ndr_flags, struct samr_GroupInfoX *r) { + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, &r->unknown)); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; +done: + return NT_STATUS_OK; +} + +static NTSTATUS ndr_pull_samr_GroupInfoDesciption(struct ndr_pull *ndr, int ndr_flags, struct samr_GroupInfoDesciption *r) +{ + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_SCALARS, &r->description)); +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + NDR_CHECK(ndr_pull_samr_Name(ndr, NDR_BUFFERS, &r->description)); +done: + return NT_STATUS_OK; +} + +static NTSTATUS ndr_pull_samr_GroupInfo(struct ndr_pull *ndr, int ndr_flags, uint16 *level, union samr_GroupInfo *r) +{ + if (!(ndr_flags & NDR_SCALARS)) goto buffers; + NDR_CHECK(ndr_pull_uint16(ndr, level)); + switch (*level) { + case 1: { + NDR_CHECK(ndr_pull_samr_GroupInfoAll(ndr, NDR_SCALARS, &r->all)); + break; } + + case 2: { + NDR_CHECK(ndr_pull_samr_GroupInfoName(ndr, NDR_SCALARS, &r->name)); + break; } + + case 3: { + NDR_CHECK(ndr_pull_samr_GroupInfoX(ndr, NDR_SCALARS, &r->unknown)); + break; } + + case 4: { + NDR_CHECK(ndr_pull_samr_GroupInfoDesciption(ndr, NDR_SCALARS, &r->description)); + break; } + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); + } +buffers: + if (!(ndr_flags & NDR_BUFFERS)) goto done; + switch (*level) { + case 1: + NDR_CHECK(ndr_pull_samr_GroupInfoAll(ndr, NDR_BUFFERS, &r->all)); + break; + + case 2: + NDR_CHECK(ndr_pull_samr_GroupInfoName(ndr, NDR_BUFFERS, &r->name)); + break; + + case 3: + NDR_CHECK(ndr_pull_samr_GroupInfoX(ndr, NDR_BUFFERS, &r->unknown)); + break; + + case 4: + NDR_CHECK(ndr_pull_samr_GroupInfoDesciption(ndr, NDR_BUFFERS, &r->description)); + break; + + default: + return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u", *level); + } +done: + return NT_STATUS_OK; +} + +NTSTATUS ndr_pull_samr_QueryGroupInfo(struct ndr_pull *ndr, struct samr_QueryGroupInfo *r) +{ + uint32 _ptr_info; + NDR_CHECK(ndr_pull_uint32(ndr, &_ptr_info)); + if (_ptr_info) { + NDR_ALLOC(ndr, r->out.info); + } else { + r->out.info = NULL; + } + if (r->out.info) { + { uint16 _level; + NDR_CHECK(ndr_pull_samr_GroupInfo(ndr, NDR_SCALARS|NDR_BUFFERS, &_level, r->out.info)); + if (((NDR_SCALARS|NDR_BUFFERS) & NDR_SCALARS) && (_level != r->in.level)) return ndr_pull_error(ndr, NDR_ERR_BAD_SWITCH, "Bad switch value %u in info"); + } + } NDR_CHECK(ndr_pull_NTSTATUS(ndr, &r->out.result)); return NT_STATUS_OK; @@ -2022,13 +2142,13 @@ void ndr_print_samr_DomInfo2(struct ndr_print *ndr, const char *name, struct sam ndr_print_struct(ndr, name, "samr_DomInfo2"); ndr->depth++; ndr_print_HYPER_T(ndr, "force_logoff_time", r->force_logoff_time); - ndr_print_samr_Name(ndr, "unknown_name", &r->unknown_name); + ndr_print_samr_Name(ndr, "unknown1", &r->unknown1); ndr_print_samr_Name(ndr, "domain", &r->domain); ndr_print_samr_Name(ndr, "primary", &r->primary); ndr_print_HYPER_T(ndr, "sequence_num", r->sequence_num); - ndr_print_uint32(ndr, "unknown_2", r->unknown_2); + ndr_print_uint32(ndr, "unknown2", r->unknown2); ndr_print_uint32(ndr, "role", r->role); - ndr_print_uint32(ndr, "unknown_3", r->unknown_3); + ndr_print_uint32(ndr, "unknown3", r->unknown3); ndr_print_uint32(ndr, "num_users", r->num_users); ndr_print_uint32(ndr, "num_groups", r->num_groups); ndr_print_uint32(ndr, "num_aliases", r->num_aliases); @@ -2047,7 +2167,7 @@ void ndr_print_samr_DomInfo4(struct ndr_print *ndr, const char *name, struct sam { ndr_print_struct(ndr, name, "samr_DomInfo4"); ndr->depth++; - ndr_print_samr_Name(ndr, "unknown_name", &r->unknown_name); + ndr_print_samr_Name(ndr, "unknown", &r->unknown); ndr->depth--; } @@ -2097,13 +2217,13 @@ void ndr_print_samr_DomInfo11(struct ndr_print *ndr, const char *name, struct sa ndr_print_struct(ndr, name, "samr_DomInfo11"); ndr->depth++; ndr_print_HYPER_T(ndr, "force_logoff_time", r->force_logoff_time); - ndr_print_samr_Name(ndr, "unknown_name", &r->unknown_name); + ndr_print_samr_Name(ndr, "unknown1", &r->unknown1); ndr_print_samr_Name(ndr, "domain", &r->domain); ndr_print_samr_Name(ndr, "primary", &r->primary); ndr_print_HYPER_T(ndr, "sequence_num", r->sequence_num); - ndr_print_uint32(ndr, "unknown_2", r->unknown_2); + ndr_print_uint32(ndr, "unknown2", r->unknown2); ndr_print_uint32(ndr, "role", r->role); - ndr_print_uint32(ndr, "unknown_3", r->unknown_3); + ndr_print_uint32(ndr, "unknown3", r->unknown3); ndr_print_uint32(ndr, "num_users", r->num_users); ndr_print_uint32(ndr, "num_groups", r->num_groups); ndr_print_uint32(ndr, "num_aliases", r->num_aliases); @@ -2191,6 +2311,66 @@ void ndr_print_samr_DomainInfo(struct ndr_print *ndr, const char *name, uint16 l } } +void ndr_print_samr_GroupInfoAll(struct ndr_print *ndr, const char *name, struct samr_GroupInfoAll *r) +{ + ndr_print_struct(ndr, name, "samr_GroupInfoAll"); + ndr->depth++; + ndr_print_samr_Name(ndr, "name", &r->name); + ndr_print_uint32(ndr, "unknown", r->unknown); + ndr_print_uint32(ndr, "members", r->members); + ndr_print_samr_Name(ndr, "description", &r->description); + ndr->depth--; +} + +void ndr_print_samr_GroupInfoName(struct ndr_print *ndr, const char *name, struct samr_GroupInfoName *r) +{ + ndr_print_struct(ndr, name, "samr_GroupInfoName"); + ndr->depth++; + ndr_print_samr_Name(ndr, "Name", &r->Name); + ndr->depth--; +} + +void ndr_print_samr_GroupInfoX(struct ndr_print *ndr, const char *name, struct samr_GroupInfoX *r) +{ + ndr_print_struct(ndr, name, "samr_GroupInfoX"); + ndr->depth++; + ndr_print_uint32(ndr, "unknown", r->unknown); + ndr->depth--; +} + +void ndr_print_samr_GroupInfoDesciption(struct ndr_print *ndr, const char *name, struct samr_GroupInfoDesciption *r) +{ + ndr_print_struct(ndr, name, "samr_GroupInfoDesciption"); + ndr->depth++; + ndr_print_samr_Name(ndr, "description", &r->description); + ndr->depth--; +} + +void ndr_print_samr_GroupInfo(struct ndr_print *ndr, const char *name, uint16 level, union samr_GroupInfo *r) +{ + ndr_print_union(ndr, name, level, "samr_GroupInfo"); + switch (level) { + case 1: + ndr_print_samr_GroupInfoAll(ndr, "all", &r->all); + break; + + case 2: + ndr_print_samr_GroupInfoName(ndr, "name", &r->name); + break; + + case 3: + ndr_print_samr_GroupInfoX(ndr, "unknown", &r->unknown); + break; + + case 4: + ndr_print_samr_GroupInfoDesciption(ndr, "description", &r->description); + break; + + default: + ndr_print_bad_level(ndr, name, level); + } +} + void ndr_print_samr_UserInfo1(struct ndr_print *ndr, const char *name, struct samr_UserInfo1 *r) { ndr_print_struct(ndr, name, "samr_UserInfo1"); diff --git a/source4/librpc/ndr/ndr_samr.h b/source4/librpc/ndr/ndr_samr.h index f267e6d5d7..5708fcd405 100644 --- a/source4/librpc/ndr/ndr_samr.h +++ b/source4/librpc/ndr/ndr_samr.h @@ -122,13 +122,13 @@ struct samr_DomInfo1 { struct samr_DomInfo2 { HYPER_T force_logoff_time; - struct samr_Name unknown_name; + struct samr_Name unknown1; struct samr_Name domain; struct samr_Name primary; HYPER_T sequence_num; - uint32 unknown_2; + uint32 unknown2; uint32 role; - uint32 unknown_3; + uint32 unknown3; uint32 num_users; uint32 num_groups; uint32 num_aliases; @@ -139,7 +139,7 @@ struct samr_DomInfo3 { }; struct samr_DomInfo4 { - struct samr_Name unknown_name; + struct samr_Name unknown; }; struct samr_DomInfo5 { @@ -165,13 +165,13 @@ struct samr_DomInfo9 { struct samr_DomInfo11 { HYPER_T force_logoff_time; - struct samr_Name unknown_name; + struct samr_Name unknown1; struct samr_Name domain; struct samr_Name primary; HYPER_T sequence_num; - uint32 unknown_2; + uint32 unknown2; uint32 role; - uint32 unknown_3; + uint32 unknown3; uint32 num_users; uint32 num_groups; uint32 num_aliases; @@ -340,21 +340,54 @@ struct samr_LOOKUP_RIDS { }; -struct samr_OPEN_GROUP { +struct samr_OpenGroup { struct { + struct policy_handle *handle; + uint32 access_mask; + uint32 rid; } in; struct { + struct policy_handle *acct_handle; NTSTATUS result; } out; }; -struct samr_QUERY_GROUPINFO { +struct samr_GroupInfoAll { + struct samr_Name name; + uint32 unknown; + uint32 members; + struct samr_Name description; +}; + +struct samr_GroupInfoName { + struct samr_Name Name; +}; + +struct samr_GroupInfoX { + uint32 unknown; +}; + +struct samr_GroupInfoDesciption { + struct samr_Name description; +}; + +union samr_GroupInfo { +/* [case(1)] */ struct samr_GroupInfoAll all; +/* [case(2)] */ struct samr_GroupInfoName name; +/* [case(3)] */ struct samr_GroupInfoX unknown; +/* [case(4)] */ struct samr_GroupInfoDesciption description; +}; + +struct samr_QueryGroupInfo { struct { + struct policy_handle *handle; + uint16 level; } in; struct { + union samr_GroupInfo *info; NTSTATUS result; } out; @@ -1033,8 +1066,8 @@ struct samr_VALIDATE_PASSWORD { #define DCERPC_SAMR_GET_ALIAS_MEMBERSHIP 16 #define DCERPC_SAMR_LOOKUP_NAMES 17 #define DCERPC_SAMR_LOOKUP_RIDS 18 -#define DCERPC_SAMR_OPEN_GROUP 19 -#define DCERPC_SAMR_QUERY_GROUPINFO 20 +#define DCERPC_SAMR_OPENGROUP 19 +#define DCERPC_SAMR_QUERYGROUPINFO 20 #define DCERPC_SAMR_SET_GROUPINFO 21 #define DCERPC_SAMR_ADD_GROUPMEM 22 #define DCERPC_SAMR_DELETE_DOM_GROUP 23 diff --git a/source4/librpc/rpc/rpc_samr.c b/source4/librpc/rpc/rpc_samr.c index 97298ffa06..d636618d23 100644 --- a/source4/librpc/rpc/rpc_samr.c +++ b/source4/librpc/rpc/rpc_samr.c @@ -269,12 +269,12 @@ NTSTATUS dcerpc_samr_LOOKUP_RIDS(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, str return r->out.result; } -NTSTATUS dcerpc_samr_OPEN_GROUP(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_OPEN_GROUP *r) +NTSTATUS dcerpc_samr_OpenGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_OpenGroup *r) { NTSTATUS status; - status = dcerpc_ndr_request(p, DCERPC_SAMR_OPEN_GROUP, mem_ctx, - (ndr_push_fn_t) ndr_push_samr_OPEN_GROUP, - (ndr_pull_fn_t) ndr_pull_samr_OPEN_GROUP, + status = dcerpc_ndr_request(p, DCERPC_SAMR_OPENGROUP, mem_ctx, + (ndr_push_fn_t) ndr_push_samr_OpenGroup, + (ndr_pull_fn_t) ndr_pull_samr_OpenGroup, r); if (!NT_STATUS_IS_OK(status)) { return status; @@ -283,12 +283,12 @@ NTSTATUS dcerpc_samr_OPEN_GROUP(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, stru return r->out.result; } -NTSTATUS dcerpc_samr_QUERY_GROUPINFO(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_QUERY_GROUPINFO *r) +NTSTATUS dcerpc_samr_QueryGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_QueryGroupInfo *r) { NTSTATUS status; - status = dcerpc_ndr_request(p, DCERPC_SAMR_QUERY_GROUPINFO, mem_ctx, - (ndr_push_fn_t) ndr_push_samr_QUERY_GROUPINFO, - (ndr_pull_fn_t) ndr_pull_samr_QUERY_GROUPINFO, + status = dcerpc_ndr_request(p, DCERPC_SAMR_QUERYGROUPINFO, mem_ctx, + (ndr_push_fn_t) ndr_push_samr_QueryGroupInfo, + (ndr_pull_fn_t) ndr_pull_samr_QueryGroupInfo, r); if (!NT_STATUS_IS_OK(status)) { return status; diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c index e8771f2e5a..f8b89699e2 100644 --- a/source4/torture/rpc/samr.c +++ b/source4/torture/rpc/samr.c @@ -21,6 +21,34 @@ #include "includes.h" +static BOOL test_QueryGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle) +{ + NTSTATUS status; + struct samr_QueryGroupInfo r; + uint16 levels[] = {1, 2, 3, 4}; + int i; + BOOL ret = True; + + for (i=0;i<ARRAY_SIZE(levels);i++) { + printf("Testing QueryGroupInfo level %u\n", levels[i]); + + r.in.handle = handle; + r.in.level = levels[i]; + + status = dcerpc_samr_QueryGroupInfo(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("QueryGroupInfo level %u failed - %s\n", + levels[i], nt_errstr(status)); + ret = False; + } + + NDR_PRINT_UNION_DEBUG(samr_GroupInfo, r.in.level, r.out.info); + } + + return ret; +} + static BOOL test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { @@ -56,6 +84,7 @@ static BOOL test_OpenUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, NTSTATUS status; struct samr_OpenUser r; struct policy_handle acct_handle; + BOOL ret = True; printf("Testing OpenUser(%u)\n", rid); @@ -71,10 +100,38 @@ static BOOL test_OpenUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } if (!test_QueryUserInfo(p, mem_ctx, &acct_handle)) { + ret = False; + } + + return ret; +} + +static BOOL test_OpenGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, uint32 rid) +{ + NTSTATUS status; + struct samr_OpenGroup r; + struct policy_handle acct_handle; + BOOL ret = True; + + printf("Testing OpenGroup(%u)\n", rid); + + r.in.handle = handle; + r.in.access_mask = SEC_RIGHTS_MAXIMUM_ALLOWED; + r.in.rid = rid; + r.out.acct_handle = &acct_handle; + + status = dcerpc_samr_OpenGroup(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("OpenGroup(%u) failed - %s\n", rid, nt_errstr(status)); return False; } - - return True; + + if (!test_QueryGroupInfo(p, mem_ctx, &acct_handle)) { + ret = False; + } + + return ret; } static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, @@ -121,6 +178,8 @@ static BOOL test_EnumDomainGroups(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, NTSTATUS status; struct samr_EnumDomainGroups r; uint32 resume_handle=0; + int i; + BOOL ret = True; printf("Testing EnumDomainGroups\n"); @@ -137,7 +196,17 @@ static BOOL test_EnumDomainGroups(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, NDR_PRINT_DEBUG(samr_SamArray, r.out.sam); - return True; + if (!r.out.sam) { + return False; + } + + for (i=0;i<r.out.sam->count;i++) { + if (!test_OpenGroup(p, mem_ctx, handle, r.out.sam->entries[i].idx)) { + ret = False; + } + } + + return ret; } static BOOL test_EnumDomainAliases(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, |