diff options
author | Rafal Szczesniak <mimir@samba.org> | 2005-05-10 18:17:40 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:16:37 -0500 |
commit | 84f248ec8401bc5279047de4e16231cf191348ef (patch) | |
tree | fb90eb614b760fcf95ab215d33fc25c70844019e /source4/torture/libnet/userman.c | |
parent | b5da6b2c853b2aca572435ef989148adbf2f3ff0 (diff) | |
download | samba-84f248ec8401bc5279047de4e16231cf191348ef.tar.gz samba-84f248ec8401bc5279047de4e16231cf191348ef.tar.xz samba-84f248ec8401bc5279047de4e16231cf191348ef.zip |
r6717: - torture test of async useradd function and monitor messages.
- make message handling functions static.
rafal
(This used to be commit 96446e5e1e53eb519cbfeb64d0dd2f4052d75b0f)
Diffstat (limited to 'source4/torture/libnet/userman.c')
-rw-r--r-- | source4/torture/libnet/userman.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/source4/torture/libnet/userman.c b/source4/torture/libnet/userman.c index 6add4223202..6a0a41434a8 100644 --- a/source4/torture/libnet/userman.c +++ b/source4/torture/libnet/userman.c @@ -22,6 +22,7 @@ #include "includes.h" #include "librpc/gen_ndr/ndr_samr.h" #include "libnet/composite.h" +#include "libcli/composite/monitor.h" #define TEST_USERNAME "libnetusermantest" @@ -88,6 +89,8 @@ static BOOL test_useradd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, user.in.domain_handle = *domain_handle; user.in.username = name; + printf("Testing rpc_composite_useradd\n"); + status = rpc_composite_useradd(p, mem_ctx, &user); if (!NT_STATUS_IS_OK(status)) { printf("Failed to call sync rpc_composite_userinfo - %s\n", nt_errstr(status)); @@ -98,6 +101,46 @@ static BOOL test_useradd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } +static void msg_handler(struct monitor_msg *m) +{ + switch (m->type) { + case rpc_create_user: + printf("monitor_msg: user created (rid=%d)\n", m->data.rpc_create_user.rid); + break; + } +} + + +static BOOL test_useradd_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, const char* username) +{ + NTSTATUS status; + BOOL ret = True; + struct composite_context *c; + struct rpc_composite_useradd user; + + user.in.domain_handle = *handle; + user.in.username = username; + + printf("Testing async rpc_composite_useradd\n"); + + c = rpc_composite_useradd_send(p, &user, msg_handler); + if (!c) { + printf("Failed to call async rpc_composite_useradd\n"); + return False; + } + + status = rpc_composite_useradd_recv(c, mem_ctx, &user); + if (!NT_STATUS_IS_OK(status)) { + printf("Calling async rpc_composite_useradd failed - %s\n", nt_errstr(status)); + return False; + } + + return True; + +} + + static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, const char *username) { @@ -269,6 +312,21 @@ BOOL torture_useradd(void) goto done; } + if (!test_opendomain(p, mem_ctx, &h, &domain_name)) { + ret = False; + goto done; + } + + if (!test_useradd_async(p, mem_ctx, &h, name)) { + ret = False; + goto done; + } + + if (!test_cleanup(p, mem_ctx, &h, name)) { + ret = False; + goto done; + } + done: talloc_free(mem_ctx); return ret; |