2 Unix SMB/CIFS implementation.
4 test suite for dcerpc alter_context operations
6 Copyright (C) Andrew Tridgell 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "torture/torture.h"
25 #include "librpc/gen_ndr/ndr_lsa.h"
26 #include "librpc/gen_ndr/ndr_dssetup.h"
27 #include "torture/rpc/rpc.h"
29 BOOL torture_rpc_alter_context(void)
32 struct dcerpc_pipe *p, *p2;
35 struct policy_handle *handle;
36 struct dcerpc_interface_table tmptbl;
37 struct dcerpc_syntax_id syntax;
38 struct dcerpc_syntax_id transfer_syntax;
40 mem_ctx = talloc_init("torture_rpc_alter_context");
42 printf("opening LSA connection\n");
43 status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_lsarpc);
44 if (!NT_STATUS_IS_OK(status)) {
49 if (!test_lsa_OpenPolicy2(p, mem_ctx, &handle)) {
53 printf("Opening secondary DSSETUP context\n");
54 status = dcerpc_secondary_context(p, &p2, &dcerpc_table_dssetup);
55 if (!NT_STATUS_IS_OK(status)) {
57 printf("dcerpc_alter_context failed - %s\n", nt_errstr(status));
61 tmptbl = dcerpc_table_dssetup;
62 tmptbl.if_version += 100;
63 printf("Opening bad secondary connection\n");
64 status = dcerpc_secondary_context(p, &p2, &tmptbl);
65 if (NT_STATUS_IS_OK(status)) {
67 printf("dcerpc_alter_context with wrong version should fail\n");
71 printf("testing DSSETUP pipe operations\n");
72 ret &= test_DsRoleGetPrimaryDomainInformation(p2, mem_ctx);
75 if (!test_lsa_Close(p, mem_ctx, handle)) {
81 transfer_syntax = p->transfer_syntax;
83 printf("Testing change of primary context\n");
84 status = dcerpc_alter_context(p, mem_ctx, &p2->syntax, &p2->transfer_syntax);
85 if (!NT_STATUS_IS_OK(status)) {
87 printf("dcerpc_alter_context failed - %s\n", nt_errstr(status));
91 printf("testing DSSETUP pipe operations - should fault\n");
92 if (test_DsRoleGetPrimaryDomainInformation(p, mem_ctx)) {
96 if (!test_lsa_OpenPolicy2(p, mem_ctx, &handle)) {
101 if (!test_lsa_Close(p, mem_ctx, handle)) {
106 printf("testing DSSETUP pipe operations\n");
107 ret &= test_DsRoleGetPrimaryDomainInformation(p2, mem_ctx);
109 talloc_free(mem_ctx);