[RESEND PATCH] DsBind and DsGetDomainControllerInfo to return 2k8 structs complete

Void voidswitch at gmail.com
Mon Apr 18 21:20:27 UTC 2016


I'll get this right eventually.

Thanks
Dirk
-------------- next part --------------
From 9479edf087d791df4d37afdbf470526ab65ddefa Mon Sep 17 00:00:00 2001
From: root <voidswitch at gmail.com>
Date: Mon, 18 Apr 2016 22:59:52 +0200
Subject: [PATCH] If running with functional level 2k8, some tools require
 DsGetDomainControllerInfo level 3.

  * nltest /dclist:domain
  * w32tm /monitor
  * Group Policy Editor Infrastructure identification

Two steps are required.

  * DsBind should respond with DsBindInfo48 and DRSUAPI_SUPPORTED_EXTENSION_LH_BETA2 set
  * DsGetDomainControllerInfo should return DsGetDCInfo3 if level 3 is requested.

This Patch implements DsGetDomainControllerInfo level 3. The only difference to level 2
seems to be is_rodc.

To advertise this functionality, this patch implements DsBind for DsBindInfo48.
---
 source4/rpc_server/drsuapi/dcesrv_drsuapi.c | 295 ++++++++++++++++++++++------
 source4/rpc_server/drsuapi/dcesrv_drsuapi.h |   4 +-
 2 files changed, 234 insertions(+), 65 deletions(-)

diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
index 3fe6c13..95db116 100644
--- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
+++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.c
@@ -56,10 +56,12 @@ static WERROR dcesrv_drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_C
 	struct drsuapi_bind_state *b_state;
 	struct dcesrv_handle *handle;
 	struct drsuapi_DsBindInfoCtr *bind_info;
-	struct GUID site_guid;
-	struct ldb_result *site_res;
-	struct ldb_dn *server_site_dn;
+	struct drsuapi_DsBindInfoCtr *local_info;
+	struct GUID site_guid, config_guid;
+	struct ldb_result *site_res, *config_res;
+	struct ldb_dn *server_site_dn, *config_dn;
 	static const char *site_attrs[] = { "objectGUID", NULL };
+	static const char *config_attrs[] = { "objectGUID", NULL };
 	struct ldb_result *ntds_res;
 	struct ldb_dn *ntds_dn;
 	static const char *ntds_attrs[] = { "ms-DS-ReplicationEpoch", NULL };
@@ -166,73 +168,133 @@ static WERROR dcesrv_drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_C
 	 * store the clients bind_info
 	 */
 	if (r->in.bind_info) {
-		switch (r->in.bind_info->length) {
-		case 24: {
-			struct drsuapi_DsBindInfo24 *info24;
-			info24 = &r->in.bind_info->info.info24;
-			b_state->remote_info28.supported_extensions	= info24->supported_extensions;
-			b_state->remote_info28.site_guid		= info24->site_guid;
-			b_state->remote_info28.pid			= info24->pid;
-			b_state->remote_info28.repl_epoch		= 0;
-			break;
-		}
-		case 28:
-			b_state->remote_info28 = r->in.bind_info->info.info28;
-			break;
-		}
+		b_state->remote_info = r->in.bind_info;
 	}
 
 	/*
-	 * fill in our local bind info 28
+	 * fill in our local bind info
 	 */
