s4-dsdb: simplify samdb_is_gc()
authorAndrew Tridgell <tridge@samba.org>
Wed, 28 Sep 2011 04:36:00 +0000 (14:36 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 4 Oct 2011 04:08:57 +0000 (15:08 +1100)
we already have a function for returning the NTDS options

source4/dsdb/common/util.c

index 3a55a553068026cc4498f58e1d25c9c8c2e60850..106e261db978561874d586f30e00b7b36ade01f9 100644 (file)
@@ -1860,37 +1860,11 @@ failed:
 */
 bool samdb_is_gc(struct ldb_context *ldb)
 {
-       const char *attrs[] = { "options", NULL };
        uint32_t options;
-       int ret;
-       struct ldb_result *res;
-       TALLOC_CTX *tmp_ctx;
-
-       tmp_ctx = talloc_new(ldb);
-       if (tmp_ctx == NULL) {
-               DEBUG(1, ("talloc_new failed in samdb_is_pdc"));
-               return false;
-       }
-
-       /* Query cn=ntds settings,.... */
-       ret = ldb_search(ldb, tmp_ctx, &res, samdb_ntds_settings_dn(ldb), LDB_SCOPE_BASE, attrs, NULL);
-       if (ret != LDB_SUCCESS) {
-               talloc_free(tmp_ctx);
-               return false;
-       }
-       if (res->count != 1) {
-               talloc_free(tmp_ctx);
+       if (samdb_ntds_options(ldb, &options) != LDB_SUCCESS) {
                return false;
        }
-
-       options = ldb_msg_find_attr_as_uint(res->msgs[0], "options", 0);
-       talloc_free(tmp_ctx);
-
-       /* if options attribute has the 0x00000001 flag set, then enable the global catlog */
-       if (options & DS_NTDSDSA_OPT_IS_GC) {
-               return true;
-       }
-       return false;
+       return (options & DS_NTDSDSA_OPT_IS_GC) != 0;
 }
 
 /* Find a domain object in the parents of a particular DN.  */