s4-dsdb: isGlobalCatalogReady should be shown by default
[ira/wip.git] / source4 / dsdb / samdb / ldb_modules / rootdse.c
index a8e08ec3ad58638d79aa28d264377dd9e9e396c0..9d2b8cdc5b848f56f15807435073a541c51cda0b 100644 (file)
@@ -273,7 +273,7 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
 
        if (schema && do_attribute_explicit(attrs, "dsSchemaPrefixCount")) {
                if (ldb_msg_add_fmt(msg, "dsSchemaPrefixCount", 
-                                   "%u", schema->num_prefixes) != 0) {
+                                   "%u", schema->prefixmap->length) != 0) {
                        goto failed;
                }
        }
@@ -322,10 +322,9 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
                }
        }
 
-       if (priv && do_attribute(attrs, "domainFunctionality")
-           && (val = talloc_get_type(ldb_get_opaque(ldb, "domainFunctionality"), int))) {
+       if (priv && do_attribute(attrs, "domainFunctionality")) {
                if (ldb_msg_add_fmt(msg, "domainFunctionality", 
-                                   "%d", *val) != 0) {
+                                   "%d", dsdb_functional_level(ldb)) != 0) {
                        goto failed;
                }
        }
@@ -365,6 +364,18 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
                }
        }
 
+       if (do_attribute(attrs, "isGlobalCatalogReady")) {
+               /* MS-ADTS 3.1.1.3.2.10
+                  Note, we should only return true here is we have
+                  completed at least one synchronisation. As both
+                  provision and vampire do a full sync, this means we
+                  can return true is the gc bit is set in the NTDSDSA
+                  options */
+               if (ldb_msg_add_fmt(msg, "isGlobalCatalogReady",
+                                   "%s", samdb_is_gc(ldb)?"TRUE":"FALSE") != 0) {
+                       goto failed;
+               }
+       }
 
        /* TODO: lots more dynamic attributes should be added here */
 
@@ -718,13 +729,13 @@ static int rootdse_modify(struct ldb_module *module, struct ldb_request *req)
        }
        
        talloc_free(ext_res);
-       return ldb_request_done(req, ret);
+       return ldb_module_done(req, NULL, NULL, ret);
 }
 
 _PUBLIC_ const struct ldb_module_ops ldb_rootdse_module_ops = {
-       .name                   = "rootdse",
+       .name           = "rootdse",
        .init_context   = rootdse_init,
        .search         = rootdse_search,
-       .request                = rootdse_request,
+       .request        = rootdse_request,
        .modify         = rootdse_modify
 };