schema_fsmo: move fsmo info into struct dsdb_schema
authorStefan Metzmacher <metze@samba.org>
Tue, 1 Jul 2008 14:35:13 +0000 (16:35 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 1 Jul 2008 14:55:43 +0000 (16:55 +0200)
metze
(This used to be commit 8538d305c803268c712a90879f29a2a74ba0ef03)

source4/dsdb/samdb/ldb_modules/rootdse.c
source4/dsdb/samdb/ldb_modules/schema_fsmo.c
source4/dsdb/samdb/samdb.h
source4/dsdb/schema/schema.h
source4/dsdb/schema/schema_init.c

index 50f333d09572bfd6d70150641f748ff5be174531..75f99a139d797b17cbcc57be97fd36f1fd440818 100644 (file)
@@ -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) {
index bc1e60abb27c901e1bcd800c9b806d21912209fc..0fcda0a430f19e573e7546de0e1a5c35b7e09b06 100644 (file)
@@ -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);
index 8370857aba325f5d87ceaa37718a0331ccf69265..75aa819ccdd5809fc6dbe00a879e79d35c8fefbe 100644 (file)
@@ -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;
index bb3423546508ba686eda88b4d3af99693650fb2a..6fce354f7cc981d59fe6da47418fa27b15858f61 100644 (file)
@@ -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;
 };
 
index c046cb597f5d11e4f8aaed29e684c7d8c3afa6ff..6f8958dab8f29b2486c53d24758eb5237aa78d8c 100644 (file)
@@ -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
         */