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
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 2 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, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "torture/torture.h"
27 #include "librpc/gen_ndr/ndr_drsuapi_c.h"
28 #include "torture/rpc/rpc.h"
30 #define TEST_MACHINE_NAME "torturetest"
32 BOOL
test_DsBind(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
,
33 struct DsPrivate
*priv
)
36 struct drsuapi_DsBind r
;
39 GUID_from_string(DRSUAPI_DS_BIND_GUID
, &priv
->bind_guid
);
41 r
.in
.bind_guid
= &priv
->bind_guid
;
42 r
.in
.bind_info
= NULL
;
43 r
.out
.bind_handle
= &priv
->bind_handle
;
45 printf("testing DsBind\n");
47 status
= dcerpc_drsuapi_DsBind(p
, mem_ctx
, &r
);
48 if (!NT_STATUS_IS_OK(status
)) {
49 const char *errstr
= nt_errstr(status
);
50 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
51 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
53 printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr
);
55 } else if (!W_ERROR_IS_OK(r
.out
.result
)) {
56 printf("DsBind failed - %s\n", win_errstr(r
.out
.result
));
63 static BOOL
test_DsGetDCInfo(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
,
64 struct DsPrivate
*priv
)
67 struct drsuapi_DsGetDomainControllerInfo r
;
70 if (lp_parm_bool(-1, "torture", "samba4", False
)) {
71 printf("skipping DsGetDCInfo test against Samba4\n");
75 r
.in
.bind_handle
= &priv
->bind_handle
;
78 r
.in
.req
.req1
.domain_name
= talloc_strdup(mem_ctx
, lp_realm());
79 r
.in
.req
.req1
.level
= 1;
81 printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
82 r
.in
.req
.req1
.level
, r
.in
.req
.req1
.domain_name
);
84 status
= dcerpc_drsuapi_DsGetDomainControllerInfo(p
, mem_ctx
, &r
);
85 if (!NT_STATUS_IS_OK(status
)) {
86 const char *errstr
= nt_errstr(status
);
87 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
88 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
90 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
91 " with dns domain failed - %s\n",
92 r
.in
.req
.req1
.level
, errstr
);
94 } else if (!W_ERROR_IS_OK(r
.out
.result
)) {
95 printf("DsGetDomainControllerInfo level %d\n"
96 " with dns domain failed - %s\n",
97 r
.in
.req
.req1
.level
, win_errstr(r
.out
.result
));
101 r
.in
.req
.req1
.level
= 2;
103 printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
104 r
.in
.req
.req1
.level
, r
.in
.req
.req1
.domain_name
);
106 status
= dcerpc_drsuapi_DsGetDomainControllerInfo(p
, mem_ctx
, &r
);
107 if (!NT_STATUS_IS_OK(status
)) {
108 const char *errstr
= nt_errstr(status
);
109 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
110 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
112 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
113 " with dns domain failed - %s\n",
114 r
.in
.req
.req1
.level
, errstr
);
116 } else if (!W_ERROR_IS_OK(r
.out
.result
)) {
117 printf("DsGetDomainControllerInfo level %d\n"
118 " with dns domain failed - %s\n",
119 r
.in
.req
.req1
.level
, win_errstr(r
.out
.result
));
122 if (r
.out
.ctr
.ctr2
.count
> 0) {
123 priv
->dcinfo
= r
.out
.ctr
.ctr2
.array
[0];
127 r
.in
.req
.req1
.level
= -1;
129 printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
130 r
.in
.req
.req1
.level
, r
.in
.req
.req1
.domain_name
);
132 status
= dcerpc_drsuapi_DsGetDomainControllerInfo(p
, mem_ctx
, &r
);
133 if (!NT_STATUS_IS_OK(status
)) {
134 const char *errstr
= nt_errstr(status
);
135 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
136 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
138 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
139 " with dns domain failed - %s\n",
140 r
.in
.req
.req1
.level
, errstr
);
142 } else if (!W_ERROR_IS_OK(r
.out
.result
)) {
143 printf("DsGetDomainControllerInfo level %d\n"
144 " with dns domain failed - %s\n",
145 r
.in
.req
.req1
.level
, win_errstr(r
.out
.result
));
149 r
.in
.req
.req1
.domain_name
= talloc_strdup(mem_ctx
, lp_workgroup());
150 r
.in
.req
.req1
.level
= 2;
152 printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
153 r
.in
.req
.req1
.level
, r
.in
.req
.req1
.domain_name
);
155 status
= dcerpc_drsuapi_DsGetDomainControllerInfo(p
, mem_ctx
, &r
);
156 if (!NT_STATUS_IS_OK(status
)) {
157 const char *errstr
= nt_errstr(status
);
158 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
159 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
161 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
162 " with netbios domain failed - %s\n",
163 r
.in
.req
.req1
.level
, errstr
);
165 } else if (!W_ERROR_IS_OK(r
.out
.result
)) {
166 printf("DsGetDomainControllerInfo level %d\n"
167 " with netbios domain failed - %s\n",
168 r
.in
.req
.req1
.level
, win_errstr(r
.out
.result
));
172 r
.in
.req
.req1
.domain_name
= "__UNKNOWN_DOMAIN__";
173 r
.in
.req
.req1
.level
= 2;
175 printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
176 r
.in
.req
.req1
.level
, r
.in
.req
.req1
.domain_name
);
178 status
= dcerpc_drsuapi_DsGetDomainControllerInfo(p
, mem_ctx
, &r
);
179 if (!NT_STATUS_IS_OK(status
)) {
180 const char *errstr
= nt_errstr(status
);
181 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
182 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
184 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
185 " with invalid domain failed - %s\n",
186 r
.in
.req
.req1
.level
, errstr
);
188 } else if (!W_ERROR_EQUAL(r
.out
.result
, WERR_DS_OBJ_NOT_FOUND
)) {
189 printf("DsGetDomainControllerInfo level %d\n"
190 " with invalid domain not expected error (WERR_DS_OBJ_NOT_FOUND) - %s\n",
191 r
.in
.req
.req1
.level
, win_errstr(r
.out
.result
));
198 static BOOL
test_DsWriteAccountSpn(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
,
199 struct DsPrivate
*priv
)
202 struct drsuapi_DsWriteAccountSpn r
;
203 struct drsuapi_DsNameString names
[2];
206 r
.in
.bind_handle
= &priv
->bind_handle
;
209 printf("testing DsWriteAccountSpn\n");
211 r
.in
.req
.req1
.operation
= DRSUAPI_DS_SPN_OPERATION_ADD
;
212 r
.in
.req
.req1
.unknown1
= 0;
213 r
.in
.req
.req1
.object_dn
= priv
->dcinfo
.computer_dn
;
214 r
.in
.req
.req1
.count
= 2;
215 r
.in
.req
.req1
.spn_names
= names
;
216 names
[0].str
= talloc_asprintf(mem_ctx
, "smbtortureSPN/%s",priv
->dcinfo
.netbios_name
);
217 names
[1].str
= talloc_asprintf(mem_ctx
, "smbtortureSPN/%s",priv
->dcinfo
.dns_name
);
219 status
= dcerpc_drsuapi_DsWriteAccountSpn(p
, mem_ctx
, &r
);
220 if (!NT_STATUS_IS_OK(status
)) {
221 const char *errstr
= nt_errstr(status
);
222 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
223 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
225 printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr
);
227 } else if (!W_ERROR_IS_OK(r
.out
.result
)) {
228 printf("DsWriteAccountSpn failed - %s\n", win_errstr(r
.out
.result
));
232 r
.in
.req
.req1
.operation
= DRSUAPI_DS_SPN_OPERATION_DELETE
;
233 r
.in
.req
.req1
.unknown1
= 0;
235 status
= dcerpc_drsuapi_DsWriteAccountSpn(p
, mem_ctx
, &r
);
236 if (!NT_STATUS_IS_OK(status
)) {
237 const char *errstr
= nt_errstr(status
);
238 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
239 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
241 printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr
);
243 } else if (!W_ERROR_IS_OK(r
.out
.result
)) {
244 printf("DsWriteAccountSpn failed - %s\n", win_errstr(r
.out
.result
));
251 static BOOL
test_DsReplicaGetInfo(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
,
252 struct DsPrivate
*priv
)
255 struct drsuapi_DsReplicaGetInfo r
;
264 DRSUAPI_DS_REPLICA_GET_INFO
,
265 DRSUAPI_DS_REPLICA_INFO_NEIGHBORS
,
268 DRSUAPI_DS_REPLICA_GET_INFO
,
269 DRSUAPI_DS_REPLICA_INFO_CURSORS
,
272 DRSUAPI_DS_REPLICA_GET_INFO
,
273 DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA
,
276 DRSUAPI_DS_REPLICA_GET_INFO
,
277 DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES
,
280 DRSUAPI_DS_REPLICA_GET_INFO
,
281 DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES
,
284 DRSUAPI_DS_REPLICA_GET_INFO
,
285 DRSUAPI_DS_REPLICA_INFO_PENDING_OPS
,
288 DRSUAPI_DS_REPLICA_GET_INFO2
,
289 DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA
,
292 DRSUAPI_DS_REPLICA_GET_INFO2
,
293 DRSUAPI_DS_REPLICA_INFO_CURSORS2
,
296 DRSUAPI_DS_REPLICA_GET_INFO2
,
297 DRSUAPI_DS_REPLICA_INFO_CURSORS3
,
300 DRSUAPI_DS_REPLICA_GET_INFO2
,
301 DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2
,
304 DRSUAPI_DS_REPLICA_GET_INFO2
,
305 DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2
,
308 DRSUAPI_DS_REPLICA_GET_INFO2
,
309 DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02
,
312 DRSUAPI_DS_REPLICA_GET_INFO2
,
313 DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04
,
316 DRSUAPI_DS_REPLICA_GET_INFO2
,
317 DRSUAPI_DS_REPLICA_INFO_CURSURS05
,
320 DRSUAPI_DS_REPLICA_GET_INFO2
,
321 DRSUAPI_DS_REPLICA_INFO_06
,
326 if (lp_parm_bool(-1, "torture", "samba4", False
)) {
327 printf("skipping DsGetDCInfo test against Samba4\n");
331 r
.in
.bind_handle
= &priv
->bind_handle
;
333 for (i
=0; i
< ARRAY_SIZE(array
); i
++) {
334 const char *object_dn
;
336 printf("testing DsReplicaGetInfo level %d infotype %d\n",
337 array
[i
].level
, array
[i
].infotype
);
339 object_dn
= (array
[i
].obj_dn
? array
[i
].obj_dn
: priv
->domain_obj_dn
);
341 r
.in
.level
= array
[i
].level
;
343 case DRSUAPI_DS_REPLICA_GET_INFO
:
344 r
.in
.req
.req1
.info_type
= array
[i
].infotype
;
345 r
.in
.req
.req1
.object_dn
= object_dn
;
346 ZERO_STRUCT(r
.in
.req
.req1
.guid1
);
348 case DRSUAPI_DS_REPLICA_GET_INFO2
:
349 r
.in
.req
.req2
.info_type
= array
[i
].infotype
;
350 r
.in
.req
.req2
.object_dn
= object_dn
;
351 ZERO_STRUCT(r
.in
.req
.req1
.guid1
);
352 r
.in
.req
.req2
.unknown1
= 0;
353 r
.in
.req
.req2
.string1
= NULL
;
354 r
.in
.req
.req2
.string2
= NULL
;
355 r
.in
.req
.req2
.unknown2
= 0;
359 status
= dcerpc_drsuapi_DsReplicaGetInfo(p
, mem_ctx
, &r
);
360 if (!NT_STATUS_IS_OK(status
)) {
361 const char *errstr
= nt_errstr(status
);
362 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
363 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
365 if (p
->last_fault_code
!= DCERPC_FAULT_INVALID_TAG
) {
366 printf("dcerpc_drsuapi_DsReplicaGetInfo failed - %s\n", errstr
);
369 printf("DsReplicaGetInfo level %d and/or infotype %d not supported by server\n",
370 array
[i
].level
, array
[i
].infotype
);
372 } else if (!W_ERROR_IS_OK(r
.out
.result
)) {
373 printf("DsReplicaGetInfo failed - %s\n", win_errstr(r
.out
.result
));
381 static BOOL
test_DsReplicaSync(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
,
382 struct DsPrivate
*priv
)
387 struct drsuapi_DsReplicaSync r
;
388 struct drsuapi_DsReplicaObjectIdentifier nc
;
389 struct GUID null_guid
;
390 struct dom_sid null_sid
;
399 if (!lp_parm_bool(-1, "torture", "dangerous", False
)) {
400 printf("DsReplicaSync disabled - enable dangerous tests to use\n");
404 if (lp_parm_bool(-1, "torture", "samba4", False
)) {
405 printf("skipping DsReplicaSync test against Samba4\n");
409 ZERO_STRUCT(null_guid
);
410 ZERO_STRUCT(null_sid
);
412 r
.in
.bind_handle
= &priv
->bind_handle
;
414 for (i
=0; i
< ARRAY_SIZE(array
); i
++) {
415 printf("testing DsReplicaSync level %d\n",
418 r
.in
.level
= array
[i
].level
;
423 nc
.dn
= priv
->domain_obj_dn
?priv
->domain_obj_dn
:"";
425 r
.in
.req
.req1
.naming_context
= &nc
;
426 r
.in
.req
.req1
.guid1
= priv
->dcinfo
.ntds_guid
;
427 r
.in
.req
.req1
.string1
= NULL
;
428 r
.in
.req
.req1
.options
= 16;
432 status
= dcerpc_drsuapi_DsReplicaSync(p
, mem_ctx
, &r
);
433 if (!NT_STATUS_IS_OK(status
)) {
434 const char *errstr
= nt_errstr(status
);
435 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
436 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
438 printf("dcerpc_drsuapi_DsReplicaSync failed - %s\n", errstr
);
440 } else if (!W_ERROR_IS_OK(r
.out
.result
)) {
441 printf("DsReplicaSync failed - %s\n", win_errstr(r
.out
.result
));
449 static BOOL
test_DsReplicaUpdateRefs(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
,
450 struct DsPrivate
*priv
)
455 struct drsuapi_DsReplicaUpdateRefs r
;
456 struct drsuapi_DsReplicaObjectIdentifier nc
;
457 struct GUID null_guid
;
458 struct dom_sid null_sid
;
467 if (lp_parm_bool(-1, "torture", "samba4", False
)) {
468 printf("skipping DsReplicaUpdateRefs test against Samba4\n");
472 ZERO_STRUCT(null_guid
);
473 ZERO_STRUCT(null_sid
);
475 r
.in
.bind_handle
= &priv
->bind_handle
;
477 for (i
=0; i
< ARRAY_SIZE(array
); i
++) {
478 printf("testing DsReplicaUpdateRefs level %d\n",
481 r
.in
.level
= array
[i
].level
;
486 nc
.dn
= priv
->domain_obj_dn
?priv
->domain_obj_dn
:"";
488 r
.in
.req
.req1
.naming_context
= &nc
;
489 r
.in
.req
.req1
.dest_dsa_dns_name
= talloc_asprintf(mem_ctx
, "__some_dest_dsa_guid_string._msdn.%s",
490 priv
->domain_dns_name
);
491 r
.in
.req
.req1
.dest_dsa_guid
= null_guid
;
492 r
.in
.req
.req1
.options
= 0;
496 status
= dcerpc_drsuapi_DsReplicaUpdateRefs(p
, mem_ctx
, &r
);
497 if (!NT_STATUS_IS_OK(status
)) {
498 const char *errstr
= nt_errstr(status
);
499 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
500 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
502 printf("dcerpc_drsuapi_DsReplicaUpdateRefs failed - %s\n", errstr
);
504 } else if (!W_ERROR_IS_OK(r
.out
.result
)) {
505 printf("DsReplicaUpdateRefs failed - %s\n", win_errstr(r
.out
.result
));
513 static BOOL
test_DsGetNCChanges(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
,
514 struct DsPrivate
*priv
)
519 struct drsuapi_DsGetNCChanges r
;
520 struct drsuapi_DsReplicaObjectIdentifier nc
;
521 struct GUID null_guid
;
522 struct dom_sid null_sid
;
534 if (lp_parm_bool(-1, "torture", "samba4", False
)) {
535 printf("skipping DsGetNCChanges test against Samba4\n");
539 ZERO_STRUCT(null_guid
);
540 ZERO_STRUCT(null_sid
);
542 for (i
=0; i
< ARRAY_SIZE(array
); i
++) {
543 printf("testing DsGetNCChanges level %d\n",
546 r
.in
.bind_handle
= &priv
->bind_handle
;
547 r
.in
.level
= array
[i
].level
;
549 switch (r
.in
.level
) {
553 nc
.dn
= priv
->domain_obj_dn
?priv
->domain_obj_dn
:"";
555 r
.in
.req
.req5
.destination_dsa_guid
= GUID_random();
556 r
.in
.req
.req5
.source_dsa_guid
= null_guid
;
557 r
.in
.req
.req5
.naming_context
= &nc
;
558 r
.in
.req
.req5
.highwatermark
.tmp_highest_usn
= 0;
559 r
.in
.req
.req5
.highwatermark
.reserved_usn
= 0;
560 r
.in
.req
.req5
.highwatermark
.highest_usn
= 0;
561 r
.in
.req
.req5
.uptodateness_vector
= NULL
;
562 r
.in
.req
.req5
.replica_flags
= 0;
563 if (lp_parm_bool(-1, "drsuapi","compression", False
)) {
564 r
.in
.req
.req5
.replica_flags
|= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES
;
566 r
.in
.req
.req5
.unknown2
= 0;
567 r
.in
.req
.req5
.unknown3
= 0;
568 r
.in
.req
.req5
.unknown4
= 0;
569 r
.in
.req
.req5
.h1
= 0;
575 nc
.dn
= priv
->domain_obj_dn
?priv
->domain_obj_dn
:"";
577 r
.in
.req
.req8
.destination_dsa_guid
= GUID_random();
578 r
.in
.req
.req8
.source_dsa_guid
= null_guid
;
579 r
.in
.req
.req8
.naming_context
= &nc
;
580 r
.in
.req
.req8
.highwatermark
.tmp_highest_usn
= 0;
581 r
.in
.req
.req8
.highwatermark
.reserved_usn
= 0;
582 r
.in
.req
.req8
.highwatermark
.highest_usn
= 0;
583 r
.in
.req
.req8
.uptodateness_vector
= NULL
;
584 r
.in
.req
.req8
.replica_flags
= 0;
585 if (lp_parm_bool(-1,"drsuapi","compression",False
)) {
586 r
.in
.req
.req8
.replica_flags
|= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES
;
588 if (lp_parm_bool(-1,"drsuapi","neighbour_writeable",True
)) {
589 r
.in
.req
.req8
.replica_flags
|= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE
;
591 r
.in
.req
.req8
.replica_flags
|= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
592 | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS
593 | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS
594 | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED
596 r
.in
.req
.req8
.unknown2
= 402;
597 r
.in
.req
.req8
.unknown3
= 402116;
598 r
.in
.req
.req8
.unknown4
= 0;
599 r
.in
.req
.req8
.h1
= 0;
600 r
.in
.req
.req8
.unique_ptr1
= 0;
601 r
.in
.req
.req8
.unique_ptr2
= 0;
602 r
.in
.req
.req8
.ctr12
.count
= 0;
603 r
.in
.req
.req8
.ctr12
.array
= NULL
;
608 status
= dcerpc_drsuapi_DsGetNCChanges(p
, mem_ctx
, &r
);
609 if (!NT_STATUS_IS_OK(status
)) {
610 const char *errstr
= nt_errstr(status
);
611 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
612 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
614 printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr
);
616 } else if (!W_ERROR_IS_OK(r
.out
.result
)) {
617 printf("DsGetNCChanges failed - %s\n", win_errstr(r
.out
.result
));
625 BOOL
test_DsUnbind(struct dcerpc_pipe
*p
, TALLOC_CTX
*mem_ctx
,
626 struct DsPrivate
*priv
)
629 struct drsuapi_DsUnbind r
;
632 r
.in
.bind_handle
= &priv
->bind_handle
;
633 r
.out
.bind_handle
= &priv
->bind_handle
;
635 printf("testing DsUnbind\n");
637 status
= dcerpc_drsuapi_DsUnbind(p
, mem_ctx
, &r
);
638 if (!NT_STATUS_IS_OK(status
)) {
639 const char *errstr
= nt_errstr(status
);
640 if (NT_STATUS_EQUAL(status
, NT_STATUS_NET_WRITE_FAULT
)) {
641 errstr
= dcerpc_errstr(mem_ctx
, p
->last_fault_code
);
643 printf("dcerpc_drsuapi_DsUnbind failed - %s\n", errstr
);
645 } else if (!W_ERROR_IS_OK(r
.out
.result
)) {
646 printf("DsBind failed - %s\n", win_errstr(r
.out
.result
));
653 BOOL
torture_rpc_drsuapi(struct torture_context
*torture
)
656 struct dcerpc_pipe
*p
;
659 struct DsPrivate priv
;
660 struct cli_credentials
*machine_credentials
;
662 mem_ctx
= talloc_init("torture_rpc_drsuapi");
664 printf("Connected to DRAUAPI pipe\n");
668 priv
.join
= torture_join_domain(TEST_MACHINE_NAME
, ACB_SVRTRUST
,
669 &machine_credentials
);
671 talloc_free(mem_ctx
);
672 printf("Failed to join as BDC\n");
676 status
= torture_rpc_connection(mem_ctx
,
678 &dcerpc_table_drsuapi
);
679 if (!NT_STATUS_IS_OK(status
)) {
680 torture_leave_domain(priv
.join
);
681 talloc_free(mem_ctx
);
685 ret
&= test_DsBind(p
, mem_ctx
, &priv
);
687 ret
&= test_DsGetDCInfo(p
, mem_ctx
, &priv
);
689 ret
&= test_DsCrackNames(p
, mem_ctx
, &priv
, TEST_MACHINE_NAME
);
691 ret
&= test_DsWriteAccountSpn(p
, mem_ctx
, &priv
);
693 ret
&= test_DsReplicaGetInfo(p
, mem_ctx
, &priv
);
695 ret
&= test_DsReplicaSync(p
, mem_ctx
, &priv
);
697 ret
&= test_DsReplicaUpdateRefs(p
, mem_ctx
, &priv
);
699 ret
&= test_DsGetNCChanges(p
, mem_ctx
, &priv
);
701 ret
&= test_DsUnbind(p
, mem_ctx
, &priv
);
703 talloc_free(mem_ctx
);
705 torture_leave_domain(priv
.join
);