svn commit: samba r9670 - in branches/SOC/SAMBA_4_0/source/torture/rpc: .

brad at samba.org brad at samba.org
Sat Aug 27 00:30:11 GMT 2005


Author: brad
Date: 2005-08-27 00:30:11 +0000 (Sat, 27 Aug 2005)
New Revision: 9670

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9670

Log:
Added a patch from metze.

To showcase what i've learned today, i've created two new parameters which can be set at runtime, drsuapi:last_usn and drsuapi:partition.

drsuapi:last_usn takes an integer representing the USN of the last recieved replication update for a particular partition (uses the domain dn if drsuapi:parition isn't set). 

That value is passed in the DsGetNCChanges() call so that only info which has been updated since that point in time is returned. If this option is not set, 0 is used by default, and all updates for that partition are returned.

drsuapi:partition takes a string dn and uses that as the name of the AD partition to replicate.

Some debugging output was also added. 

Modified:
   branches/SOC/SAMBA_4_0/source/torture/rpc/dssync.c


Changeset:
Modified: branches/SOC/SAMBA_4_0/source/torture/rpc/dssync.c
===================================================================
--- branches/SOC/SAMBA_4_0/source/torture/rpc/dssync.c	2005-08-26 22:16:36 UTC (rev 9669)
+++ branches/SOC/SAMBA_4_0/source/torture/rpc/dssync.c	2005-08-27 00:30:11 UTC (rev 9670)
@@ -50,9 +50,12 @@
 */
 	const char *ldap_url;
 	const char *site_name;
+	
 	const char *domain_dn;
 	const char *config_dn;
 	const char *schema_dn;
+	const char *domaindns_dn;
+	const char *forestdns_dn;
 
 	/* what we need to do as 'Administrator' */
 	struct {
@@ -118,18 +121,18 @@
 	/* ctx->new_dc ...*/
 #define TEST_MACHINE_NAME "smbtorturedssync"
 	/*create machine account*/
-	/*ctx->new_dc.join = torture_join_domain(mem_ctx, TEST_MACHINE_NAME, lp_workgroup(), ACB_SVRTRUST, &new_dc_pass);*/
+/*	ctx->new_dc.join = torture_join_domain(mem_ctx, TEST_MACHINE_NAME, lp_workgroup(), ACB_SVRTRUST, &new_dc_pass);
 
 	ctx->new_dc.credentials = cli_credentials_init(ctx);
 	
 	cli_credentials_set_workstation(ctx->new_dc.credentials, TEST_MACHINE_NAME, CRED_SPECIFIED);
 	cli_credentials_set_domain(ctx->new_dc.credentials, lp_workgroup(), CRED_SPECIFIED);
 	cli_credentials_set_username(ctx->new_dc.credentials, TEST_MACHINE_NAME"$", CRED_SPECIFIED);
-/*	cli_credentials_set_password(ctx->new_dc.credentials, new_dc_pass, CRED_SPECIFIED);*/
+	cli_credentials_set_password(ctx->new_dc.credentials, new_dc_pass, CRED_SPECIFIED);
 	cli_credentials_set_secure_channel_type(ctx->new_dc.credentials, SEC_CHAN_BDC);
 
 	ctx->new_dc.invocation_id = GUID_random();
-
+*/
 	our_bind_info					= &ctx->new_dc.drsuapi.our_bind_info;
 	our_bind_info->length				= 28;
 	our_bind_info->info.info28.supported_extensions	= 0x1ffffb7f;
@@ -138,9 +141,6 @@
 	our_bind_info->info.info28.u1			= 508;
 	our_bind_info->info.info28.repl_epoch		= 0;
 
-#ifndef DRSUAPI_DS_BIND_GUID_W2K3
-#define DRSUAPI_DS_BIND_GUID_W2K3	( "6afab99c-6e26-464a-975f-f58f105218bc" )
-#endif
 	GUID_from_string(DRSUAPI_DS_BIND_GUID_W2K3, &ctx->new_dc.drsuapi.bind_guid);
 
 	ctx->new_dc.drsuapi.req.in.bind_guid		= &ctx->new_dc.drsuapi.bind_guid;
@@ -333,7 +333,8 @@
 	ctx->domain_dn = r.out.ctr.ctr1->array[0].result_name;
 	ctx->config_dn = talloc_asprintf(ctx, "CN=Configuration,%s", ctx->domain_dn);
 	ctx->schema_dn = talloc_asprintf(ctx, "CN=Schema,%s", ctx->config_dn);
-
+	ctx->domaindns_dn = talloc_asprintf(ctx, "DC=DomainDnsZones,%s", ctx->domain_dn);  
+	ctx->forestdns_dn =  talloc_asprintf(ctx, "DC=ForestDnsZones,%s", ctx->domain_dn);
 	ZERO_STRUCT(search);
 	search.in.dest_address = ctx->drsuapi_binding->host;
 	search.in.acct_control = -1;
@@ -699,7 +700,7 @@
 				ret = False;
 			}
 		} else {
-			printf("DsAddEntry failed: unexpsected level: %u\n",r.out.level);
+			printf("DsAddEntry failed: unexpected level: %u\n",r.out.level);
 			ret = False;
 		}
 	}
