s4-dsdb: don't cache the NTDS settings DN
authorAndrew Tridgell <tridge@samba.org>
Thu, 11 Aug 2011 06:29:24 +0000 (16:29 +1000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 12 Aug 2011 02:00:07 +0000 (04:00 +0200)
this DN can change due to a server rename, so we cannot cache it. It
is set by provision, but not anywhere else.

This seems to not have a large performance impact

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/dsdb/common/util.c

index f306748d0890cffad62eccc541b6390e8edb909a..3b287e36354d959fd227d20f7f3695f55bbc1179 100644 (file)
@@ -1252,9 +1252,9 @@ bool samdb_set_ntds_settings_dn(struct ldb_context *ldb, struct ldb_dn *ntds_set
        struct ldb_dn *ntds_settings_dn_new;
        struct ldb_dn *ntds_settings_dn_old;
 
-       /* see if we have a cached copy */
+       /* see if we have a forced copy from provision */
        ntds_settings_dn_old = talloc_get_type(ldb_get_opaque(ldb, 
-                                                             "cache.ntds_settings_dn"), struct ldb_dn);
+                                                             "forced.ntds_settings_dn"), struct ldb_dn);
 
        tmp_ctx = talloc_new(ldb);
        if (tmp_ctx == NULL) {
@@ -1266,8 +1266,8 @@ bool samdb_set_ntds_settings_dn(struct ldb_context *ldb, struct ldb_dn *ntds_set
                goto failed;
        }
 
-       /* cache the domain_sid in the ldb */
-       if (ldb_set_opaque(ldb, "cache.ntds_settings_dn", ntds_settings_dn_new) != LDB_SUCCESS) {
+       /* set the DN in the ldb to avoid lookups during provision */
+       if (ldb_set_opaque(ldb, "forced.ntds_settings_dn", ntds_settings_dn_new) != LDB_SUCCESS) {
                goto failed;
        }
 
@@ -1295,7 +1295,7 @@ struct ldb_dn *samdb_ntds_settings_dn(struct ldb_context *ldb)
        struct ldb_dn *settings_dn;
 
        /* see if we have a cached copy */
-       settings_dn = (struct ldb_dn *)ldb_get_opaque(ldb, "cache.ntds_settings_dn");
+       settings_dn = (struct ldb_dn *)ldb_get_opaque(ldb, "forced.ntds_settings_dn");
        if (settings_dn) {
                return settings_dn;
        }
@@ -1318,10 +1318,9 @@ struct ldb_dn *samdb_ntds_settings_dn(struct ldb_context *ldb)
 
        settings_dn = ldb_msg_find_attr_as_dn(ldb, tmp_ctx, root_res->msgs[0], "dsServiceName");
 
-       /* cache the domain_sid in the ldb */
-       if (ldb_set_opaque(ldb, "cache.ntds_settings_dn", settings_dn) != LDB_SUCCESS) {
-               goto failed;
-       }
+       /* note that we do not cache the DN here, as that would mean
+        * we could not handle server renames at runtime. Only
+        * provision sets up forced.ntds_settings_dn */
 
        talloc_steal(ldb, settings_dn);
        talloc_free(tmp_ctx);