]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4-dsdb: Use samdb_reference_dn_is_our_ntdsa()
authorAndrew Bartlett <abartlet@samba.org>
Tue, 14 Aug 2012 08:48:24 +0000 (18:48 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 14 Aug 2012 13:37:22 +0000 (15:37 +0200)
source4/dsdb/common/util.c

index fd18d8881fdc75b1730c6ab104e2f180512cc430..b5db1d145a35f3ef852a7d1717f0249f906b978e 100644 (file)
@@ -1816,50 +1816,19 @@ const char *samdb_client_site_name(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
 */
 bool samdb_is_pdc(struct ldb_context *ldb)
 {
-       const char *dom_attrs[] = { "fSMORoleOwner", NULL };
        int ret;
-       struct ldb_result *dom_res;
-       TALLOC_CTX *tmp_ctx;
        bool is_pdc;
-       struct ldb_dn *pdc;
-
-       tmp_ctx = talloc_new(ldb);
-       if (tmp_ctx == NULL) {
-               DEBUG(1, ("talloc_new failed in samdb_is_pdc"));
-               return false;
-       }
 
-       ret = ldb_search(ldb, tmp_ctx, &dom_res, ldb_get_default_basedn(ldb), LDB_SCOPE_BASE, dom_attrs, NULL);
+       ret = samdb_reference_dn_is_our_ntdsa(ldb, ldb_get_default_basedn(ldb), "fsmoRoleOwner", 
+                                             &is_pdc);
        if (ret != LDB_SUCCESS) {
-               DEBUG(1,("Searching for fSMORoleOwner in %s failed: %s\n", 
+               DEBUG(1,("Failed to find if we are the PDC for this ldb: Searching for fSMORoleOwner in %s failed: %s\n", 
                         ldb_dn_get_linearized(ldb_get_default_basedn(ldb)), 
                         ldb_errstring(ldb)));
-               goto failed;
-       }
-       if (dom_res->count != 1) {
-               goto failed;
-       }
-
-       pdc = ldb_msg_find_attr_as_dn(ldb, tmp_ctx, dom_res->msgs[0],
-                                     "fSMORoleOwner");
-       if (pdc == NULL) {
-               goto failed;
-       }
-
-       if (ldb_dn_compare(samdb_ntds_settings_dn(ldb, tmp_ctx), pdc) == 0) {
-               is_pdc = true;
-       } else {
-               is_pdc = false;
+               return false;
        }
 
-       talloc_free(tmp_ctx);
-
        return is_pdc;
-
-failed:
-       DEBUG(1,("Failed to find if we are the PDC for this ldb\n"));
-       talloc_free(tmp_ctx);
-       return false;
 }
 
 /*