summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/samdb/ldb_modules/rootdse.c5
-rw-r--r--source4/dsdb/samdb/ldb_modules/schema_fsmo.c32
-rw-r--r--source4/dsdb/samdb/samdb.h5
-rw-r--r--source4/dsdb/schema/schema.h5
-rw-r--r--source4/dsdb/schema/schema_init.c6
5 files changed, 20 insertions, 33 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c
index 50f333d095..75f99a139d 100644
--- a/source4/dsdb/samdb/ldb_modules/rootdse.c
+++ b/source4/dsdb/samdb/ldb_modules/rootdse.c
@@ -164,14 +164,11 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
}
if (do_attribute_explicit(attrs, "validFSMOs")) {
- const struct dsdb_schema_fsmo *schema_fsmo;
const struct dsdb_naming_fsmo *naming_fsmo;
const struct dsdb_pdc_fsmo *pdc_fsmo;
const char *dn_str;
- schema_fsmo = talloc_get_type(ldb_get_opaque(module->ldb, "dsdb_schema_fsmo"),
- struct dsdb_schema_fsmo);
- if (schema_fsmo && schema_fsmo->we_are_master) {
+ if (schema && schema->fsmo.we_are_master) {
dn_str = ldb_dn_get_linearized(samdb_schema_dn(module->ldb));
if (dn_str && dn_str[0]) {
if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != 0) {
diff --git a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
index bc1e60abb2..0fcda0a430 100644
--- a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
+++ b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
@@ -38,7 +38,6 @@ static int schema_fsmo_init(struct ldb_module *module)
TALLOC_CTX *mem_ctx;
struct ldb_dn *schema_dn;
struct dsdb_schema *schema;
- struct dsdb_schema_fsmo *schema_fsmo;
struct ldb_result *schema_res;
const struct ldb_val *prefix_val;
const struct ldb_val *info_val;
@@ -54,8 +53,6 @@ static int schema_fsmo_init(struct ldb_module *module)
NULL
};
- module->private_data = NULL;
-
if (dsdb_get_schema(module->ldb)) {
return ldb_next_init(module);
}
@@ -74,12 +71,6 @@ static int schema_fsmo_init(struct ldb_module *module)
return LDB_ERR_OPERATIONS_ERROR;
}
- schema_fsmo = talloc_zero(mem_ctx, struct dsdb_schema_fsmo);
- if (!schema_fsmo) {
- ldb_oom(module->ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
schema = dsdb_new_schema(mem_ctx, lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")));
if (!schema) {
ldb_oom(module->ldb);
@@ -225,6 +216,13 @@ static int schema_fsmo_init(struct ldb_module *module)
}
talloc_free(c_res);
+ schema->fsmo.master_dn = ldb_msg_find_attr_as_dn(module->ldb, schema, schema_res->msgs[0], "fSMORoleOwner");
+ if (ldb_dn_compare(samdb_ntds_settings_dn(module->ldb), schema->fsmo.master_dn) == 0) {
+ schema->fsmo.we_are_master = true;
+ } else {
+ schema->fsmo.we_are_master = false;
+ }
+
/* dsdb_set_schema() steal schema into the ldb_context */
ret = dsdb_set_schema(module->ldb, schema);
if (ret != LDB_SUCCESS) {
@@ -235,23 +233,9 @@ static int schema_fsmo_init(struct ldb_module *module)
return ret;
}
- schema_fsmo->master_dn = ldb_msg_find_attr_as_dn(module->ldb, schema_fsmo, schema_res->msgs[0], "fSMORoleOwner");
- if (ldb_dn_compare(samdb_ntds_settings_dn(module->ldb), schema_fsmo->master_dn) == 0) {
- schema_fsmo->we_are_master = true;
- } else {
- schema_fsmo->we_are_master = false;
- }
-
- if (ldb_set_opaque(module->ldb, "dsdb_schema_fsmo", schema_fsmo) != LDB_SUCCESS) {
- ldb_oom(module->ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- module->private_data = talloc_steal(module, schema_fsmo);
-
ldb_debug(module->ldb, LDB_DEBUG_TRACE,
"schema_fsmo_init: we are master: %s\n",
- (schema_fsmo->we_are_master?"yes":"no"));
+ (schema->fsmo.we_are_master?"yes":"no"));
talloc_free(mem_ctx);
return ldb_next_init(module);
diff --git a/source4/dsdb/samdb/samdb.h b/source4/dsdb/samdb/samdb.h
index 8370857aba..75aa819ccd 100644
--- a/source4/dsdb/samdb/samdb.h
+++ b/source4/dsdb/samdb/samdb.h
@@ -80,11 +80,6 @@ struct dsdb_extended_replicated_objects {
struct dsdb_extended_replicated_object *objects;
};
-struct dsdb_schema_fsmo {
- bool we_are_master;
- struct ldb_dn *master_dn;
-};
-
struct dsdb_naming_fsmo {
bool we_are_master;
struct ldb_dn *master_dn;
diff --git a/source4/dsdb/schema/schema.h b/source4/dsdb/schema/schema.h
index bb34235465..6fce354f7c 100644
--- a/source4/dsdb/schema/schema.h
+++ b/source4/dsdb/schema/schema.h
@@ -150,6 +150,11 @@ struct dsdb_schema {
struct dsdb_attribute *attributes;
struct dsdb_class *classes;
+ struct {
+ bool we_are_master;
+ struct ldb_dn *master_dn;
+ } fsmo;
+
struct smb_iconv_convenience *iconv_convenience;
};
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index c046cb597f..6f8958dab8 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -1164,6 +1164,12 @@ WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf
schema = dsdb_new_schema(mem_ctx, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")));
+ schema->fsmo.we_are_master = true;
+ schema->fsmo.master_dn = ldb_dn_new_fmt(schema, ldb, "@PROVISION_SCHEMA_MASTER");
+ if (!schema->fsmo.master_dn) {
+ goto nomem;
+ }
+
/*
* load the prefixMap attribute from pf
*/