@@ -734,7 +735,9 @@
 {
 	NTSTATUS status;
 	BOOL ret = True;
-	int i;
+	int i, y = 0;
+	int tmp_usn = 0;
+	const char *partition = NULL;
 	struct drsuapi_DsGetNCChanges r;
 	struct drsuapi_DsReplicaObjectIdentifier nc;
 	struct GUID null_guid;
@@ -742,9 +745,10 @@
 	struct {
 		int32_t level;
 	} array[] = {
-		{	
+	/*	{	
 			5
 		},
+	*/	
 		{	
 			8
 		}
@@ -753,6 +757,12 @@
 	ZERO_STRUCT(null_guid);
 	ZERO_STRUCT(null_sid);
 
+	partition = lp_parm_string(-1, "drsuapi", "partition");
+	if (partition == NULL) {
+		partition = ctx->domain_dn;
+		printf("drsuapi:partition not specified, defaulting to %s.\n", ctx->domain_dn);
+	}
+	
 	for (i=0; i < ARRAY_SIZE(array); i++) {
 		printf("testing DsGetNCChanges level %d\n",
 			array[i].level);
@@ -764,7 +774,7 @@
 		case 5:
 			nc.guid	= null_guid;
 			nc.sid	= null_sid;
-			nc.dn	= ctx->domain_dn;
+			nc.dn	= partition; 
 
 			r.in.req.req5.destination_dsa_guid		= ctx->new_dc.invocation_id;
 			r.in.req.req5.source_dsa_guid			= null_guid;
@@ -794,8 +804,9 @@
 		case 8:
 			nc.guid	= null_guid;
 			nc.sid	= null_sid;
-			nc.dn	= ctx->domain_dn;
-
+			nc.dn	= partition; 
+			/*this can be other ad partitions, domain_dn, config_dn, schema_dn, domaindns_dn, forestdns_dn*/
+			
 			r.in.req.req8.destination_dsa_guid		= ctx->new_dc.invocation_id;
 			r.in.req.req8.source_dsa_guid			= null_guid;
 			r.in.req.req8.naming_context			= &nc;
@@ -827,19 +838,57 @@
 			break;
 		}
 		
-		status = dcerpc_drsuapi_DsGetNCChanges(ctx->new_dc.drsuapi.pipe, ctx, &r);
+		ZERO_STRUCT(r.out);
+		printf("Dumping AD partition: %s\n", nc.dn);
+		do {
+			/*r.in.req.req8.highwatermark = r.out.ctr.ctr6.new_highwatermark;*/
+		/*	
+			by setting r.in.req.req8.highwatermark.highest_usn to be the usn of the last update we received 
+			(r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn from the last run), 
+			we can get just the updates that have happened since then.
+		*/
+			
+			r.in.req.req8.highwatermark.tmp_highest_usn = 0;
+			tmp_usn = lp_parm_int(-1, "drsuapi", "last_usn", 0);
+			r.in.req.req8.highwatermark.highest_usn = tmp_usn;
+		
+			ZERO_STRUCT(r.out);
+
+
+DEBUG(0,("start[%d] tmp: %llu , hi: %llu\n",y,
+	r.in.req.req8.highwatermark.tmp_highest_usn,
+	r.in.req.req8.highwatermark.highest_usn));
+
+			status = dcerpc_drsuapi_DsGetNCChanges(ctx->new_dc.drsuapi.pipe, ctx, &r);
 				
-		if (!NT_STATUS_IS_OK(status)) {
-			const char *errstr = nt_errstr(status);
-			if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
-				errstr = dcerpc_errstr(ctx, ctx->new_dc.drsuapi.pipe->last_fault_code);
+			if (!NT_STATUS_IS_OK(status)) {
+				const char *errstr = nt_errstr(status);
+				if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
+					errstr = dcerpc_errstr(ctx, ctx->new_dc.drsuapi.pipe->last_fault_code);
+				}
+				printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr);
+				ret = False;
+			} else if (!W_ERROR_IS_OK(r.out.result)) {
+				printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result));
+				ret = False;
 			}
-			printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr);
-			ret = False;
-		} else if (!W_ERROR_IS_OK(r.out.result)) {
-			printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result));
-			ret = False;
-		}
+			
+DEBUG(0,("end[%d] tmp: %llu , hi: %llu\n",y,
+	r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn,
+	r.out.ctr.ctr6.new_highwatermark.highest_usn));
+
+			y++;
+			r.in.req.req8.highwatermark.tmp_highest_usn += 100000;
+			printf("The current highwatermark value (latest USN) = %llu. Temporary Maximum = %llu \n",
+				r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn, r.in.req.req8.highwatermark.tmp_highest_usn);
+	/*	} while (ret == True && r.out.level == 6 &&
+			r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn != r.out.ctr.ctr6.new_highwatermark.highest_usn);
+	*/	
+			printf("r.in.level = %d.\nr.out.level = %d.\n",
+				r.in.level, r.out.level);
+		} while (ret == True && r.out.level == 7);
+		printf("r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn: %llu.\n",
+			r.out.ctr.ctr6.new_highwatermark.tmp_highest_usn);
 	}
 
 	return ret;
@@ -850,12 +899,9 @@
 	BOOL ret = True;
 	TALLOC_CTX *mem_ctx;
 	struct DsSyncTest *ctx;
-	int rtn = 0;
 	
 	mem_ctx = talloc_init("torture_rpc_dssync");
 	ctx = test_create_context(mem_ctx);
-	rtn = ldb_connect(ctx->ldb_ctx,ctx->ldap_url,0,NULL);
-	printf("Connected to %s.\n",ctx->ldap_url);
 	
 	ret &= test_DsBind(ctx, ctx->admin.credentials, &ctx->admin.drsuapi);
 	ret &= test_LDAPBind(ctx, ctx->admin.credentials, &ctx->admin.ldap);



More information about the samba-cvs mailing list