From 278e44cf9f6e0ba0c4f45dd6e7127ab7936f3ed7 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 28 Sep 2011 14:36:00 +1000 Subject: s4-dsdb: simplify samdb_is_gc() we already have a function for returning the NTDS options --- source4/dsdb/common/util.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'source4/dsdb/common') diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c index 3a55a55306..106e261db9 100644 --- a/source4/dsdb/common/util.c +++ b/source4/dsdb/common/util.c @@ -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. */ -- cgit