s4-kcc: added service->am_rodc
authorAndrew Tridgell <tridge@samba.org>
Wed, 22 Sep 2010 18:18:04 +0000 (11:18 -0700)
committerAndrew Tridgell <tridge@samba.org>
Thu, 23 Sep 2010 07:17:57 +0000 (07:17 +0000)
use a rodc flag on the service instead of calling samdb_rodc each time

source4/dsdb/kcc/kcc_periodic.c
source4/dsdb/kcc/kcc_service.c
source4/dsdb/kcc/kcc_service.h
source4/dsdb/kcc/kcc_topology.c

index c396912aa379278875488451288eac98790dff83..bfb6bdc3a50182b8f61cb93b941952c2c86130fa 100644 (file)
@@ -307,9 +307,12 @@ NTSTATUS kccsrv_simple_update(struct kccsrv_service *s, TALLOC_CTX *mem_ctx)
                r1->source_dsa_obj_guid      = ntds_guid;
                r1->source_dsa_invocation_id = invocation_id;
                r1->replica_flags            = 
-                       DRSUAPI_DRS_WRIT_REP |
                        DRSUAPI_DRS_INIT_SYNC |
-                       DRSUAPI_DRS_PER_SYNC;
+                       DRSUAPI_DRS_PER_SYNC |
+                       DRSUAPI_DRS_ADD_REF;
+               if (!s->am_rodc) {
+                       r1->replica_flags |= DRSUAPI_DRS_WRIT_REP;
+               }
                memset(r1->schedule, 0x11, sizeof(r1->schedule));
 
                dsa_conn->servers = talloc_realloc(dsa_conn, dsa_conn->servers,
index 9bacca9bc798402b1f4f87aed048e1c8b8eff6b2..0d78443d98a1462755ffe5f16ed0448a490b1282 100644 (file)
@@ -67,6 +67,11 @@ static WERROR kccsrv_connect_samdb(struct kccsrv_service *service, struct loadpa
 
        service->ntds_guid = *ntds_guid;
 
+       if (samdb_rodc(service->samdb, &service->am_rodc) != LDB_SUCCESS) {
+               DEBUG(0,(__location__ ": Failed to determine RODC status\n"));
+               return WERR_DS_UNAVAILABLE;
+       }
+
        return WERR_OK;
 }
 
index 64c78a361f1eeb14fc34ca569cb4d393eb3321a5..f56488560abe5c2785a1da6e115cd54c384150ab 100644 (file)
@@ -80,6 +80,8 @@ struct kccsrv_service {
        } periodic;
 
        time_t last_deleted_check;
+
+       bool am_rodc;
 };
 
 struct kcc_connection_list;
index cb32a0bf81c3fee3bebbafb352f4386cfc092d8f..fbf2885ad8a758244301372dc170d54984a33ba4 100644 (file)
@@ -1077,7 +1077,6 @@ static NTSTATUS kcctpl_get_all_bridgehead_dcs(struct kccsrv_service *service,
        const char * const dc_attrs[] = { "objectGUID", "options", NULL };
        struct ldb_message_element *el;
        unsigned int i;
-       bool rodc;
        const char *transport_name, *transport_address_attr;
        uint64_t site_opts;
 
@@ -1156,14 +1155,6 @@ static NTSTATUS kcctpl_get_all_bridgehead_dcs(struct kccsrv_service *service,
 
        el = ldb_msg_find_element(transport, "bridgeheadServerListBL");
 
-       ret = samdb_rodc(ldb, &rodc);
-       if (ret != LDB_SUCCESS) {
-               DEBUG(1, (__location__ ": unable to tell if we are an RODC: %s\n",
-                         ldb_strerror(ret)));
-               talloc_free(tmp_ctx);
-               return NT_STATUS_INTERNAL_DB_CORRUPTION;
-       }
-
        transport_name = samdb_result_string(transport, "name", NULL);
        if (!transport_name) {
                DEBUG(1, (__location__ ": failed to find name attribute of "
@@ -3151,7 +3142,7 @@ static NTSTATUS kcctpl_create_connections(struct kccsrv_service *service,
                                          bool *_found_failed_dcs,
                                          bool *_connected)
 {
-       bool connected, found_failed_dcs, partial_replica_okay, rodc;
+       bool connected, found_failed_dcs, partial_replica_okay;
        NTSTATUS status;
        struct ldb_message *site;
        TALLOC_CTX *tmp_ctx;
@@ -3231,14 +3222,6 @@ static NTSTATUS kcctpl_create_connections(struct kccsrv_service *service,
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
        }
 
-       ret = samdb_rodc(ldb, &rodc);
-       if (ret != LDB_SUCCESS) {
-               DEBUG(1, (__location__ ": Unable to tell if we are an RODC: %s\n",
-                         ldb_strerror(ret)));
-               talloc_free(tmp_ctx);
-               return NT_STATUS_INTERNAL_DB_CORRUPTION;
-       }
-
        for (i = 0; i < st_edge_list.count; i++) {
                struct kcctpl_multi_edge *edge;
                struct GUID other_site_id;
@@ -3309,7 +3292,7 @@ static NTSTATUS kcctpl_create_connections(struct kccsrv_service *service,
                        return status;
                }
 
-               if (rodc) {
+               if (service->am_rodc) {
                        /* TODO: l_bridgehad = nTDSDSA of local DC */
                } else {
                        status = kcctpl_get_bridgehead_dc(service, tmp_ctx,