summaryrefslogtreecommitdiff
path: root/source4/dsdb/kcc
diff options
context:
space:
mode:
authorAmitay Isaacs <amitay@gmail.com>2011-09-06 16:13:44 +1000
committerAndrew Bartlett <abartlet@samba.org>2011-09-07 12:16:40 +0200
commit2fc233b78f35e4bc5062869d77985567d61d0f8a (patch)
tree46ed71e863a2263c151af49cfa29c0cd5f39b766 /source4/dsdb/kcc
parent9bc4decc1cba701926fc8081c3903aac754a6f51 (diff)
downloadsamba-2fc233b78f35e4bc5062869d77985567d61d0f8a.tar.gz
samba-2fc233b78f35e4bc5062869d77985567d61d0f8a.tar.bz2
samba-2fc233b78f35e4bc5062869d77985567d61d0f8a.zip
s4-kcc: Fix the list of NCs for DRS replica information
AD DNS partitions (DomainDnsZones and ForestDnsZones) are listed under msDs-hasMasterNCs attribute for post-2003 windows servers.
Diffstat (limited to 'source4/dsdb/kcc')
-rw-r--r--source4/dsdb/kcc/kcc_drs_replica_info.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/source4/dsdb/kcc/kcc_drs_replica_info.c b/source4/dsdb/kcc/kcc_drs_replica_info.c
index 536684fff1..ab77fa0ba5 100644
--- a/source4/dsdb/kcc/kcc_drs_replica_info.c
+++ b/source4/dsdb/kcc/kcc_drs_replica_info.c
@@ -386,16 +386,28 @@ struct ncList {
static WERROR get_master_ncs(TALLOC_CTX *mem_ctx, struct ldb_context *samdb,
const char *ntds_guid_str, struct ncList **master_nc_list)
{
- const char *attrs[] = { "hasMasterNCs", NULL };
+ const char *post_2003_attrs[] = { "msDs-hasMasterNCs", NULL };
+ const char *pre_2003_attrs[] = { "hasMasterNCs", NULL };
struct ldb_result *res;
struct ncList *nc_list = NULL;
struct ncList *nc_list_elem;
int ret;
unsigned int i;
char *nc_str;
+ int is_level_post_2003;
+ /* In W2003 and greater, msDs-hasMasterNCs attribute lists the writable NC replicas */
+ is_level_post_2003 = 1;
ret = ldb_search(samdb, mem_ctx, &res, ldb_get_config_basedn(samdb),
- LDB_SCOPE_DEFAULT, attrs, "(objectguid=%s)", ntds_guid_str);
+ LDB_SCOPE_DEFAULT, post_2003_attrs, "(objectguid=%s)", ntds_guid_str);
+
+ if (ret != LDB_SUCCESS) {
+ DEBUG(0,(__location__ ": Failed objectguid search - %s\n", ldb_errstring(samdb)));
+
+ is_level_post_2003 = 0;
+ ret = ldb_search(samdb, mem_ctx, &res, ldb_get_config_basedn(samdb),
+ LDB_SCOPE_DEFAULT, pre_2003_attrs, "(objectguid=%s)", ntds_guid_str);
+ }
if (ret != LDB_SUCCESS) {
DEBUG(0,(__location__ ": Failed objectguid search - %s\n", ldb_errstring(samdb)));
@@ -408,9 +420,15 @@ static WERROR get_master_ncs(TALLOC_CTX *mem_ctx, struct ldb_context *samdb,
}
for (i = 0; i < res->count; i++) {
- struct ldb_message_element *msg_elem = ldb_msg_find_element(res->msgs[i], "hasMasterNCs");
+ struct ldb_message_element *msg_elem;
unsigned int k;
+ if (is_level_post_2003) {
+ msg_elem = ldb_msg_find_element(res->msgs[i], "msDs-hasMasterNCs");
+ } else {
+ msg_elem = ldb_msg_find_element(res->msgs[i], "hasMasterNCs");
+ }
+
if (!msg_elem || msg_elem->num_values == 0) {
DEBUG(0,(__location__ ": Failed: Attribute hasMasterNCs not found - %s\n",
ldb_errstring(samdb)));