From 2a2deeb3b43dcb11f2b604bdd20c1183e87522bb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Oct 2011 11:14:13 +1100 Subject: s4-rodc: ensure we load replicated partitions for RODCs Pair-Programmed-With: Andrew Bartlett --- source4/dsdb/repl/drepl_partitions.c | 79 ++++++++++++++++-------------------- source4/dsdb/repl/drepl_service.h | 2 +- 2 files changed, 35 insertions(+), 46 deletions(-) (limited to 'source4') diff --git a/source4/dsdb/repl/drepl_partitions.c b/source4/dsdb/repl/drepl_partitions.c index 7c5424555a..f2d4b1321b 100644 --- a/source4/dsdb/repl/drepl_partitions.c +++ b/source4/dsdb/repl/drepl_partitions.c @@ -34,11 +34,15 @@ #include "param/param.h" #include "dsdb/common/util.h" +/* + load the partitions list based on replicated NC attributes in our + NTDSDSA object + */ WERROR dreplsrv_load_partitions(struct dreplsrv_service *s) { WERROR status; - static const char *attrs[] = { "hasMasterNCs", "hasPartialReplicaNCs", NULL }; - unsigned int i; + static const char *attrs[] = { "hasMasterNCs", "hasPartialReplicaNCs", "msDS-HasFullReplicaNCs", NULL }; + unsigned int a; int ret; TALLOC_CTX *tmp_ctx; struct ldb_result *res; @@ -62,57 +66,42 @@ WERROR dreplsrv_load_partitions(struct dreplsrv_service *s) return WERR_DS_DRA_INTERNAL_ERROR; } - el = ldb_msg_find_element(res->msgs[0], "hasMasterNCs"); - - for (i=0; el && inum_values; i++) { - struct ldb_dn *pdn; - struct dreplsrv_partition *p; + for (a=0; attrs[a]; a++) { + int i; - pdn = ldb_dn_from_ldb_val(tmp_ctx, s->samdb, &el->values[i]); - if (pdn == NULL) { - talloc_free(tmp_ctx); - return WERR_DS_DRA_INTERNAL_ERROR; + el = ldb_msg_find_element(res->msgs[0], attrs[a]); + if (el == NULL) { + continue; } - if (!ldb_dn_validate(pdn)) { - return WERR_DS_DRA_INTERNAL_ERROR; - } - - p = talloc_zero(s, struct dreplsrv_partition); - W_ERROR_HAVE_NO_MEMORY(p); - - p->dn = talloc_steal(p, pdn); - p->service = s; + for (i=0; inum_values; i++) { + struct ldb_dn *pdn; + struct dreplsrv_partition *p; + + pdn = ldb_dn_from_ldb_val(tmp_ctx, s->samdb, &el->values[i]); + if (pdn == NULL) { + talloc_free(tmp_ctx); + return WERR_DS_DRA_INTERNAL_ERROR; + } + if (!ldb_dn_validate(pdn)) { + return WERR_DS_DRA_INTERNAL_ERROR; + } - DLIST_ADD(s->partitions, p); + p = talloc_zero(s, struct dreplsrv_partition); + W_ERROR_HAVE_NO_MEMORY(p); - DEBUG(2, ("dreplsrv_partition[%s] loaded\n", ldb_dn_get_linearized(p->dn))); - } + p->dn = talloc_steal(p, pdn); + p->service = s; - el = ldb_msg_find_element(res->msgs[0], "hasPartialReplicaNCs"); + if (strcasecmp(attrs[a], "hasPartialReplicaNCs") == 0) { + p->partial_replica = true; + } else if (strcasecmp(attrs[a], "msDS-HasFullReplicaNCs") == 0) { + p->rodc_replica = true; + } - for (i=0; el && inum_values; i++) { - struct ldb_dn *pdn; - struct dreplsrv_partition *p; + DLIST_ADD(s->partitions, p); - pdn = ldb_dn_from_ldb_val(tmp_ctx, s->samdb, &el->values[i]); - if (pdn == NULL) { - talloc_free(tmp_ctx); - return WERR_DS_DRA_INTERNAL_ERROR; - } - if (!ldb_dn_validate(pdn)) { - return WERR_DS_DRA_INTERNAL_ERROR; + DEBUG(2, ("dreplsrv_partition[%s] loaded\n", ldb_dn_get_linearized(p->dn))); } - - p = talloc_zero(s, struct dreplsrv_partition); - W_ERROR_HAVE_NO_MEMORY(p); - - p->dn = talloc_steal(p, pdn); - p->partial_replica = true; - p->service = s; - - DLIST_ADD(s->partitions, p); - - DEBUG(2, ("dreplsrv_partition[%s] loaded (partial replica)\n", ldb_dn_get_linearized(p->dn))); } talloc_free(tmp_ctx); diff --git a/source4/dsdb/repl/drepl_service.h b/source4/dsdb/repl/drepl_service.h index 98564529bb..6daf82d9f4 100644 --- a/source4/dsdb/repl/drepl_service.h +++ b/source4/dsdb/repl/drepl_service.h @@ -106,8 +106,8 @@ struct dreplsrv_partition { */ struct dreplsrv_partition_source_dsa *notifies; - bool incoming_only; bool partial_replica; + bool rodc_replica; }; typedef void (*dreplsrv_extended_callback_t)(struct dreplsrv_service *, -- cgit