-	b_state->local_info28.supported_extensions	= 0;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_BASE;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2;
+    local_info = talloc_zero(mem_ctx, struct drsuapi_DsBindInfoCtr);
+    W_ERROR_HAVE_NO_MEMORY(local_info);
+
+    /*
+     * fill 28 or 48 info, depends on request
+     */
+    if (r->in.bind_info->length < 48) {
+
+        local_info->length = 28;
+        local_info->info.info28.supported_extensions	 = 0;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_BASE;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2;
 #if 0 /* we don't support MSZIP compression (only decompression) */
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS;
 #endif
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V5;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7;
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V5;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT;
 #if 0 /* we don't support XPRESS compression yet */
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS;
 #endif
-	b_state->local_info28.supported_extensions	|= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V10;
-	b_state->local_info28.site_guid			= site_guid;
-	b_state->local_info28.pid			= pid;
-	b_state->local_info28.repl_epoch		= repl_epoch;
-
-	/*
-	 * allocate the return bind_info
-	 */
-	bind_info = talloc_zero(mem_ctx, struct drsuapi_DsBindInfoCtr);
-	W_ERROR_HAVE_NO_MEMORY(bind_info);
-
-	bind_info->length	= 28;
-	bind_info->info.info28	= b_state->local_info28;
+        local_info->info.info28.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V10;
+        
+        local_info->info.info28.site_guid                = site_guid;
+        local_info->info.info28.pid                      = pid;
+        local_info->info.info28.repl_epoch               = repl_epoch;
+
+    } else {
+
+        local_info->length = 48;
+        local_info->info.info48.supported_extensions	 = 0;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_BASE;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2;
+#if 0 /* we don't support MSZIP compression (only decompression) */
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS;
+#endif
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V5;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7;
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT;
+#if 0 /* we don't support XPRESS compression yet */
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS;
+#endif
+        local_info->info.info48.supported_extensions	 |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V10;
+        
+        local_info->info.info48.site_guid                = site_guid;
+        local_info->info.info48.pid                      = pid;
+        local_info->info.info48.repl_epoch               = repl_epoch;
+        
+        local_info->info.info48.supported_extensions_ext = 0;
+        local_info->info.info48.supported_extensions_ext |= DRSUAPI_SUPPORTED_EXTENSION_LH_BETA2;
+        
+        /*
+         * find out the guid of our own site
+         */
+        config_dn = ldb_get_config_basedn(b_state->sam_ctx);
+        W_ERROR_HAVE_NO_MEMORY(config_dn);
+        
+        ret = ldb_search(b_state->sam_ctx, mem_ctx, &config_res,
+                     config_dn, LDB_SCOPE_BASE, site_attrs,
+                     "(objectClass=*)");
+        if (ret != LDB_SUCCESS) {
+            return WERR_DS_DRA_INTERNAL_ERROR;
+        }
+        if (config_res->count != 1) {
+            return WERR_DS_DRA_INTERNAL_ERROR;
+        }
+        config_guid = samdb_result_guid(config_res->msgs[0], "objectGUID");
+        local_info->info.info48.config_dn_guid = config_guid;
+    }
+
+	// set local_info
+	b_state->local_info = local_info;
+
+	// set bind_info
+	bind_info		    = local_info;
 
 	/*
 	 * allocate a bind handle
@@ -244,7 +306,7 @@ static WERROR dcesrv_drsuapi_DsBind(struct dcesrv_call_state *dce_call, TALLOC_C
 	/*
 	 * prepare reply
 	 */
-	r->out.bind_info = bind_info;
+	r->out.bind_info    = bind_info;
 	*r->out.bind_handle = handle->wire_handle;
 
 	return WERR_OK;
@@ -580,6 +642,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
 
 	struct drsuapi_DsGetDCInfoCtr1 *ctr1;
 	struct drsuapi_DsGetDCInfoCtr2 *ctr2;
+	struct drsuapi_DsGetDCInfoCtr3 *ctr3;
 
 	int ret;
 	unsigned int i;
@@ -596,6 +659,7 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
 		attrs = attrs_1;
 		break;
 	case 2:
+	case 3:
 		attrs = attrs_2;
 		break;
 	default:
@@ -781,6 +845,111 @@ static WERROR dcesrv_drsuapi_DsGetDomainControllerInfo_1(struct drsuapi_bind_sta
 
 		}
 		break;
