diff options
author | Andrew Tridgell <tridge@samba.org> | 2011-09-22 09:49:54 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-09-22 10:00:48 +1000 |
commit | 783ff68628fee6d5681b3a9abd80b74a78588926 (patch) | |
tree | e7f41cf6be34ec9b76ba5c92712e4d6a8a360b03 | |
parent | 00ef18f19c39bf5083939ac79854bcd1ccc7cef7 (diff) | |
download | samba-783ff68628fee6d5681b3a9abd80b74a78588926.tar.gz samba-783ff68628fee6d5681b3a9abd80b74a78588926.tar.bz2 samba-783ff68628fee6d5681b3a9abd80b74a78588926.zip |
s4-kcc: return partial replica NCs in drs showrepl
the showrepl operation should return all our replicated NCs, including
partial replicas
-rw-r--r-- | source4/dsdb/kcc/kcc_drs_replica_info.c | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/source4/dsdb/kcc/kcc_drs_replica_info.c b/source4/dsdb/kcc/kcc_drs_replica_info.c index ab77fa0ba5..8eb72662b7 100644 --- a/source4/dsdb/kcc/kcc_drs_replica_info.c +++ b/source4/dsdb/kcc/kcc_drs_replica_info.c @@ -386,8 +386,9 @@ 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 *post_2003_attrs[] = { "msDs-hasMasterNCs", NULL }; - const char *pre_2003_attrs[] = { "hasMasterNCs", NULL }; + const char *post_2003_attrs[] = { "msDs-hasMasterNCs", "hasPartialReplicaNCs", NULL }; + const char *pre_2003_attrs[] = { "hasMasterNCs", "hasPartialReplicaNCs", NULL }; + const char **attrs = post_2003_attrs; struct ldb_result *res; struct ncList *nc_list = NULL; struct ncList *nc_list_elem; @@ -405,6 +406,7 @@ static WERROR get_master_ncs(TALLOC_CTX *mem_ctx, struct ldb_context *samdb, DEBUG(0,(__location__ ": Failed objectguid search - %s\n", ldb_errstring(samdb))); is_level_post_2003 = 0; + attrs = post_2003_attrs; ret = ldb_search(samdb, mem_ctx, &res, ldb_get_config_basedn(samdb), LDB_SCOPE_DEFAULT, pre_2003_attrs, "(objectguid=%s)", ntds_guid_str); } @@ -421,32 +423,26 @@ 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; - unsigned int k; + unsigned int k, a; - 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))); - return WERR_INTERNAL_ERROR; - } + for (a=0; attrs[a]; a++) { + msg_elem = ldb_msg_find_element(res->msgs[i], attrs[a]); + if (!msg_elem || msg_elem->num_values == 0) { + continue; + } - for (k = 0; k < msg_elem->num_values; k++) { - /* copy the string on msg_elem->values[k]->data to nc_str */ - nc_str = talloc_strndup(mem_ctx, (char *)msg_elem->values[k].data, msg_elem->values[k].length); - W_ERROR_HAVE_NO_MEMORY(nc_str); + for (k = 0; k < msg_elem->num_values; k++) { + /* copy the string on msg_elem->values[k]->data to nc_str */ + nc_str = talloc_strndup(mem_ctx, (char *)msg_elem->values[k].data, msg_elem->values[k].length); + W_ERROR_HAVE_NO_MEMORY(nc_str); - nc_list_elem = talloc_zero(mem_ctx, struct ncList); - W_ERROR_HAVE_NO_MEMORY(nc_list_elem); - nc_list_elem->dn = ldb_dn_new(mem_ctx, samdb, nc_str); - W_ERROR_HAVE_NO_MEMORY(nc_list_elem); - DLIST_ADD(nc_list, nc_list_elem); + nc_list_elem = talloc_zero(mem_ctx, struct ncList); + W_ERROR_HAVE_NO_MEMORY(nc_list_elem); + nc_list_elem->dn = ldb_dn_new(mem_ctx, samdb, nc_str); + W_ERROR_HAVE_NO_MEMORY(nc_list_elem); + DLIST_ADD(nc_list, nc_list_elem); + } } - } *master_nc_list = nc_list; |