2 Unix SMB/CIFS implementation.
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) Stefan (metze) Metzmacher 2004
8 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2005-2006
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "torture/torture.h"
26 #include "librpc/gen_ndr/ndr_drsuapi_c.h"
27 #include "torture/rpc/rpc.h"
29 #define TEST_MACHINE_NAME "torturetest"
31 BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
32 struct DsPrivate *priv)
35 struct drsuapi_DsBind r;
38 GUID_from_string(DRSUAPI_DS_BIND_GUID, &priv->bind_guid);
40 r.in.bind_guid = &priv->bind_guid;
41 r.in.bind_info = NULL;
42 r.out.bind_handle = &priv->bind_handle;
44 printf("testing DsBind\n");
46 status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r);
47 if (!NT_STATUS_IS_OK(status)) {
48 const char *errstr = nt_errstr(status);
49 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
50 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
52 printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr);
54 } else if (!W_ERROR_IS_OK(r.out.result)) {
55 printf("DsBind failed - %s\n", win_errstr(r.out.result));
62 static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
63 struct DsPrivate *priv)
66 struct drsuapi_DsGetDomainControllerInfo r;
76 .name = torture_join_dom_netbios_name(priv->join),
80 .name = torture_join_dom_dns_name(priv->join),
84 .name = "__UNKNOWN_DOMAIN__",
85 .expected = WERR_DS_OBJ_NOT_FOUND
88 .name = "unknown.domain.samba.example.com",
89 .expected = WERR_DS_OBJ_NOT_FOUND
92 int levels[] = {1, 2};
95 for (i=0; i < ARRAY_SIZE(levels); i++) {
96 for (j=0; j < ARRAY_SIZE(names); j++) {
98 r.in.bind_handle = &priv->bind_handle;
101 r.in.req.req1.domain_name = names[j].name;
102 r.in.req.req1.level = level;
104 printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
105 r.in.req.req1.level, r.in.req.req1.domain_name);
107 status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
108 if (!NT_STATUS_IS_OK(status)) {
109 const char *errstr = nt_errstr(status);
110 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
111 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
113 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
114 " with dns domain failed - %s\n",
115 r.in.req.req1.level, errstr);
117 } else if (!W_ERROR_EQUAL(r.out.result, names[j].expected)) {
118 printf("DsGetDomainControllerInfo level %d\n"
119 " with dns domain failed - %s, expected %s\n",
120 r.in.req.req1.level, win_errstr(r.out.result),
121 win_errstr(names[j].expected));
125 if (!W_ERROR_IS_OK(r.out.result)) {
126 /* If this was an error, we can't read the result structure */
130 if (r.in.req.req1.level != r.out.level_out) {
131 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level in (%d) != out (%d)\n",
132 r.in.req.req1.level, r.out.level_out);
134 /* We can't safely read the result structure */
139 for (k=0; k < r.out.ctr.ctr1.count; k++) {
140 if (strcasecmp_m(r.out.ctr.ctr1.array[k].netbios_name,
141 torture_join_netbios_name(priv->join)) == 0) {
148 for (k=0; k < r.out.ctr.ctr2.count; k++) {
149 if (strcasecmp_m(r.out.ctr.ctr2.array[k].netbios_name,
150 torture_join_netbios_name(priv->join)) == 0) {
152 priv->dcinfo = r.out.ctr.ctr2.array[k];
159 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d: Failed to find the domain controller (%s) we just created during the join\n",
161 torture_join_netbios_name(priv->join));
167 if (lp_parm_bool(-1, "torture", "samba4", False)) {
168 printf("skipping DsGetDomainControllerInfo level -1 test against Samba4\n");
172 r.in.bind_handle = &priv->bind_handle;
175 r.in.req.req1.domain_name = "__UNKNOWN_DOMAIN__"; /* This is clearly ignored for this level */
176 r.in.req.req1.level = -1;
178 printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
179 r.in.req.req1.level, r.in.req.req1.domain_name);
181 status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
182 if (!NT_STATUS_IS_OK(status)) {
183 const char *errstr = nt_errstr(status);
184 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
185 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
187 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
188 " with dns domain failed - %s\n",
189 r.in.req.req1.level, errstr);
191 } else if (!W_ERROR_IS_OK(r.out.result)) {
192 printf("DsGetDomainControllerInfo level %d\n"
193 " with dns domain failed - %s\n",
194 r.in.req.req1.level, win_errstr(r.out.result));
199 const char *dc_account = talloc_asprintf(mem_ctx, "%s\\%s$",
200 torture_join_dom_netbios_name(priv->join),
201 priv->dcinfo.netbios_name);
202 for (k=0; k < r.out.ctr.ctr01.count; k++) {
203 if (strcasecmp_m(r.out.ctr.ctr01.array[k].client_account,
210 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d: Failed to find the domain controller (%s) in last logon records\n",
221 static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
222 struct DsPrivate *priv)
225 struct drsuapi_DsWriteAccountSpn r;
226 struct drsuapi_DsNameString names[2];
229 r.in.bind_handle = &priv->bind_handle;
232 printf("testing DsWriteAccountSpn\n");
234 r.in.req.req1.operation = DRSUAPI_DS_SPN_OPERATION_ADD;
235 r.in.req.req1.unknown1 = 0;
236 r.in.req.req1.object_dn = priv->dcinfo.computer_dn;
237 r.in.req.req1.count = 2;
238 r.in.req.req1.spn_names = names;
239 names[0].str = talloc_asprintf(mem_ctx, "smbtortureSPN/%s",priv->dcinfo.netbios_name);
240 names[1].str = talloc_asprintf(mem_ctx, "smbtortureSPN/%s",priv->dcinfo.dns_name);
242 status = dcerpc_drsuapi_DsWriteAccountSpn(p, mem_ctx, &r);
243 if (!NT_STATUS_IS_OK(status)) {
244 const char *errstr = nt_errstr(status);
245 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
246 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
248 printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr);
250 } else if (!W_ERROR_IS_OK(r.out.result)) {
251 printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result));
255 r.in.req.req1.operation = DRSUAPI_DS_SPN_OPERATION_DELETE;
256 r.in.req.req1.unknown1 = 0;
258 status = dcerpc_drsuapi_DsWriteAccountSpn(p, mem_ctx, &r);
259 if (!NT_STATUS_IS_OK(status)) {
260 const char *errstr = nt_errstr(status);
261 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
262 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
264 printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr);
266 } else if (!W_ERROR_IS_OK(r.out.result)) {
267 printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result));
274 static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
275 struct DsPrivate *priv)
278 struct drsuapi_DsReplicaGetInfo r;
287 DRSUAPI_DS_REPLICA_GET_INFO,
288 DRSUAPI_DS_REPLICA_INFO_NEIGHBORS,
291 DRSUAPI_DS_REPLICA_GET_INFO,
292 DRSUAPI_DS_REPLICA_INFO_CURSORS,
295 DRSUAPI_DS_REPLICA_GET_INFO,
296 DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA,
299 DRSUAPI_DS_REPLICA_GET_INFO,
300 DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES,
303 DRSUAPI_DS_REPLICA_GET_INFO,
304 DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES,
307 DRSUAPI_DS_REPLICA_GET_INFO,
308 DRSUAPI_DS_REPLICA_INFO_PENDING_OPS,
311 DRSUAPI_DS_REPLICA_GET_INFO2,
312 DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA,
315 DRSUAPI_DS_REPLICA_GET_INFO2,
316 DRSUAPI_DS_REPLICA_INFO_CURSORS2,
319 DRSUAPI_DS_REPLICA_GET_INFO2,
320 DRSUAPI_DS_REPLICA_INFO_CURSORS3,
323 DRSUAPI_DS_REPLICA_GET_INFO2,
324 DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2,
327 DRSUAPI_DS_REPLICA_GET_INFO2,
328 DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2,
331 DRSUAPI_DS_REPLICA_GET_INFO2,
332 DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02,
335 DRSUAPI_DS_REPLICA_GET_INFO2,
336 DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04,
339 DRSUAPI_DS_REPLICA_GET_INFO2,
340 DRSUAPI_DS_REPLICA_INFO_CURSORS05,
343 DRSUAPI_DS_REPLICA_GET_INFO2,
344 DRSUAPI_DS_REPLICA_INFO_06,
349 if (lp_parm_bool(-1, "torture", "samba4", False)) {
350 printf("skipping DsReplicaGetInfo test against Samba4\n");
354 r.in.bind_handle = &priv->bind_handle;
356 for (i=0; i < ARRAY_SIZE(array); i++) {
357 const char *object_dn;
359 printf("testing DsReplicaGetInfo level %d infotype %d\n",
360 array[i].level, array[i].infotype);
362 object_dn = (array[i].obj_dn ? array[i].obj_dn : priv->domain_obj_dn);
364 r.in.level = array[i].level;
366 case DRSUAPI_DS_REPLICA_GET_INFO:
367 r.in.req.req1.info_type = array[i].infotype;
368 r.in.req.req1.object_dn = object_dn;
369 ZERO_STRUCT(r.in.req.req1.guid1);
371 case DRSUAPI_DS_REPLICA_GET_INFO2:
372 r.in.req.req2.info_type = array[i].infotype;
373 r.in.req.req2.object_dn = object_dn;
374 ZERO_STRUCT(r.in.req.req1.guid1);
375 r.in.req.req2.unknown1 = 0;
376 r.in.req.req2.string1 = NULL;
377 r.in.req.req2.string2 = NULL;
378 r.in.req.req2.unknown2 = 0;
382 status = dcerpc_drsuapi_DsReplicaGetInfo(p, mem_ctx, &r);
383 if (!NT_STATUS_IS_OK(status)) {
384 const char *errstr = nt_errstr(status);
385 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
386 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
388 if (p->last_fault_code != DCERPC_FAULT_INVALID_TAG) {
389 printf("dcerpc_drsuapi_DsReplicaGetInfo failed - %s\n", errstr);
392 printf("DsReplicaGetInfo level %d and/or infotype %d not supported by server\n",
393 array[i].level, array[i].infotype);
395 } else if (!W_ERROR_IS_OK(r.out.result)) {
396 printf("DsReplicaGetInfo failed - %s\n", win_errstr(r.out.result));
404 static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
405 struct DsPrivate *priv)
410 struct drsuapi_DsReplicaSync r;
411 struct drsuapi_DsReplicaObjectIdentifier nc;
412 struct GUID null_guid;
413 struct dom_sid null_sid;
422 if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
423 printf("DsReplicaSync disabled - enable dangerous tests to use\n");
427 if (lp_parm_bool(-1, "torture", "samba4", False)) {
428 printf("skipping DsReplicaSync test against Samba4\n");
432 ZERO_STRUCT(null_guid);
433 ZERO_STRUCT(null_sid);
435 r.in.bind_handle = &priv->bind_handle;
437 for (i=0; i < ARRAY_SIZE(array); i++) {
438 printf("testing DsReplicaSync level %d\n",
441 r.in.level = array[i].level;
446 nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:"";
448 r.in.req.req1.naming_context = &nc;
449 r.in.req.req1.source_dsa_guid = priv->dcinfo.ntds_guid;
450 r.in.req.req1.other_info = NULL;
451 r.in.req.req1.options = 16;
455 status = dcerpc_drsuapi_DsReplicaSync(p, mem_ctx, &r);
456 if (!NT_STATUS_IS_OK(status)) {
457 const char *errstr = nt_errstr(status);
458 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
459 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
461 printf("dcerpc_drsuapi_DsReplicaSync failed - %s\n", errstr);
463 } else if (!W_ERROR_IS_OK(r.out.result)) {
464 printf("DsReplicaSync failed - %s\n", win_errstr(r.out.result));
472 static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
473 struct DsPrivate *priv)
478 struct drsuapi_DsReplicaUpdateRefs r;
479 struct drsuapi_DsReplicaObjectIdentifier nc;
480 struct GUID null_guid;
481 struct dom_sid null_sid;
490 if (lp_parm_bool(-1, "torture", "samba4", False)) {
491 printf("skipping DsReplicaUpdateRefs test against Samba4\n");
495 ZERO_STRUCT(null_guid);
496 ZERO_STRUCT(null_sid);
498 r.in.bind_handle = &priv->bind_handle;
500 for (i=0; i < ARRAY_SIZE(array); i++) {
501 printf("testing DsReplicaUpdateRefs level %d\n",
504 r.in.level = array[i].level;
509 nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:"";
511 r.in.req.req1.naming_context = &nc;
512 r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(mem_ctx, "__some_dest_dsa_guid_string._msdn.%s",
513 priv->domain_dns_name);
514 r.in.req.req1.dest_dsa_guid = null_guid;
515 r.in.req.req1.options = 0;
519 status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, mem_ctx, &r);
520 if (!NT_STATUS_IS_OK(status)) {
521 const char *errstr = nt_errstr(status);
522 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
523 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
525 printf("dcerpc_drsuapi_DsReplicaUpdateRefs failed - %s\n", errstr);
527 } else if (!W_ERROR_IS_OK(r.out.result)) {
528 printf("DsReplicaUpdateRefs failed - %s\n", win_errstr(r.out.result));
536 static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
537 struct DsPrivate *priv)
542 struct drsuapi_DsGetNCChanges r;
543 struct drsuapi_DsReplicaObjectIdentifier nc;
544 struct GUID null_guid;
545 struct dom_sid null_sid;
557 if (lp_parm_bool(-1, "torture", "samba4", False)) {
558 printf("skipping DsGetNCChanges test against Samba4\n");
562 ZERO_STRUCT(null_guid);
563 ZERO_STRUCT(null_sid);
565 for (i=0; i < ARRAY_SIZE(array); i++) {
566 printf("testing DsGetNCChanges level %d\n",
569 r.in.bind_handle = &priv->bind_handle;
570 r.in.level = &array[i].level;
572 switch (*r.in.level) {
576 nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:"";
578 r.in.req.req5.destination_dsa_guid = GUID_random();
579 r.in.req.req5.source_dsa_invocation_id = null_guid;
580 r.in.req.req5.naming_context = &nc;
581 r.in.req.req5.highwatermark.tmp_highest_usn = 0;
582 r.in.req.req5.highwatermark.reserved_usn = 0;
583 r.in.req.req5.highwatermark.highest_usn = 0;
584 r.in.req.req5.uptodateness_vector = NULL;
585 r.in.req.req5.replica_flags = 0;
586 if (lp_parm_bool(-1, "drsuapi","compression", False)) {
587 r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES;
589 r.in.req.req5.max_object_count = 0;
590 r.in.req.req5.max_ndr_size = 0;
591 r.in.req.req5.unknown4 = 0;
592 r.in.req.req5.h1 = 0;
598 nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:"";
600 r.in.req.req8.destination_dsa_guid = GUID_random();
601 r.in.req.req8.source_dsa_invocation_id = null_guid;
602 r.in.req.req8.naming_context = &nc;
603 r.in.req.req8.highwatermark.tmp_highest_usn = 0;
604 r.in.req.req8.highwatermark.reserved_usn = 0;
605 r.in.req.req8.highwatermark.highest_usn = 0;
606 r.in.req.req8.uptodateness_vector = NULL;
607 r.in.req.req8.replica_flags = 0;
608 if (lp_parm_bool(-1,"drsuapi","compression",False)) {
609 r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES;
611 if (lp_parm_bool(-1,"drsuapi","neighbour_writeable",True)) {
612 r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE;
614 r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
615 | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS
616 | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS
617 | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED
619 r.in.req.req8.max_object_count = 402;
620 r.in.req.req8.max_ndr_size = 402116;
621 r.in.req.req8.unknown4 = 0;
622 r.in.req.req8.h1 = 0;
623 r.in.req.req8.unique_ptr1 = 0;
624 r.in.req.req8.unique_ptr2 = 0;
625 r.in.req.req8.mapping_ctr.num_mappings = 0;
626 r.in.req.req8.mapping_ctr.mappings = NULL;
631 status = dcerpc_drsuapi_DsGetNCChanges(p, mem_ctx, &r);
632 if (!NT_STATUS_IS_OK(status)) {
633 const char *errstr = nt_errstr(status);
634 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
635 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
637 printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr);
639 } else if (!W_ERROR_IS_OK(r.out.result)) {
640 printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result));
648 BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
649 struct DsPrivate *priv)
652 struct drsuapi_QuerySitesByCost r;
655 const char *my_site = "Default-First-Site-Name";
656 const char *remote_site1 = "smbtorture-nonexisting-site1";
657 const char *remote_site2 = "smbtorture-nonexisting-site2";
659 r.in.bind_handle = &priv->bind_handle;
661 r.in.req.req1.site_from = talloc_strdup(mem_ctx, my_site);
662 r.in.req.req1.num_req = 2;
663 r.in.req.req1.site_to = talloc_zero_array(mem_ctx, const char *, r.in.req.req1.num_req);
664 r.in.req.req1.site_to[0] = talloc_strdup(mem_ctx, remote_site1);
665 r.in.req.req1.site_to[1] = talloc_strdup(mem_ctx, remote_site2);
666 r.in.req.req1.flags = 0;
668 status = dcerpc_drsuapi_QuerySitesByCost(p, mem_ctx, &r);
669 if (!NT_STATUS_IS_OK(status)) {
670 const char *errstr = nt_errstr(status);
671 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
672 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
674 printf("drsuapi_QuerySitesByCost - %s\n", errstr);
676 } else if (!W_ERROR_IS_OK(r.out.result)) {
677 printf("QuerySitesByCost failed - %s\n", win_errstr(r.out.result));
681 if (W_ERROR_IS_OK(r.out.result)) {
683 if (!W_ERROR_EQUAL(r.out.ctr.ctr1.info[0].error_code, WERR_DS_OBJ_NOT_FOUND) ||
684 !W_ERROR_EQUAL(r.out.ctr.ctr1.info[1].error_code, WERR_DS_OBJ_NOT_FOUND)) {
685 printf("expected error_code WERR_DS_OBJ_NOT_FOUND, got %s\n",
686 win_errstr(r.out.ctr.ctr1.info[0].error_code));
690 if ((r.out.ctr.ctr1.info[0].site_cost != (uint32_t) -1) ||
691 (r.out.ctr.ctr1.info[1].site_cost != (uint32_t) -1)) {
692 printf("expected site_cost %d, got %d\n",
693 (uint32_t) -1, r.out.ctr.ctr1.info[0].site_cost);
703 BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
704 struct DsPrivate *priv)
707 struct drsuapi_DsUnbind r;
710 r.in.bind_handle = &priv->bind_handle;
711 r.out.bind_handle = &priv->bind_handle;
713 printf("testing DsUnbind\n");
715 status = dcerpc_drsuapi_DsUnbind(p, mem_ctx, &r);
716 if (!NT_STATUS_IS_OK(status)) {
717 const char *errstr = nt_errstr(status);
718 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
719 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
721 printf("dcerpc_drsuapi_DsUnbind failed - %s\n", errstr);
723 } else if (!W_ERROR_IS_OK(r.out.result)) {
724 printf("DsBind failed - %s\n", win_errstr(r.out.result));
731 BOOL torture_rpc_drsuapi(struct torture_context *torture)
734 struct dcerpc_pipe *p;
737 struct DsPrivate priv;
738 struct cli_credentials *machine_credentials;
740 mem_ctx = talloc_init("torture_rpc_drsuapi");
744 priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST,
745 &machine_credentials);
747 talloc_free(mem_ctx);
748 printf("Failed to join as BDC\n");
752 status = torture_rpc_connection(mem_ctx,
754 &dcerpc_table_drsuapi);
755 if (!NT_STATUS_IS_OK(status)) {
756 torture_leave_domain(priv.join);
757 talloc_free(mem_ctx);
761 ret &= test_DsBind(p, mem_ctx, &priv);
763 ret &= test_QuerySitesByCost(p, mem_ctx, &priv);
765 ret &= test_DsGetDomainControllerInfo(p, mem_ctx, &priv);
767 ret &= test_DsCrackNames(p, mem_ctx, &priv);
769 ret &= test_DsWriteAccountSpn(p, mem_ctx, &priv);
771 ret &= test_DsReplicaGetInfo(p, mem_ctx, &priv);
773 ret &= test_DsReplicaSync(p, mem_ctx, &priv);
775 ret &= test_DsReplicaUpdateRefs(p, mem_ctx, &priv);
777 ret &= test_DsGetNCChanges(p, mem_ctx, &priv);
779 ret &= test_DsUnbind(p, mem_ctx, &priv);
781 talloc_free(mem_ctx);
783 torture_leave_domain(priv.join);
789 BOOL torture_rpc_drsuapi_cracknames(struct torture_context *torture)
792 struct dcerpc_pipe *p;
795 struct DsPrivate priv;
796 struct cli_credentials *machine_credentials;
798 mem_ctx = talloc_init("torture_rpc_drsuapi");
800 printf("Connected to DRAUAPI pipe\n");
804 priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST,
805 &machine_credentials);
807 talloc_free(mem_ctx);
808 printf("Failed to join as BDC\n");
812 status = torture_rpc_connection(mem_ctx,
814 &dcerpc_table_drsuapi);
815 if (!NT_STATUS_IS_OK(status)) {
816 torture_leave_domain(priv.join);
817 talloc_free(mem_ctx);
821 ret &= test_DsBind(p, mem_ctx, &priv);
824 /* We don't care if this fails, we just need some info from it */
825 test_DsGetDomainControllerInfo(p, mem_ctx, &priv);
827 ret &= test_DsCrackNames(p, mem_ctx, &priv);
829 ret &= test_DsUnbind(p, mem_ctx, &priv);
831 talloc_free(mem_ctx);
833 torture_leave_domain(priv.join);