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 "librpc/gen_ndr/ndr_lsa.h"
25 #include "librpc/gen_ndr/ndr_dssetup.h"
28 BOOL torture_rpc_alter_context(void)
31 struct dcerpc_pipe *p, *p2;
34 struct policy_handle *handle;
35 struct dcerpc_interface_table tmptbl;
36 struct dcerpc_syntax_id syntax;
37 struct dcerpc_syntax_id transfer_syntax;
39 mem_ctx = talloc_init("torture_rpc_alter_context");
41 printf("opening LSA connection\n");
42 status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_lsarpc);
43 if (!NT_STATUS_IS_OK(status)) {
48 if (!test_lsa_OpenPolicy2(p, mem_ctx, &handle)) {
52 printf("Opening secondary DSSETUP context\n");
53 status = dcerpc_secondary_context(p, &p2, &dcerpc_table_dssetup);
54 if (!NT_STATUS_IS_OK(status)) {
56 printf("dcerpc_alter_context failed - %s\n", nt_errstr(status));
60 tmptbl = dcerpc_table_dssetup;
61 tmptbl.if_version += 100;
62 printf("Opening bad secondary connection\n");
63 status = dcerpc_secondary_context(p, &p2, &tmptbl);
64 if (NT_STATUS_IS_OK(status)) {
66 printf("dcerpc_alter_context with wrong version should fail\n");
70 printf("testing DSSETUP pipe operations\n");
71 ret &= test_DsRoleGetPrimaryDomainInformation(p2, mem_ctx);
74 if (!test_lsa_Close(p, mem_ctx, handle)) {
80 transfer_syntax = p->transfer_syntax;
82 printf("Testing change of primary context\n");
83 status = dcerpc_alter_context(p, mem_ctx, &p2->syntax, &p2->transfer_syntax);
84 if (!NT_STATUS_IS_OK(status)) {
86 printf("dcerpc_alter_context failed - %s\n", nt_errstr(status));
90 printf("testing DSSETUP pipe operations - should fault\n");
91 if (test_DsRoleGetPrimaryDomainInformation(p, mem_ctx)) {
95 if (!test_lsa_OpenPolicy2(p, mem_ctx, &handle)) {
100 if (!test_lsa_Close(p, mem_ctx, handle)) {
105 printf("testing DSSETUP pipe operations\n");
106 ret &= test_DsRoleGetPrimaryDomainInformation(p2, mem_ctx);
108 talloc_free(mem_ctx);