s4-rodc: ensure we load replicated partitions for RODCs
authorAndrew Tridgell <tridge@samba.org>
Thu, 6 Oct 2011 00:14:13 +0000 (11:14 +1100)
committerAndrew Tridgell <tridge@samba.org>
Thu, 6 Oct 2011 03:34:21 +0000 (14:34 +1100)
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/dsdb/repl/drepl_partitions.c
source4/dsdb/repl/drepl_service.h

index 7c5424555a91f3c5c3f6b98bb96d057ca08d5f4d..f2d4b1321bfa95caa8807e7a50fc141700886577 100644 (file)
 #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 && i<el->num_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; i<el->num_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 && i<el->num_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);
index 98564529bb7d7463a964f9527bfc19d161cc0bd2..6daf82d9f4eb0da7bffd03de4e6308dee6f0f16f 100644 (file)
@@ -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 *,