2 Unix SMB/CIFS implementation.
3 Test suite for libnet calls.
5 Copyright (C) Rafal Szczesniak 2005
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "torture/rpc/rpc.h"
23 #include "lib/events/events.h"
24 #include "libnet/libnet.h"
25 #include "librpc/gen_ndr/ndr_samr_c.h"
27 static BOOL test_domainopen(struct libnet_context *net_ctx, TALLOC_CTX *mem_ctx,
28 struct lsa_String *domname,
29 struct policy_handle *domain_handle)
32 struct libnet_DomainOpen io;
34 printf("opening domain\n");
36 io.in.domain_name = talloc_strdup(mem_ctx, domname->string);
37 io.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
39 status = libnet_DomainOpen(net_ctx, mem_ctx, &io);
40 if (!NT_STATUS_IS_OK(status)) {
41 printf("Composite domain open failed - %s\n", nt_errstr(status));
45 *domain_handle = io.out.domain_handle;
50 static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
51 struct policy_handle *domain_handle)
55 struct policy_handle handle;
57 r.in.handle = domain_handle;
58 r.out.handle = &handle;
60 printf("closing domain handle\n");
62 status = dcerpc_samr_Close(p, mem_ctx, &r);
63 if (!NT_STATUS_IS_OK(status)) {
64 printf("Close failed - %s\n", nt_errstr(status));
72 BOOL torture_domainopen(struct torture_context *torture)
76 struct libnet_context *net_ctx;
77 struct event_context *evt_ctx;
80 struct policy_handle h;
81 struct lsa_String name;
83 mem_ctx = talloc_init("test_domain_open");
84 binding = torture_setting_string(torture, "binding", NULL);
86 evt_ctx = event_context_find(torture);
87 net_ctx = libnet_context_init(evt_ctx);
89 status = torture_rpc_connection(mem_ctx,
93 if (!NT_STATUS_IS_OK(status)) {
97 name.string = lp_workgroup();
100 * Testing synchronous version
102 if (!test_domainopen(net_ctx, mem_ctx, &name, &h)) {
107 if (!test_cleanup(net_ctx->samr.pipe, mem_ctx, &h)) {
113 talloc_free(mem_ctx);