diff options
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/libnet/libnet.c | 1 | ||||
-rw-r--r-- | source4/torture/libnet/libnet_group.c | 80 |
2 files changed, 81 insertions, 0 deletions
diff --git a/source4/torture/libnet/libnet.c b/source4/torture/libnet/libnet.c index 0e5c9301f8..0bb70df1e0 100644 --- a/source4/torture/libnet/libnet.c +++ b/source4/torture/libnet/libnet.c @@ -42,6 +42,7 @@ NTSTATUS torture_net_init(void) torture_suite_add_simple_test(suite, "API-USERINFO", torture_userinfo_api); torture_suite_add_simple_test(suite, "API-USERLIST", torture_userlist); torture_suite_add_simple_test(suite, "API-GROUPINFO", torture_groupinfo_api); + torture_suite_add_simple_test(suite, "API-GROUPLIST", torture_grouplist); torture_suite_add_simple_test(suite, "API-RPCCONN-BIND", torture_rpc_connect_binding); torture_suite_add_simple_test(suite, "API-RPCCONN-SRV", torture_rpc_connect_srv); torture_suite_add_simple_test(suite, "API-RPCCONN-PDC", torture_rpc_connect_pdc); diff --git a/source4/torture/libnet/libnet_group.c b/source4/torture/libnet/libnet_group.c index 02fc0f7fd5..83aab48e90 100644 --- a/source4/torture/libnet/libnet_group.c +++ b/source4/torture/libnet/libnet_group.c @@ -202,6 +202,25 @@ static bool test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } +static bool test_lsa_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *domain_handle) +{ + NTSTATUS status; + struct lsa_Close r; + + r.in.handle = domain_handle; + r.out.handle = domain_handle; + + status = dcerpc_lsa_Close(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("Close lsa domain failed - %s\n", nt_errstr(status)); + return false; + } + + return true; +} + + bool torture_groupinfo_api(struct torture_context *torture) { const char *name = TEST_GROUPNAME; @@ -269,3 +288,64 @@ done: talloc_free(mem_ctx); return ret; } + + +bool torture_grouplist(struct torture_context *torture) +{ + bool ret = true; + NTSTATUS status; + TALLOC_CTX *mem_ctx = NULL; + struct libnet_context *ctx; + struct lsa_String domain_name; + struct libnet_GroupList req; + int i; + + ctx = libnet_context_init(NULL, torture->lp_ctx); + ctx->cred = cmdline_credentials; + + domain_name.string = lp_workgroup(torture->lp_ctx); + mem_ctx = talloc_init("torture group list"); + + ZERO_STRUCT(req); + + printf("listing group accounts:\n"); + + do { + req.in.domain_name = domain_name.string; + req.in.page_size = 128; + req.in.resume_index = req.out.resume_index; + + status = libnet_GroupList(ctx, mem_ctx, &req); + if (!NT_STATUS_IS_OK(status) && + !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) break; + + for (i = 0; i < req.out.count; i++) { + printf("\tgroup: %s, sid=%s\n", + req.out.groups[i].groupname, req.out.groups[i].sid); + } + + } while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)); + + if (!(NT_STATUS_IS_OK(status) || + NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES))) { + printf("libnet_GroupList call failed: %s\n", nt_errstr(status)); + ret = false; + goto done; + } + + if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) { + printf("domain close failed\n"); + ret = false; + } + + if (!test_lsa_close(ctx->lsa.pipe, mem_ctx, &ctx->lsa.handle)) { + printf("lsa domain close failed\n"); + ret = false; + } + + talloc_free(ctx); + +done: + talloc_free(mem_ctx); + return ret; +} |