+	case 3:
+		ctr3 = &r->out.ctr->ctr3;
+		ctr3->count = res->count;
+		ctr3->array = talloc_zero_array(mem_ctx, 
+						 struct drsuapi_DsGetDCInfo3, 
+						 res->count);
+		for (i=0; i < res->count; i++) {
+			struct ldb_dn *domain_dn;
+			struct ldb_result *res_domain;
+			struct ldb_result *res_account;
+			struct ldb_dn *ntds_dn = ldb_dn_copy(mem_ctx, res->msgs[i]->dn);
+			struct ldb_result *res_ntds;
+			struct ldb_dn *site_dn = ldb_dn_copy(mem_ctx, res->msgs[i]->dn);
+			struct ldb_result *res_site;
+			bool is_rodc;
+			struct ldb_dn *ref_dn
+				= ldb_msg_find_attr_as_dn(b_state->sam_ctx, 
+							  mem_ctx, res->msgs[i], 
+							  "serverReference");
+
+			if (!ntds_dn || !ldb_dn_add_child_fmt(ntds_dn, "CN=NTDS Settings")) {
+				return WERR_NOMEM;
+			}
+
+			/* Format is cn=<NETBIOS name>,cn=Servers,cn=<site>,cn=sites.... */
+			if (!site_dn || !ldb_dn_remove_child_components(site_dn, 2)) {
+				return WERR_NOMEM;
+			}
+
+			ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_ntds, ntds_dn,
+						 LDB_SCOPE_BASE, attrs_ntds, "objectClass=nTDSDSA");
+			if (ret == LDB_SUCCESS && res_ntds->count == 1) {
+				ctr3->array[i].is_gc
+					= (ldb_msg_find_attr_as_uint(res_ntds->msgs[0], "options", 0) & DS_NTDSDSA_OPT_IS_GC);
+				ctr3->array[i].ntds_guid 
+					= samdb_result_guid(res_ntds->msgs[0], "objectGUID");
+				ctr3->array[i].ntds_dn = ldb_dn_get_linearized(res_ntds->msgs[0]->dn);
+			}
+			if ((ret != LDB_SUCCESS) && (ret != LDB_ERR_NO_SUCH_OBJECT)) {
+				DEBUG(5, ("warning: searching for NTDS DN %s failed: %s\n", 
+					  ldb_dn_get_linearized(ntds_dn), ldb_errstring(b_state->sam_ctx)));
+			}
+
+			ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_site, site_dn,
+						 LDB_SCOPE_BASE, attrs_site, "objectClass=site");
+			if (ret == LDB_SUCCESS && res_site->count == 1) {
+				ctr3->array[i].site_guid 
+					= samdb_result_guid(res_site->msgs[0], "objectGUID");
+				ctr3->array[i].site_dn = ldb_dn_get_linearized(res_site->msgs[0]->dn);
+			}
+			if ((ret != LDB_SUCCESS) && (ret != LDB_ERR_NO_SUCH_OBJECT)) {
+				DEBUG(5, ("warning: searching for site DN %s failed: %s\n", 
+					  ldb_dn_get_linearized(site_dn), ldb_errstring(b_state->sam_ctx)));
+			}
+
+			ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_account, ref_dn,
+						 LDB_SCOPE_BASE, attrs_account_2, "objectClass=computer");
+			if (ret == LDB_SUCCESS && res_account->count == 1) {
+				const char *errstr;
+				ctr3->array[i].dns_name
+					= ldb_msg_find_attr_as_string(res_account->msgs[0], "dNSHostName", NULL);
+				ctr3->array[i].netbios_name
+					= ldb_msg_find_attr_as_string(res_account->msgs[0], "cn", NULL);
+				ctr3->array[i].computer_dn = ldb_dn_get_linearized(res_account->msgs[0]->dn);
+				ctr3->array[i].computer_guid 
+					= samdb_result_guid(res_account->msgs[0], "objectGUID");
+
+				/* Determine if this is the PDC */
+				ret = samdb_search_for_parent_domain(b_state->sam_ctx, 
+								     mem_ctx, res_account->msgs[0]->dn,
+								     &domain_dn, &errstr);
+				
+				if (ret == LDB_SUCCESS) {
+					ret = ldb_search(b_state->sam_ctx, mem_ctx, &res_domain, domain_dn,
+								 LDB_SCOPE_BASE, attrs_none, "fSMORoleOwner=%s",
+								 ldb_dn_get_linearized(ntds_dn));
+					if (ret == LDB_SUCCESS && res_domain->count == 1) {
+						ctr3->array[i].is_pdc = true;
+					}
+					if ((ret != LDB_SUCCESS) && (ret != LDB_ERR_NO_SUCH_OBJECT)) {
+						DEBUG(5, ("warning: searching for domain DN %s failed: %s\n", 
+							  ldb_dn_get_linearized(domain_dn), ldb_errstring(b_state->sam_ctx)));
+					}
+				}
+			}
+			if ((ret != LDB_SUCCESS) && (ret != LDB_ERR_NO_SUCH_OBJECT)) {
+				DEBUG(5, ("warning: searching for computer account DN %s failed: %s\n", 
+					  ldb_dn_get_linearized(ref_dn), ldb_errstring(b_state->sam_ctx)));
+			}
+
+			/* Look at server DN and extract site component */
+			ctr3->array[i].site_name = result_site_name(res->msgs[i]->dn);
+			ctr3->array[i].server_dn = ldb_dn_get_linearized(res->msgs[i]->dn);
+			ctr3->array[i].server_guid 
+				= samdb_result_guid(res->msgs[i], "objectGUID");
+
+			ctr3->array[i].is_enabled = true;
+
+			// Find if rodc
+			ret = samdb_is_rodc(b_state->sam_ctx, &ctr3->array[i].server_guid, &is_rodc);
+			if (ret == LDB_SUCCESS && is_rodc) {
+				ctr3->array[i].is_rodc = true;
+			}
+		}
+		break;
 	default:
 		return WERR_UNKNOWN_LEVEL;
 	}
diff --git a/source4/rpc_server/drsuapi/dcesrv_drsuapi.h b/source4/rpc_server/drsuapi/dcesrv_drsuapi.h
index 49d1d42..d376f7e 100644
--- a/source4/rpc_server/drsuapi/dcesrv_drsuapi.h
+++ b/source4/rpc_server/drsuapi/dcesrv_drsuapi.h
@@ -33,8 +33,8 @@ struct drsuapi_bind_state {
 	struct ldb_context *sam_ctx;
 	struct ldb_context *sam_ctx_system;
 	struct GUID remote_bind_guid;
-	struct drsuapi_DsBindInfo28 remote_info28;
-	struct drsuapi_DsBindInfo28 local_info28;
+	struct drsuapi_DsBindInfoCtr *remote_info;
+	struct drsuapi_DsBindInfoCtr *local_info;
 	struct drsuapi_getncchanges_state *getncchanges_state;
 };
 
-- 
2.1.4



More information about the samba-technical mailing list