2 Unix SMB/CIFS implementation.
4 DsGetNCChanges replication test
6 Copyright (C) Stefan (metze) Metzmacher 2005
7 Copyright (C) Brad Henry 2005
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "lib/cmdline/popt_common.h"
26 #include "librpc/gen_ndr/ndr_drsuapi_c.h"
27 #include "libcli/cldap/cldap.h"
28 #include "libcli/ldap/ldap_client.h"
29 #include "torture/torture.h"
30 #include "torture/ldap/proto.h"
31 #include "libcli/auth/libcli_auth.h"
32 #include "lib/crypto/crypto.h"
33 #include "auth/credentials/credentials.h"
34 #include "libcli/auth/libcli_auth.h"
35 #include "auth/gensec/gensec.h"
37 struct DsSyncBindInfo {
38 struct dcerpc_pipe *pipe;
39 struct drsuapi_DsBind req;
40 struct GUID bind_guid;
41 struct drsuapi_DsBindInfoCtr our_bind_info_ctr;
42 struct drsuapi_DsBindInfo28 our_bind_info28;
43 struct drsuapi_DsBindInfo28 peer_bind_info28;
44 struct policy_handle bind_handle;
47 struct samr_Password nthash;
50 struct DsSyncLDAPInfo {
51 struct ldap_connection *conn;
55 struct dcerpc_binding *drsuapi_binding;
58 const char *site_name;
60 const char *domain_dn;
62 /* what we need to do as 'Administrator' */
64 struct cli_credentials *credentials;
65 struct DsSyncBindInfo drsuapi;
66 struct DsSyncLDAPInfo ldap;
69 /* what we need to do as the new dc machine account */
71 struct cli_credentials *credentials;
72 struct DsSyncBindInfo drsuapi;
73 struct drsuapi_DsGetDCInfo2 dc_info2;
74 struct GUID invocation_id;
75 struct GUID object_guid;
78 /* info about the old dc */
80 struct drsuapi_DsGetDomainControllerInfo dc_info;
84 static struct DsSyncTest *test_create_context(TALLOC_CTX *mem_ctx)
87 struct DsSyncTest *ctx;
88 struct drsuapi_DsBindInfo28 *our_bind_info28;
89 struct drsuapi_DsBindInfoCtr *our_bind_info_ctr;
90 const char *binding = lp_parm_string(-1, "torture", "binding");
91 ctx = talloc_zero(mem_ctx, struct DsSyncTest);
92 if (!ctx) return NULL;
94 status = dcerpc_parse_binding(ctx, binding, &ctx->drsuapi_binding);
95 if (!NT_STATUS_IS_OK(status)) {
96 printf("Bad binding string %s\n", binding);
99 ctx->drsuapi_binding->flags |= DCERPC_SIGN | DCERPC_SEAL;
101 ctx->ldap_url = talloc_asprintf(ctx, "ldap://%s/", ctx->drsuapi_binding->host);
104 ctx->admin.credentials = cmdline_credentials;
106 our_bind_info28 = &ctx->admin.drsuapi.our_bind_info28;
107 our_bind_info28->supported_extensions = 0xFFFFFFFF;
108 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
109 our_bind_info28->site_guid = GUID_zero();
110 our_bind_info28->u1 = 0;
111 our_bind_info28->repl_epoch = 1;
113 our_bind_info_ctr = &ctx->admin.drsuapi.our_bind_info_ctr;
114 our_bind_info_ctr->length = 28;
115 our_bind_info_ctr->info.info28 = *our_bind_info28;
117 GUID_from_string(DRSUAPI_DS_BIND_GUID, &ctx->admin.drsuapi.bind_guid);
119 ctx->admin.drsuapi.req.in.bind_guid = &ctx->admin.drsuapi.bind_guid;
120 ctx->admin.drsuapi.req.in.bind_info = our_bind_info_ctr;
121 ctx->admin.drsuapi.req.out.bind_handle = &ctx->admin.drsuapi.bind_handle;
124 ctx->new_dc.credentials = cmdline_credentials;
126 our_bind_info28 = &ctx->new_dc.drsuapi.our_bind_info28;
127 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_BASE;
128 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION;
129 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI;
130 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2;
131 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS;
132 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1;
133 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION;
134 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE;
135 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2;
136 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION;
137 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2;
138 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD;
139 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND;
140 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO;
141 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION;
142 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01;
143 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP;
144 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY;
145 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3;
146 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2;
147 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6;
148 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS;
149 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8;
150 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5;
151 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6;
152 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
153 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7;
154 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT;
155 if (lp_parm_bool(-1,"dssync","xpress",False)) {
156 our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS;
158 our_bind_info28->site_guid = GUID_zero();
159 our_bind_info28->u1 = 508;
160 our_bind_info28->repl_epoch = 0;
162 our_bind_info_ctr = &ctx->new_dc.drsuapi.our_bind_info_ctr;
163 our_bind_info_ctr->length = 28;
164 our_bind_info_ctr->info.info28 = *our_bind_info28;
166 GUID_from_string(DRSUAPI_DS_BIND_GUID_W2K3, &ctx->new_dc.drsuapi.bind_guid);
168 ctx->new_dc.drsuapi.req.in.bind_guid = &ctx->new_dc.drsuapi.bind_guid;
169 ctx->new_dc.drsuapi.req.in.bind_info = our_bind_info_ctr;
170 ctx->new_dc.drsuapi.req.out.bind_handle = &ctx->new_dc.drsuapi.bind_handle;
172 ctx->new_dc.invocation_id = ctx->new_dc.drsuapi.bind_guid;
179 static BOOL _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncBindInfo *b)
183 struct event_context *event = NULL;
184 const struct samr_Password *nthash;
186 status = dcerpc_pipe_connect_b(ctx,
187 &b->pipe, ctx->drsuapi_binding,
188 &dcerpc_table_drsuapi,
191 if (!NT_STATUS_IS_OK(status)) {
192 printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status));
196 status = dcerpc_drsuapi_DsBind(b->pipe, ctx, &b->req);
197 if (!NT_STATUS_IS_OK(status)) {
198 const char *errstr = nt_errstr(status);
199 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
200 errstr = dcerpc_errstr(ctx, b->pipe->last_fault_code);
202 printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr);
204 } else if (!W_ERROR_IS_OK(b->req.out.result)) {
205 printf("DsBind failed - %s\n", win_errstr(b->req.out.result));
209 ZERO_STRUCT(b->peer_bind_info28);
210 if (b->req.out.bind_info) {
211 switch (b->req.out.bind_info->length) {
213 struct drsuapi_DsBindInfo24 *info24;
214 info24 = &b->req.out.bind_info->info.info24;
215 b->peer_bind_info28.supported_extensions= info24->supported_extensions;
216 b->peer_bind_info28.site_guid = info24->site_guid;
217 b->peer_bind_info28.u1 = info24->u1;
218 b->peer_bind_info28.repl_epoch = 0;
222 b->peer_bind_info28 = b->req.out.bind_info->info.info28;
227 dcerpc_fetch_session_key(b->pipe, &b->dce_key);
228 gensec_session_key(b->pipe->conn->security_state.generic_state, &b->gen_key);
229 nthash = cli_credentials_get_nt_hash(credentials, NULL);
230 if (nthash) b->nthash = *nthash;
232 if (lp_parm_bool(-1,"dssync","print_pwd_blobs",False)) {
233 DEBUG(0,("DCERPC session key:\n"));
234 dump_data(0, b->dce_key.data, b->dce_key.length);
235 DEBUG(0,("GENSEC session key:\n"));
236 dump_data(0, b->gen_key.data, b->gen_key.length);
237 DEBUG(0,("CREDENTIALS nthash:\n"));
238 dump_data(0, b->nthash.hash, sizeof(b->nthash.hash));
244 static BOOL test_LDAPBind(struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncLDAPInfo *l)
249 status = torture_ldap_connection(ctx, &l->conn, ctx->ldap_url);
250 if (!NT_STATUS_IS_OK(status)) {
251 printf("failed to connect to LDAP: %s\n", ctx->ldap_url);
255 printf("connected to LDAP: %s\n", ctx->ldap_url);
257 status = torture_ldap_bind_sasl(l->conn, credentials);
258 if (!NT_STATUS_IS_OK(status)) {
259 printf("failed to bind to LDAP:\n");
262 printf("bound to LDAP.\n");
267 static BOOL test_GetInfo(struct DsSyncTest *ctx)
270 struct drsuapi_DsCrackNames r;
271 struct drsuapi_DsNameString names[1];
274 struct cldap_socket *cldap = cldap_socket_init(ctx, NULL);
275 struct cldap_netlogon search;
277 r.in.bind_handle = &ctx->admin.drsuapi.bind_handle;
279 r.in.req.req1.codepage = 1252; /* western european */
280 r.in.req.req1.language = 0x00000407; /* german */
281 r.in.req.req1.count = 1;
282 r.in.req.req1.names = names;
283 r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS;
284 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT;
285 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
286 names[0].str = talloc_asprintf(ctx, "%s\\", lp_workgroup());
288 status = dcerpc_drsuapi_DsCrackNames(ctx->admin.drsuapi.pipe, ctx, &r);
289 if (!NT_STATUS_IS_OK(status)) {
290 const char *errstr = nt_errstr(status);
291 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
292 errstr = dcerpc_errstr(ctx, ctx->admin.drsuapi.pipe->last_fault_code);
294 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
296 } else if (!W_ERROR_IS_OK(r.out.result)) {
297 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
301 ctx->domain_dn = r.out.ctr.ctr1->array[0].result_name;
304 search.in.dest_address = ctx->drsuapi_binding->host;
305 search.in.acct_control = -1;
306 search.in.version = 6;
307 status = cldap_netlogon(cldap, ctx, &search);
308 if (!NT_STATUS_IS_OK(status)) {
309 const char *errstr = nt_errstr(status);
310 ctx->site_name = talloc_asprintf(ctx, "%s", "Default-First-Site-Name");
311 printf("cldap_netlogon() returned %s. Defaulting to Site-Name: %s\n", errstr, ctx->site_name);
313 ctx->site_name = talloc_steal(ctx, search.out.netlogon.logon5.client_site);
314 printf("cldap_netlogon() returned Client Site-Name: %s.\n",ctx->site_name);
315 printf("cldap_netlogon() returned Server Site-Name: %s.\n",search.out.netlogon.logon5.server_site);
321 static void test_analyse_objects(struct DsSyncTest *ctx,
322 struct drsuapi_DsReplicaObjectListItemEx *cur)
324 if (!lp_parm_bool(-1,"dssync","print_pwd_blobs",False)) {
328 for (; cur; cur = cur->next_object) {
330 BOOL dn_printed = False;
333 if (!cur->object.identifier) continue;
335 dn = cur->object.identifier->dn;
337 for (i=0; i < cur->object.attribute_ctr.num_attributes; i++) {
338 const char *name = NULL;
339 DATA_BLOB *data = NULL;
340 struct drsuapi_DsReplicaAttribute *attr;
341 attr = &cur->object.attribute_ctr.attributes[i];
343 switch (attr->attid) {
344 case DRSUAPI_ATTRIBUTE_dBCSPwd:
347 case DRSUAPI_ATTRIBUTE_unicodePwd:
350 case DRSUAPI_ATTRIBUTE_ntPwdHistory:
351 name = "ntPwdHistory";
353 case DRSUAPI_ATTRIBUTE_lmPwdHistory:
354 name = "lmPwdHistory";
356 case DRSUAPI_ATTRIBUTE_supplementalCredentials:
357 name = "supplementalCredentials";
359 case DRSUAPI_ATTRIBUTE_priorValue:
362 case DRSUAPI_ATTRIBUTE_currentValue:
363 name = "currentValue";
365 case DRSUAPI_ATTRIBUTE_trustAuthOutgoing:
366 name = "trustAuthOutgoing";
368 case DRSUAPI_ATTRIBUTE_trustAuthIncoming:
369 name = "trustAuthIncoming";
371 case DRSUAPI_ATTRIBUTE_initialAuthOutgoing:
372 name = "initialAuthOutgoing";
374 case DRSUAPI_ATTRIBUTE_initialAuthIncoming:
375 name = "initialAuthIncoming";
381 if (attr->value_ctr.num_values != 1) continue;
383 if (!attr->value_ctr.values[0].blob) continue;
385 data = attr->value_ctr.values[0].blob;
388 DEBUG(0,("DN: %s\n", dn));
391 DEBUGADD(0,("ATTR: %s data_blob.length=%lu\n",
392 name, (long)data->length));
393 dump_data(0,data->data, data->length);
398 static BOOL test_FetchData(struct DsSyncTest *ctx)
403 uint64_t highest_usn = 0;
404 const char *partition = NULL;
405 struct drsuapi_DsGetNCChanges r;
406 struct drsuapi_DsReplicaObjectIdentifier nc;
407 struct drsuapi_DsGetNCChangesCtr1 *ctr1 = NULL;
408 struct drsuapi_DsGetNCChangesCtr6 *ctr6 = NULL;
409 int32_t out_level = 0;
410 struct GUID null_guid;
411 struct dom_sid null_sid;
423 ZERO_STRUCT(null_guid);
424 ZERO_STRUCT(null_sid);
426 partition = lp_parm_string(-1, "dssync", "partition");
427 if (partition == NULL) {
428 partition = ctx->domain_dn;
429 printf("dssync:partition not specified, defaulting to %s.\n", ctx->domain_dn);
432 highest_usn = lp_parm_int(-1, "dssync", "highest_usn", 0);
434 for (i=0; i < ARRAY_SIZE(array); i++) {
435 printf("testing DsGetNCChanges level %d\n",
438 r.in.bind_handle = &ctx->new_dc.drsuapi.bind_handle;
439 r.in.level = &array[i].level;
441 switch (*r.in.level) {
447 r.in.req.req5.destination_dsa_guid = ctx->new_dc.invocation_id;
448 r.in.req.req5.source_dsa_invocation_id = null_guid;
449 r.in.req.req5.naming_context = &nc;
450 r.in.req.req5.highwatermark.tmp_highest_usn = highest_usn;
451 r.in.req.req5.highwatermark.reserved_usn = 0;
452 r.in.req.req5.highwatermark.highest_usn = highest_usn;
453 r.in.req.req5.uptodateness_vector = NULL;
454 r.in.req.req5.replica_flags = 0;
455 if (lp_parm_bool(-1,"dssync","compression",False)) {
456 r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES;
458 if (lp_parm_bool(-1,"dssync","neighbour_writeable",True)) {
459 r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE;
461 r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
462 | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS
463 | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS
464 | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED
466 r.in.req.req5.max_object_count = 133;
467 r.in.req.req5.max_ndr_size = 1336770;
468 r.in.req.req5.unknown4 = 0;
469 r.in.req.req5.h1 = 0;
476 /* nc.dn can be set to any other ad partition */
478 r.in.req.req8.destination_dsa_guid = ctx->new_dc.invocation_id;
479 r.in.req.req8.source_dsa_invocation_id = null_guid;
480 r.in.req.req8.naming_context = &nc;
481 r.in.req.req8.highwatermark.tmp_highest_usn = highest_usn;
482 r.in.req.req8.highwatermark.reserved_usn = 0;
483 r.in.req.req8.highwatermark.highest_usn = highest_usn;
484 r.in.req.req8.uptodateness_vector = NULL;
485 r.in.req.req8.replica_flags = 0;
486 if (lp_parm_bool(-1,"dssync","compression",False)) {
487 r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES;
489 if (lp_parm_bool(-1,"dssync","neighbour_writeable",True)) {
490 r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE;
492 r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
493 | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS
494 | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS
495 | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED
497 r.in.req.req8.max_object_count = 402;
498 r.in.req.req8.max_ndr_size = 402116;
500 r.in.req.req8.unknown4 = 0;
501 r.in.req.req8.h1 = 0;
502 r.in.req.req8.unique_ptr1 = 0;
503 r.in.req.req8.unique_ptr2 = 0;
504 r.in.req.req8.mapping_ctr.num_mappings = 0;
505 r.in.req.req8.mapping_ctr.mappings = NULL;
510 printf("Dumping AD partition: %s\n", nc.dn);
514 r.out.level = &_level;
516 if (*r.in.level == 5) {
517 DEBUG(0,("start[%d] tmp_higest_usn: %llu , highest_usn: %llu\n",y,
518 (long long)r.in.req.req5.highwatermark.tmp_highest_usn,
519 (long long)r.in.req.req5.highwatermark.highest_usn));
522 if (*r.in.level == 8) {
523 DEBUG(0,("start[%d] tmp_higest_usn: %llu , highest_usn: %llu\n",y,
524 (long long)r.in.req.req8.highwatermark.tmp_highest_usn,
525 (long long)r.in.req.req8.highwatermark.highest_usn));
528 status = dcerpc_drsuapi_DsGetNCChanges(ctx->new_dc.drsuapi.pipe, ctx, &r);
529 if (!NT_STATUS_IS_OK(status)) {
530 const char *errstr = nt_errstr(status);
531 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
532 errstr = dcerpc_errstr(ctx, ctx->new_dc.drsuapi.pipe->last_fault_code);
534 printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr);
536 } else if (!W_ERROR_IS_OK(r.out.result)) {
537 printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result));
541 if (ret == True && *r.out.level == 1) {
543 ctr1 = &r.out.ctr.ctr1;
544 } else if (ret == True && *r.out.level == 2) {
546 ctr1 = r.out.ctr.ctr2.ctr.mszip1.ctr1;
549 if (out_level == 1) {
550 DEBUG(0,("end[%d] tmp_highest_usn: %llu , highest_usn: %llu\n",y,
551 (long long)ctr1->new_highwatermark.tmp_highest_usn,
552 (long long)ctr1->new_highwatermark.highest_usn));
554 test_analyse_objects(ctx, ctr1->first_object);
556 if (ctr1->new_highwatermark.tmp_highest_usn > ctr1->new_highwatermark.highest_usn) {
557 r.in.req.req5.highwatermark = ctr1->new_highwatermark;
562 if (ret == True && *r.out.level == 6) {
564 ctr6 = &r.out.ctr.ctr6;
565 } else if (ret == True && *r.out.level == 7
566 && r.out.ctr.ctr7.level == 6
567 && r.out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) {
569 ctr6 = r.out.ctr.ctr7.ctr.mszip6.ctr6;
572 if (out_level == 6) {
573 DEBUG(0,("end[%d] tmp_highest_usn: %llu , highest_usn: %llu\n",y,
574 (long long)ctr6->new_highwatermark.tmp_highest_usn,
575 (long long)ctr6->new_highwatermark.highest_usn));
577 test_analyse_objects(ctx, ctr6->first_object);
579 if (ctr6->new_highwatermark.tmp_highest_usn > ctr6->new_highwatermark.highest_usn) {
580 r.in.req.req8.highwatermark = ctr6->new_highwatermark;
592 static BOOL test_FetchNT4Data(struct DsSyncTest *ctx)
597 uint64_t highest_usn = 0;
598 const char *partition = NULL;
599 struct drsuapi_DsGetNT4ChangeLog r;
600 int32_t out_level = 0;
601 struct GUID null_guid;
602 struct dom_sid null_sid;
605 ZERO_STRUCT(null_guid);
606 ZERO_STRUCT(null_sid);
610 r.in.bind_handle = &ctx->new_dc.drsuapi.bind_handle;
613 r.in.req.req1.unknown1 = lp_parm_int(-1, "dssync", "nt4-1", 3);
614 r.in.req.req1.unknown2 = lp_parm_int(-1, "dssync", "nt4-2", 0x00004000);
617 r.in.req.req1.length = cookie.length;
618 r.in.req.req1.data = cookie.data;
620 status = dcerpc_drsuapi_DsGetNT4ChangeLog(ctx->new_dc.drsuapi.pipe, ctx, &r);
621 if (!NT_STATUS_IS_OK(status)) {
622 const char *errstr = nt_errstr(status);
623 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
624 errstr = dcerpc_errstr(ctx, ctx->new_dc.drsuapi.pipe->last_fault_code);
626 printf("dcerpc_drsuapi_DsGetNT4ChangeLog failed - %s\n", errstr);
628 } else if (!W_ERROR_IS_OK(r.out.result)) {
629 printf("DsGetNT4ChangeLog failed - %s\n", win_errstr(r.out.result));
631 } else if (r.out.level != 1) {
632 printf("DsGetNT4ChangeLog unknown level - %u\n", r.out.level);
634 } else if (NT_STATUS_IS_OK(r.out.info.info1.status)) {
635 } else if (NT_STATUS_EQUAL(r.out.info.info1.status, STATUS_MORE_ENTRIES)) {
636 cookie.length = r.out.info.info1.length1;
637 cookie.data = r.out.info.info1.data1;
640 printf("DsGetNT4ChangeLog failed - %s\n", nt_errstr(r.out.info.info1.status));
650 BOOL torture_rpc_dssync(struct torture_context *torture)
654 struct DsSyncTest *ctx;
656 mem_ctx = talloc_init("torture_rpc_dssync");
657 ctx = test_create_context(mem_ctx);
659 ret &= _test_DsBind(ctx, ctx->admin.credentials, &ctx->admin.drsuapi);
660 ret &= test_LDAPBind(ctx, ctx->admin.credentials, &ctx->admin.ldap);
661 ret &= test_GetInfo(ctx);
662 ret &= _test_DsBind(ctx, ctx->new_dc.credentials, &ctx->new_dc.drsuapi);
663 ret &= test_FetchData(ctx);
664 ret &= test_FetchNT4Data(ctx);