diff options
author | Rafal Szczesniak <mimir@samba.org> | 2006-11-06 23:22:57 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:24:59 -0500 |
commit | 9355c6ff85f870123d9aa1ea1549ee0fae5dfbe3 (patch) | |
tree | c8036ccf8bc96e4fa958978b2d8d1f7f7cad0d19 /source4/torture | |
parent | ac43520c5a9791371e03c91e4a3e929e2ed21d1a (diff) | |
download | samba-9355c6ff85f870123d9aa1ea1549ee0fae5dfbe3.tar.gz samba-9355c6ff85f870123d9aa1ea1549ee0fae5dfbe3.tar.bz2 samba-9355c6ff85f870123d9aa1ea1549ee0fae5dfbe3.zip |
r19592: a simple test for libnet_UserList
rafal
(This used to be commit cfcbddfe71ce27bf195a1877f75789ef23bb6b1d)
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/libnet/libnet_user.c | 79 |
1 files changed, 72 insertions, 7 deletions
diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c index 606e0212e1..046ad3fec4 100644 --- a/source4/torture/libnet/libnet_user.c +++ b/source4/torture/libnet/libnet_user.c @@ -24,6 +24,7 @@ #include "lib/cmdline/popt_common.h" #include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr_c.h" +#include "librpc/gen_ndr/ndr_lsa_c.h" #include "torture/torture.h" #include "torture/rpc/rpc.h" #include "torture/libnet/usertest.h" @@ -135,8 +136,8 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } -static BOOL test_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *domain_handle) +static BOOL test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *domain_handle) { NTSTATUS status; struct samr_Close r; @@ -146,7 +147,7 @@ static BOOL test_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Close(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - printf("Close failed - %s\n", nt_errstr(status)); + printf("Close samr domain failed - %s\n", nt_errstr(status)); return False; } @@ -154,6 +155,25 @@ static BOOL test_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; +} + + static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, const char* user) { @@ -243,7 +263,7 @@ BOOL torture_createuser(struct torture_context *torture) goto done; } - if (!test_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) { + if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) { printf("domain close failed\n"); ret = False; } @@ -571,7 +591,7 @@ cleanup: goto done; } - if (!test_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) { + if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) { printf("domain close failed\n"); ret = False; } @@ -591,7 +611,7 @@ BOOL torture_userinfo_api(struct torture_context *torture) const char *binding; BOOL ret = True; NTSTATUS status; - TALLOC_CTX *mem_ctx=NULL, *prep_mem_ctx; + TALLOC_CTX *mem_ctx = NULL, *prep_mem_ctx; struct libnet_context *ctx; struct dcerpc_pipe *p; struct policy_handle h; @@ -643,7 +663,52 @@ BOOL torture_userinfo_api(struct torture_context *torture) goto done; } - if (!test_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) { + if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) { + printf("domain close failed\n"); + ret = False; + } + + talloc_free(ctx); + +done: + talloc_free(mem_ctx); + return ret; +} + + +BOOL torture_userlist(struct torture_context *torture) +{ + const char *binding; + BOOL ret = True; + NTSTATUS status; + TALLOC_CTX *mem_ctx = NULL; + struct libnet_context *ctx; + struct lsa_String domain_name; + struct libnet_UserList req; + + binding = torture_setting_string(torture, "binding", NULL); + + ctx = libnet_context_init(NULL); + ctx->cred = cmdline_credentials; + + domain_name.string = lp_workgroup(); + mem_ctx = talloc_init("torture user list"); + + ZERO_STRUCT(req); + + req.in.domain_name = domain_name.string; + req.in.page_size = 30; + req.in.restore_index = 0; + + status = libnet_UserList(ctx, mem_ctx, &req); + if (!NT_STATUS_IS_OK(status)) { + printf("libnet_UserList call failed: %s\n", nt_errstr(status)); + ret = False; + talloc_free(mem_ctx); + goto done; + } + + if (!test_lsa_close(ctx->lsa.pipe, mem_ctx, &ctx->lsa.handle)) { printf("domain close failed\n"); ret = False; } |