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 2 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, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "librpc/gen_ndr/ndr_samr.h"
26 static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
27 struct policy_handle *handle, struct samr_String *domname)
30 struct policy_handle h, domain_handle;
31 struct samr_Connect r1;
32 struct samr_LookupDomain r2;
33 struct samr_OpenDomain r3;
35 printf("connecting\n");
37 r1.in.system_name = 0;
38 r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
39 r1.out.connect_handle = &h;
41 status = dcerpc_samr_Connect(p, mem_ctx, &r1);
42 if (!NT_STATUS_IS_OK(status)) {
43 printf("Connect failed - %s\n", nt_errstr(status));
47 r2.in.connect_handle = &h;
48 r2.in.domain_name = domname;
50 printf("domain lookup\n");
52 status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2);
53 if (!NT_STATUS_IS_OK(status)) {
54 printf("LookupDomain failed - %s\n", nt_errstr(status));
58 r3.in.connect_handle = &h;
59 r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
60 r3.in.sid = r2.out.sid;
61 r3.out.domain_handle = &domain_handle;
63 printf("opening domain\n");
65 status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3);
66 if (!NT_STATUS_IS_OK(status)) {
67 printf("OpenDomain failed - %s\n", nt_errstr(status));
70 *handle = domain_handle;
77 BOOL torture_userinfo(void)
81 struct dcerpc_pipe *p;
82 struct dcerpc_binding b;
85 struct policy_handle h;
86 struct samr_String name;
88 mem_ctx = talloc_init("test_userinfo");
89 binding = lp_parm_string(-1, "torture", "binding");
91 status = torture_rpc_connection(&p,
96 if (!NT_STATUS_IS_OK(status)) {
100 status = dcerpc_parse_binding(mem_ctx, binding, &b);
101 if (!NT_STATUS_IS_OK(status)) {
102 printf("failed to parse dcerpc binding '%s'\n", binding);
103 talloc_free(mem_ctx);
107 name.string = b.host;
109 if (!test_opendomain(p, mem_ctx, &h, &name)) {
114 talloc_free(mem_ctx);
115 torture_rpc_close(p);