summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-14 18:48:24 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-14 15:37:22 +0200
commit773d0367a6d1bc4cbc3147420ddc0e94ee7cdc2c (patch)
tree670230bc09d025c04565eb01bf5b451e485a917a /source4
parent7213199f6e92713282cbf90d30ba7bb72a040734 (diff)
downloadsamba-773d0367a6d1bc4cbc3147420ddc0e94ee7cdc2c.tar.gz
samba-773d0367a6d1bc4cbc3147420ddc0e94ee7cdc2c.tar.bz2
samba-773d0367a6d1bc4cbc3147420ddc0e94ee7cdc2c.zip
s4-dsdb: Use samdb_reference_dn_is_our_ntdsa()
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/common/util.c39
1 files changed, 4 insertions, 35 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index fd18d8881f..b5db1d145a 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -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;
}
/*