summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules/pdc_fsmo.c')
-rw-r--r--source4/dsdb/samdb/ldb_modules/pdc_fsmo.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
index 198b667358..fefaef4755 100644
--- a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
+++ b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
@@ -21,9 +21,7 @@
*/
#include "includes.h"
-#include "lib/ldb/include/ldb.h"
-#include "lib/ldb/include/ldb_errors.h"
-#include "lib/ldb/include/ldb_private.h"
+#include "ldb_module.h"
#include "dsdb/samdb/samdb.h"
#include "librpc/gen_ndr/ndr_misc.h"
#include "librpc/gen_ndr/ndr_drsuapi.h"
@@ -32,6 +30,7 @@
static int pdc_fsmo_init(struct ldb_module *module)
{
+ struct ldb_context *ldb;
TALLOC_CTX *mem_ctx;
struct ldb_dn *pdc_dn;
struct dsdb_pdc_fsmo *pdc_fsmo;
@@ -42,15 +41,17 @@ static int pdc_fsmo_init(struct ldb_module *module)
NULL
};
+ ldb = ldb_module_get_ctx(module);
+
mem_ctx = talloc_new(module);
if (!mem_ctx) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- pdc_dn = samdb_base_dn(module->ldb);
+ pdc_dn = samdb_base_dn(ldb);
if (!pdc_dn) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING,
+ ldb_debug(ldb, LDB_DEBUG_WARNING,
"pdc_fsmo_init: no domain dn present: (skip loading of domain details)\n");
talloc_free(mem_ctx);
return ldb_next_init(module);
@@ -58,54 +59,54 @@ static int pdc_fsmo_init(struct ldb_module *module)
pdc_fsmo = talloc_zero(mem_ctx, struct dsdb_pdc_fsmo);
if (!pdc_fsmo) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- module->private_data = pdc_fsmo;
+ ldb_module_set_private(module, pdc_fsmo);
- ret = ldb_search(module->ldb, mem_ctx, &pdc_res,
+ ret = ldb_search(ldb, mem_ctx, &pdc_res,
pdc_dn, LDB_SCOPE_BASE,
pdc_attrs, NULL);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING,
+ ldb_debug(ldb, LDB_DEBUG_WARNING,
"pdc_fsmo_init: no domain object present: (skip loading of domain details)\n");
talloc_free(mem_ctx);
return ldb_next_init(module);
} else if (ret != LDB_SUCCESS) {
- ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
+ ldb_debug_set(ldb, LDB_DEBUG_FATAL,
"pdc_fsmo_init: failed to search the domain object: %d:%s",
ret, ldb_strerror(ret));
talloc_free(mem_ctx);
return ret;
}
if (pdc_res->count == 0) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING,
+ ldb_debug(ldb, LDB_DEBUG_WARNING,
"pdc_fsmo_init: no domain object present: (skip loading of domain details)\n");
talloc_free(mem_ctx);
return ldb_next_init(module);
} else if (pdc_res->count > 1) {
- ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
+ ldb_debug_set(ldb, LDB_DEBUG_FATAL,
"pdc_fsmo_init: [%u] domain objects found on a base search",
pdc_res->count);
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
- pdc_fsmo->master_dn = ldb_msg_find_attr_as_dn(module->ldb, mem_ctx, pdc_res->msgs[0], "fSMORoleOwner");
- if (ldb_dn_compare(samdb_ntds_settings_dn(module->ldb), pdc_fsmo->master_dn) == 0) {
+ pdc_fsmo->master_dn = ldb_msg_find_attr_as_dn(ldb, mem_ctx, pdc_res->msgs[0], "fSMORoleOwner");
+ if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), pdc_fsmo->master_dn) == 0) {
pdc_fsmo->we_are_master = true;
} else {
pdc_fsmo->we_are_master = false;
}
- if (ldb_set_opaque(module->ldb, "dsdb_pdc_fsmo", pdc_fsmo) != LDB_SUCCESS) {
- ldb_oom(module->ldb);
+ if (ldb_set_opaque(ldb, "dsdb_pdc_fsmo", pdc_fsmo) != LDB_SUCCESS) {
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
talloc_steal(module, pdc_fsmo);
- ldb_debug(module->ldb, LDB_DEBUG_TRACE,
+ ldb_debug(ldb, LDB_DEBUG_TRACE,
"pdc_fsmo_init: we are master: %s\n",
(pdc_fsmo->we_are_master?"yes":"no"));