2 Unix SMB/CIFS implementation.
4 test suite for schannel operations
6 Copyright (C) Andrew Tridgell 2004
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.
25 #define TEST_MACHINE_NAME "schanneltest"
28 do some samr ops using the schannel connection
30 static BOOL
test_samr_ops(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
)
33 struct samr_GetDomPwInfo r
;
35 struct samr_Name name
;
37 name
.name
= lp_workgroup();
40 printf("Testing GetDomPwInfo with name %s\n", r
.in
.name
->name
);
42 /* do several ops to test credential chaining */
44 status
= dcerpc_samr_GetDomPwInfo(p
, mem_ctx
, &r
);
45 if (!NT_STATUS_IS_OK(status
)) {
46 printf("GetDomPwInfo op %d failed - %s\n", i
, nt_errstr(status
));
55 test a schannel connection with the given flags
57 static BOOL
test_schannel(TALLOC_CTX
*mem_ctx
,
58 uint16 acct_flags
, uint32 dcerpc_flags
,
62 const char *machine_password
;
64 const char *binding
= lp_parm_string(-1, "torture", "binding");
65 struct dcerpc_binding b
;
66 struct dcerpc_pipe
*p
;
68 join_ctx
= torture_join_domain(TEST_MACHINE_NAME
, lp_workgroup(), acct_flags
,
71 printf("Failed to join domain with acct_flags=0x%x\n", acct_flags
);
75 status
= dcerpc_parse_binding(mem_ctx
, binding
, &b
);
76 if (!NT_STATUS_IS_OK(status
)) {
77 printf("Bad binding string %s\n", binding
);
81 b
.flags
&= ~DCERPC_AUTH_OPTIONS
;
82 b
.flags
|= dcerpc_flags
;
84 status
= dcerpc_pipe_connect_b(&p
, &b
,
90 if (!NT_STATUS_IS_OK(status
)) {
91 printf("Failed to connect with schannel\n");
95 if (!test_samr_ops(p
, mem_ctx
)) {
96 printf("Failed to process schannel secured ops\n");
100 torture_leave_domain(join_ctx
);
104 torture_leave_domain(join_ctx
);
109 a schannel test suite
111 BOOL
torture_rpc_schannel(int dummy
)
118 uint32 schannel_type
;
120 { ACB_WSTRUST
, DCERPC_SCHANNEL_WORKSTATION
| DCERPC_SIGN
, 3 },
121 { ACB_WSTRUST
, DCERPC_SCHANNEL_WORKSTATION
| DCERPC_SEAL
, 3 },
122 { ACB_WSTRUST
, DCERPC_SCHANNEL_WORKSTATION
| DCERPC_SIGN
| DCERPC_SCHANNEL_128
, 3 },
123 { ACB_WSTRUST
, DCERPC_SCHANNEL_WORKSTATION
| DCERPC_SEAL
| DCERPC_SCHANNEL_128
, 3 },
124 { ACB_SVRTRUST
, DCERPC_SCHANNEL_BDC
| DCERPC_SIGN
, 3 },
125 { ACB_SVRTRUST
, DCERPC_SCHANNEL_BDC
| DCERPC_SEAL
, 3 },
126 { ACB_SVRTRUST
, DCERPC_SCHANNEL_BDC
| DCERPC_SIGN
| DCERPC_SCHANNEL_128
, 3 },
127 { ACB_SVRTRUST
, DCERPC_SCHANNEL_BDC
| DCERPC_SEAL
| DCERPC_SCHANNEL_128
, 3 }
131 mem_ctx
= talloc_init("torture_rpc_schannel");
133 for (i
=0;i
<ARRAY_SIZE(tests
);i
++) {
134 if (!test_schannel(mem_ctx
,
135 tests
[i
].acct_flags
, tests
[i
].dcerpc_flags
, tests
[i
].schannel_type
)) {
136 printf("Failed with acct_flags=0x%x dcerpc_flags=0x%x schannel_type=%d\n",
137 tests
[i
].acct_flags
, tests
[i
].dcerpc_flags
, tests
[i
].schannel_type
);