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 3 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, see <http://www.gnu.org/licenses/>.
23 #include "librpc/gen_ndr/ndr_netlogon_c.h"
24 #include "librpc/gen_ndr/ndr_lsa_c.h"
25 #include "librpc/gen_ndr/ndr_samr_c.h"
26 #include "auth/credentials/credentials.h"
27 #include "torture/rpc/rpc.h"
28 #include "lib/cmdline/popt_common.h"
29 #include "auth/gensec/schannel_proto.h"
30 #include "libcli/auth/libcli_auth.h"
31 #include "libcli/security/security.h"
32 #include "system/filesys.h"
33 #include "param/param.h"
34 #include "librpc/rpc/dcerpc_proto.h"
35 #include "auth/gensec/gensec.h"
36 #include "libcli/composite/composite.h"
37 #include "lib/events/events.h"
39 #define TEST_MACHINE_NAME "schannel"
42 try a netlogon SamLogon
44 bool test_netlogon_ex_ops(struct dcerpc_pipe *p, struct torture_context *tctx,
45 struct cli_credentials *credentials,
46 struct creds_CredentialState *creds)
49 struct netr_LogonSamLogonEx r;
50 struct netr_NetworkInfo ninfo;
51 DATA_BLOB names_blob, chal, lm_resp, nt_resp;
53 int flags = CLI_CRED_NTLM_AUTH;
54 if (lp_client_lanman_auth(tctx->lp_ctx)) {
55 flags |= CLI_CRED_LANMAN_AUTH;
58 if (lp_client_ntlmv2_auth(tctx->lp_ctx)) {
59 flags |= CLI_CRED_NTLMv2_AUTH;
62 cli_credentials_get_ntlm_username_domain(cmdline_credentials, tctx,
63 &ninfo.identity_info.account_name.string,
64 &ninfo.identity_info.domain_name.string);
66 generate_random_buffer(ninfo.challenge,
67 sizeof(ninfo.challenge));
68 chal = data_blob_const(ninfo.challenge,
69 sizeof(ninfo.challenge));
71 names_blob = NTLMv2_generate_names_blob(tctx, lp_iconv_convenience(tctx->lp_ctx), cli_credentials_get_workstation(credentials),
72 cli_credentials_get_domain(credentials));
74 status = cli_credentials_get_ntlm_response(cmdline_credentials, tctx,
80 torture_assert_ntstatus_ok(tctx, status,
81 "cli_credentials_get_ntlm_response failed");
83 ninfo.lm.data = lm_resp.data;
84 ninfo.lm.length = lm_resp.length;
86 ninfo.nt.data = nt_resp.data;
87 ninfo.nt.length = nt_resp.length;
89 ninfo.identity_info.parameter_control = 0;
90 ninfo.identity_info.logon_id_low = 0;
91 ninfo.identity_info.logon_id_high = 0;
92 ninfo.identity_info.workstation.string = cli_credentials_get_workstation(credentials);
94 r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
95 r.in.computer_name = cli_credentials_get_workstation(credentials);
97 r.in.logon.network = &ninfo;
100 torture_comment(tctx,
101 "Testing LogonSamLogonEx with name %s\n",
102 ninfo.identity_info.account_name.string);
105 r.in.validation_level = i;
107 status = dcerpc_netr_LogonSamLogonEx(p, tctx, &r);
108 torture_assert_ntstatus_ok(tctx, status, "LogonSamLogon failed");
115 do some samr ops using the schannel connection
117 static bool test_samr_ops(struct torture_context *tctx,
118 struct dcerpc_pipe *p)
121 struct samr_GetDomPwInfo r;
122 struct samr_Connect connect;
123 struct samr_OpenDomain opendom;
125 struct lsa_String name;
126 struct policy_handle handle;
127 struct policy_handle domain_handle;
129 name.string = lp_workgroup(tctx->lp_ctx);
130 r.in.domain_name = &name;
132 connect.in.system_name = 0;
133 connect.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
134 connect.out.connect_handle = &handle;
136 printf("Testing Connect and OpenDomain on BUILTIN\n");
138 status = dcerpc_samr_Connect(p, tctx, &connect);
139 if (!NT_STATUS_IS_OK(status)) {
140 if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
141 printf("Connect failed (expected, schannel mapped to anonymous): %s\n",
144 printf("Connect failed - %s\n", nt_errstr(status));
148 opendom.in.connect_handle = &handle;
149 opendom.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
150 opendom.in.sid = dom_sid_parse_talloc(tctx, "S-1-5-32");
151 opendom.out.domain_handle = &domain_handle;
153 status = dcerpc_samr_OpenDomain(p, tctx, &opendom);
154 if (!NT_STATUS_IS_OK(status)) {
155 printf("OpenDomain failed - %s\n", nt_errstr(status));
160 printf("Testing GetDomPwInfo with name %s\n", r.in.domain_name->string);
162 /* do several ops to test credential chaining */
164 status = dcerpc_samr_GetDomPwInfo(p, tctx, &r);
165 if (!NT_STATUS_IS_OK(status)) {
166 if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
167 printf("GetDomPwInfo op %d failed - %s\n", i, nt_errstr(status));
178 do some lsa ops using the schannel connection
180 static bool test_lsa_ops(struct torture_context *tctx, struct dcerpc_pipe *p)
182 struct lsa_GetUserName r;
185 struct lsa_StringPointer authority_name_p;
187 printf("\nTesting GetUserName\n");
189 r.in.system_name = "\\";
190 r.in.account_name = NULL;
191 r.in.authority_name = &authority_name_p;
192 authority_name_p.string = NULL;
194 /* do several ops to test credential chaining and various operations */
195 status = dcerpc_lsa_GetUserName(p, tctx, &r);
197 if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) {
198 printf("not considering %s to be an error\n", nt_errstr(status));
199 } else if (!NT_STATUS_IS_OK(status)) {
200 printf("GetUserName failed - %s\n", nt_errstr(status));
203 if (!r.out.account_name) {
207 if (strcmp(r.out.account_name->string, "ANONYMOUS LOGON") != 0) {
208 printf("GetUserName returned wrong user: %s, expected %s\n",
209 r.out.account_name->string, "ANONYMOUS LOGON");
212 if (!r.out.authority_name || !r.out.authority_name->string) {
216 if (strcmp(r.out.authority_name->string->string, "NT AUTHORITY") != 0) {
217 printf("GetUserName returned wrong user: %s, expected %s\n",
218 r.out.authority_name->string->string, "NT AUTHORITY");
222 if (!test_many_LookupSids(p, tctx, NULL)) {
223 printf("LsaLookupSids3 failed!\n");
232 test a schannel connection with the given flags
234 static bool test_schannel(struct torture_context *tctx,
235 uint16_t acct_flags, uint32_t dcerpc_flags,
238 struct test_join *join_ctx;
240 const char *binding = torture_setting_string(tctx, "binding", NULL);
241 struct dcerpc_binding *b;
242 struct dcerpc_pipe *p = NULL;
243 struct dcerpc_pipe *p_netlogon = NULL;
244 struct dcerpc_pipe *p_netlogon2 = NULL;
245 struct dcerpc_pipe *p_netlogon3 = NULL;
246 struct dcerpc_pipe *p_samr2 = NULL;
247 struct dcerpc_pipe *p_lsa = NULL;
248 struct creds_CredentialState *creds;
249 struct cli_credentials *credentials;
251 join_ctx = torture_join_domain(tctx,
252 talloc_asprintf(tctx, "%s%d", TEST_MACHINE_NAME, i),
253 acct_flags, &credentials);
254 torture_assert(tctx, join_ctx != NULL, "Failed to join domain");
256 status = dcerpc_parse_binding(tctx, binding, &b);
257 torture_assert_ntstatus_ok(tctx, status, "Bad binding string");
259 b->flags &= ~DCERPC_AUTH_OPTIONS;
260 b->flags |= dcerpc_flags;
262 status = dcerpc_pipe_connect_b(tctx, &p, b, &ndr_table_samr,
263 credentials, tctx->ev, tctx->lp_ctx);
264 torture_assert_ntstatus_ok(tctx, status,
265 "Failed to connect with schannel");
267 torture_assert(tctx, test_samr_ops(tctx, p),
268 "Failed to process schannel secured SAMR ops");
270 /* Also test that when we connect to the netlogon pipe, that
271 * the credentials we setup on the first pipe are valid for
274 /* Swap the binding details from SAMR to NETLOGON */
275 status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, tctx->ev, tctx->lp_ctx);
276 torture_assert_ntstatus_ok(tctx, status, "epm map");
278 status = dcerpc_secondary_connection(p, &p_netlogon,
280 torture_assert_ntstatus_ok(tctx, status, "seconday connection");
282 status = dcerpc_bind_auth(p_netlogon, &ndr_table_netlogon,
283 credentials, tctx->lp_ctx,
284 DCERPC_AUTH_TYPE_SCHANNEL,
285 dcerpc_auth_level(p->conn),
288 torture_assert_ntstatus_ok(tctx, status, "bind auth");
290 status = dcerpc_schannel_creds(p_netlogon->conn->security_state.generic_state, tctx, &creds);
291 torture_assert_ntstatus_ok(tctx, status, "schannel creds");
293 /* do a couple of logins */
294 torture_assert(tctx, test_netlogon_ops(p_netlogon, tctx, credentials, creds),
295 "Failed to process schannel secured NETLOGON ops");
297 torture_assert(tctx, test_netlogon_ex_ops(p_netlogon, tctx, credentials, creds),
298 "Failed to process schannel secured NETLOGON EX ops");
300 /* Swap the binding details from SAMR to LSARPC */
301 status = dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, tctx->ev, tctx->lp_ctx);
302 torture_assert_ntstatus_ok(tctx, status, "epm map");
304 status = dcerpc_secondary_connection(p, &p_lsa,
307 torture_assert_ntstatus_ok(tctx, status, "seconday connection");
309 status = dcerpc_bind_auth(p_lsa, &ndr_table_lsarpc,
310 credentials, tctx->lp_ctx,
311 DCERPC_AUTH_TYPE_SCHANNEL,
312 dcerpc_auth_level(p->conn),
315 torture_assert_ntstatus_ok(tctx, status, "bind auth");
317 torture_assert(tctx, test_lsa_ops(tctx, p_lsa),
318 "Failed to process schannel secured LSA ops");
320 /* Drop the socket, we want to start from scratch */
324 /* Now see what we are still allowed to do */
326 status = dcerpc_parse_binding(tctx, binding, &b);
327 torture_assert_ntstatus_ok(tctx, status, "Bad binding string");
329 b->flags &= ~DCERPC_AUTH_OPTIONS;
330 b->flags |= dcerpc_flags;
332 status = dcerpc_pipe_connect_b(tctx, &p_samr2, b, &ndr_table_samr,
333 credentials, tctx->ev, tctx->lp_ctx);
334 torture_assert_ntstatus_ok(tctx, status,
335 "Failed to connect with schannel");
337 /* do a some SAMR operations. We have *not* done a new serverauthenticate */
338 torture_assert (tctx, test_samr_ops(tctx, p_samr2),
339 "Failed to process schannel secured SAMR ops (on fresh connection)");
341 /* Swap the binding details from SAMR to NETLOGON */
342 status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, tctx->ev, tctx->lp_ctx);
343 torture_assert_ntstatus_ok(tctx, status, "epm");
345 status = dcerpc_secondary_connection(p_samr2, &p_netlogon2,
347 torture_assert_ntstatus_ok(tctx, status, "seconday connection");
349 /* and now setup an SCHANNEL bind on netlogon */
350 status = dcerpc_bind_auth(p_netlogon2, &ndr_table_netlogon,
351 credentials, tctx->lp_ctx,
352 DCERPC_AUTH_TYPE_SCHANNEL,
353 dcerpc_auth_level(p_samr2->conn),
356 torture_assert_ntstatus_ok(tctx, status, "auth failed");
358 /* Try the schannel-only SamLogonEx operation */
359 torture_assert(tctx, test_netlogon_ex_ops(p_netlogon2, tctx, credentials, creds),
360 "Failed to process schannel secured NETLOGON EX ops (on fresh connection)");
363 /* And the more traditional style, proving that the
364 * credentials chaining state is fully present */
365 torture_assert(tctx, test_netlogon_ops(p_netlogon2, tctx, credentials, creds),
366 "Failed to process schannel secured NETLOGON ops (on fresh connection)");
368 /* Drop the socket, we want to start from scratch (again) */
369 talloc_free(p_samr2);
371 /* We don't want schannel for this test */
372 b->flags &= ~DCERPC_AUTH_OPTIONS;
374 status = dcerpc_pipe_connect_b(tctx, &p_netlogon3, b, &ndr_table_netlogon,
375 credentials, tctx->ev, tctx->lp_ctx);
376 torture_assert_ntstatus_ok(tctx, status, "Failed to connect without schannel");
378 torture_assert(tctx, !test_netlogon_ex_ops(p_netlogon3, tctx, credentials, creds),
379 "Processed NOT schannel secured NETLOGON EX ops without SCHANNEL (unsafe)");
381 /* Required because the previous call will mark the current context as having failed */
382 tctx->last_result = TORTURE_OK;
383 tctx->last_reason = NULL;
385 torture_assert(tctx, test_netlogon_ops(p_netlogon3, tctx, credentials, creds),
386 "Failed to processed NOT schannel secured NETLOGON ops without new ServerAuth");
388 torture_leave_domain(join_ctx);
395 a schannel test suite
397 bool torture_rpc_schannel(struct torture_context *torture)
402 uint32_t dcerpc_flags;
404 { ACB_WSTRUST, DCERPC_SCHANNEL | DCERPC_SIGN},
405 { ACB_WSTRUST, DCERPC_SCHANNEL | DCERPC_SEAL},
406 { ACB_WSTRUST, DCERPC_SCHANNEL | DCERPC_SIGN | DCERPC_SCHANNEL_128},
407 { ACB_WSTRUST, DCERPC_SCHANNEL | DCERPC_SEAL | DCERPC_SCHANNEL_128 },
408 { ACB_SVRTRUST, DCERPC_SCHANNEL | DCERPC_SIGN },
409 { ACB_SVRTRUST, DCERPC_SCHANNEL | DCERPC_SEAL },
410 { ACB_SVRTRUST, DCERPC_SCHANNEL | DCERPC_SIGN | DCERPC_SCHANNEL_128 },
411 { ACB_SVRTRUST, DCERPC_SCHANNEL | DCERPC_SEAL | DCERPC_SCHANNEL_128 }
415 for (i=0;i<ARRAY_SIZE(tests);i++) {
416 if (!test_schannel(torture,
417 tests[i].acct_flags, tests[i].dcerpc_flags,
419 torture_comment(torture, "Failed with acct_flags=0x%x dcerpc_flags=0x%x \n",
420 tests[i].acct_flags, tests[i].dcerpc_flags);
429 test two schannel connections
431 bool torture_rpc_schannel2(struct torture_context *torture)
433 struct test_join *join_ctx;
435 const char *binding = torture_setting_string(torture, "binding", NULL);
436 struct dcerpc_binding *b;
437 struct dcerpc_pipe *p1 = NULL, *p2 = NULL;
438 struct cli_credentials *credentials1, *credentials2;
439 uint32_t dcerpc_flags = DCERPC_SCHANNEL | DCERPC_SIGN;
441 join_ctx = torture_join_domain(torture, talloc_asprintf(torture, "%s2", TEST_MACHINE_NAME),
442 ACB_WSTRUST, &credentials1);
443 torture_assert(torture, join_ctx != NULL,
444 "Failed to join domain with acct_flags=ACB_WSTRUST");
446 credentials2 = (struct cli_credentials *)talloc_memdup(torture, credentials1, sizeof(*credentials1));
447 credentials1->netlogon_creds = NULL;
448 credentials2->netlogon_creds = NULL;
450 status = dcerpc_parse_binding(torture, binding, &b);
451 torture_assert_ntstatus_ok(torture, status, "Bad binding string");
453 b->flags &= ~DCERPC_AUTH_OPTIONS;
454 b->flags |= dcerpc_flags;
456 printf("Opening first connection\n");
457 status = dcerpc_pipe_connect_b(torture, &p1, b, &ndr_table_netlogon,
458 credentials1, torture->ev, torture->lp_ctx);
459 torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
461 torture_comment(torture, "Opening second connection\n");
462 status = dcerpc_pipe_connect_b(torture, &p2, b, &ndr_table_netlogon,
463 credentials2, torture->ev, torture->lp_ctx);
464 torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel");
466 credentials1->netlogon_creds = NULL;
467 credentials2->netlogon_creds = NULL;
469 torture_comment(torture, "Testing logon on pipe1\n");
470 if (!test_netlogon_ex_ops(p1, torture, credentials1, NULL))
473 torture_comment(torture, "Testing logon on pipe2\n");
474 if (!test_netlogon_ex_ops(p2, torture, credentials2, NULL))
477 torture_comment(torture, "Again on pipe1\n");
478 if (!test_netlogon_ex_ops(p1, torture, credentials1, NULL))
481 torture_comment(torture, "Again on pipe2\n");
482 if (!test_netlogon_ex_ops(p2, torture, credentials2, NULL))
485 torture_leave_domain(join_ctx);
489 struct torture_schannel_bench;
491 struct torture_schannel_bench_conn {
492 struct torture_schannel_bench *s;
494 struct cli_credentials *wks_creds;
495 struct dcerpc_pipe *pipe;
496 struct netr_LogonSamLogonEx r;
497 struct netr_NetworkInfo ninfo;
503 struct torture_schannel_bench {
504 struct torture_context *tctx;
509 struct torture_schannel_bench_conn *conns;
510 struct test_join *join_ctx;
511 struct cli_credentials *wks_creds;
512 struct cli_credentials *user1_creds;
513 struct cli_credentials *user2_creds;
514 struct dcerpc_binding *b;
521 static void torture_schannel_bench_connected(struct composite_context *c)
523 struct torture_schannel_bench_conn *conn = c->async.private_data;
524 struct torture_schannel_bench *s = talloc_get_type(conn->s,
525 struct torture_schannel_bench);
527 s->error = dcerpc_pipe_connect_b_recv(c, s->conns, &conn->pipe);
528 torture_comment(s->tctx, "conn[%u]: %s\n", conn->index, nt_errstr(s->error));
529 if (NT_STATUS_IS_OK(s->error)) {
534 static void torture_schannel_bench_recv(struct rpc_request *req);
536 static bool torture_schannel_bench_start(struct torture_schannel_bench_conn *conn)
538 struct torture_schannel_bench *s = conn->s;
540 DATA_BLOB names_blob, chal, lm_resp, nt_resp;
541 int flags = CLI_CRED_NTLM_AUTH;
542 struct rpc_request *req;
543 struct cli_credentials *user_creds;
545 if (conn->total % 2) {
546 user_creds = s->user1_creds;
548 user_creds = s->user2_creds;
551 if (lp_client_lanman_auth(s->tctx->lp_ctx)) {
552 flags |= CLI_CRED_LANMAN_AUTH;
555 if (lp_client_ntlmv2_auth(s->tctx->lp_ctx)) {
556 flags |= CLI_CRED_NTLMv2_AUTH;
559 talloc_free(conn->tmp);
560 conn->tmp = talloc_new(s);
561 ZERO_STRUCT(conn->ninfo);
562 ZERO_STRUCT(conn->r);
564 cli_credentials_get_ntlm_username_domain(user_creds, conn->tmp,
565 &conn->ninfo.identity_info.account_name.string,
566 &conn->ninfo.identity_info.domain_name.string);
568 generate_random_buffer(conn->ninfo.challenge,
569 sizeof(conn->ninfo.challenge));
570 chal = data_blob_const(conn->ninfo.challenge,
571 sizeof(conn->ninfo.challenge));
573 names_blob = NTLMv2_generate_names_blob(conn->tmp, lp_iconv_convenience(s->tctx->lp_ctx),
574 cli_credentials_get_workstation(conn->wks_creds),
575 cli_credentials_get_domain(conn->wks_creds));
577 status = cli_credentials_get_ntlm_response(user_creds, conn->tmp,
583 torture_assert_ntstatus_ok(s->tctx, status,
584 "cli_credentials_get_ntlm_response failed");
586 conn->ninfo.lm.data = lm_resp.data;
587 conn->ninfo.lm.length = lm_resp.length;
589 conn->ninfo.nt.data = nt_resp.data;
590 conn->ninfo.nt.length = nt_resp.length;
592 conn->ninfo.identity_info.parameter_control = 0;
593 conn->ninfo.identity_info.logon_id_low = 0;
594 conn->ninfo.identity_info.logon_id_high = 0;
595 conn->ninfo.identity_info.workstation.string = cli_credentials_get_workstation(conn->wks_creds);
597 conn->r.in.server_name = talloc_asprintf(conn->tmp, "\\\\%s", dcerpc_server_name(conn->pipe));
598 conn->r.in.computer_name = cli_credentials_get_workstation(conn->wks_creds);
599 conn->r.in.logon_level = 2;
600 conn->r.in.logon.network = &conn->ninfo;
601 conn->r.in.flags = 0;
602 conn->r.in.validation_level = 2;
604 req = dcerpc_netr_LogonSamLogonEx_send(conn->pipe, conn->tmp, &conn->r);
605 torture_assert(s->tctx, req, "Failed to setup LogonSamLogonEx request");
607 req->async.callback = torture_schannel_bench_recv;
608 req->async.private_data = conn;
613 static void torture_schannel_bench_recv(struct rpc_request *req)
616 struct torture_schannel_bench_conn *conn = req->async.private_data;
617 struct torture_schannel_bench *s = talloc_get_type(conn->s,
618 struct torture_schannel_bench);
620 s->error = dcerpc_ndr_request_recv(req);
621 if (!NT_STATUS_IS_OK(s->error)) {
632 ret = torture_schannel_bench_start(conn);
634 s->error = NT_STATUS_INTERNAL_ERROR;
639 test multiple schannel connection in parallel
641 bool torture_rpc_schannel_bench1(struct torture_context *torture)
645 const char *binding = torture_setting_string(torture, "binding", NULL);
646 struct torture_schannel_bench *s;
647 struct timeval start;
652 s = talloc_zero(torture, struct torture_schannel_bench);
654 s->progress = torture_setting_bool(torture, "progress", true);
655 s->timelimit = torture_setting_int(torture, "timelimit", 10);
656 s->nprocs = torture_setting_int(torture, "nprocs", 4);
657 s->conns = talloc_zero_array(s, struct torture_schannel_bench_conn, s->nprocs);
659 s->user1_creds = (struct cli_credentials *)talloc_memdup(s,
661 sizeof(*s->user1_creds));
662 tmp = torture_setting_string(s->tctx, "extra_user1", NULL);
664 cli_credentials_parse_string(s->user1_creds, tmp, CRED_SPECIFIED);
666 s->user2_creds = (struct cli_credentials *)talloc_memdup(s,
668 sizeof(*s->user1_creds));
669 tmp = torture_setting_string(s->tctx, "extra_user2", NULL);
671 cli_credentials_parse_string(s->user1_creds, tmp, CRED_SPECIFIED);
674 s->join_ctx = torture_join_domain(s->tctx, talloc_asprintf(s, "%sb", TEST_MACHINE_NAME),
675 ACB_WSTRUST, &s->wks_creds);
676 torture_assert(torture, s->join_ctx != NULL,
677 "Failed to join domain with acct_flags=ACB_WSTRUST");
679 cli_credentials_set_kerberos_state(s->wks_creds, CRED_DONT_USE_KERBEROS);
681 for (i=0; i < s->nprocs; i++) {
683 s->conns[i].index = i;
684 s->conns[i].wks_creds = (struct cli_credentials *)talloc_memdup(s->conns,
686 sizeof(*s->wks_creds));
687 s->conns[i].wks_creds->netlogon_creds = NULL;
690 status = dcerpc_parse_binding(s, binding, &s->b);
691 torture_assert_ntstatus_ok(torture, status, "Bad binding string");
692 s->b->flags &= ~DCERPC_AUTH_OPTIONS;
693 s->b->flags |= DCERPC_SCHANNEL | DCERPC_SIGN;
695 torture_comment(torture, "Opening %d connections in parallel\n", s->nprocs);
696 for (i=0; i < s->nprocs; i++) {
698 s->error = dcerpc_pipe_connect_b(s->conns, &s->conns[i].pipe, s->b,
700 s->conns[i].wks_creds,
701 torture->ev, torture->lp_ctx);
702 torture_assert_ntstatus_ok(torture, s->error, "Failed to connect with schannel");
705 * This path doesn't work against windows,
706 * because of windows drops the connections
707 * which haven't reached a session setup yet
709 * The same as the reset on zero vc stuff.
711 struct composite_context *c;
712 c = dcerpc_pipe_connect_b_send(s->conns, s->b,
714 s->conns[i].wks_creds,
717 torture_assert(torture, c != NULL, "Failed to setup connect");
718 c->async.fn = torture_schannel_bench_connected;
719 c->async.private_data = &s->conns[i];
722 while (NT_STATUS_IS_OK(s->error) && s->nprocs != s->nconns) {
723 int ev_ret = event_loop_once(torture->ev);
724 torture_assert(torture, ev_ret == 0, "event_loop_once failed");
727 torture_assert_ntstatus_ok(torture, s->error, "Failed establish a connect");
729 torture_comment(torture, "Start looping LogonSamLogonEx on %d connections for %d secs\n",
730 s->nprocs, s->timelimit);
731 for (i=0; i < s->nprocs; i++) {
732 ret = torture_schannel_bench_start(&s->conns[i]);
733 torture_assert(torture, ret, "Failed to setup LogonSamLogonEx");
736 start = timeval_current();
737 end = timeval_add(&start, s->timelimit, 0);
739 while (NT_STATUS_IS_OK(s->error) && !timeval_expired(&end)) {
740 int ev_ret = event_loop_once(torture->ev);
741 torture_assert(torture, ev_ret == 0, "event_loop_once failed");
743 torture_assert_ntstatus_ok(torture, s->error, "Failed some request");
745 talloc_free(s->conns);
747 for (i=0; i < s->nprocs; i++) {
748 s->total += s->conns[i].total;
751 torture_comment(torture,
752 "Total ops[%llu] (%u ops/s)\n",
753 (unsigned long long)s->total,
754 (unsigned)s->total/s->timelimit);
756 torture_leave_domain(s->join_ctx);