summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/dsdb/samdb/ldb_modules/naming_fsmo.c16
-rw-r--r--source4/dsdb/samdb/ldb_modules/pdc_fsmo.c16
-rw-r--r--source4/dsdb/samdb/ldb_modules/rootdse.c40
-rw-r--r--source4/dsdb/samdb/ldb_modules/schema_fsmo.c16
-rw-r--r--source4/dsdb/samdb/samdb.h15
5 files changed, 82 insertions, 21 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c
index 9041c37ce7..ddd120caf2 100644
--- a/source4/dsdb/samdb/ldb_modules/naming_fsmo.c
+++ b/source4/dsdb/samdb/ldb_modules/naming_fsmo.c
@@ -32,17 +32,12 @@
#include "librpc/gen_ndr/ndr_drsblobs.h"
#include "lib/util/dlinklist.h"
-struct dsdb_naming_fsmo {
- bool we_are_master;
-};
-
static int naming_fsmo_init(struct ldb_module *module)
{
TALLOC_CTX *mem_ctx;
struct ldb_dn *naming_dn;
struct dsdb_naming_fsmo *naming_fsmo;
struct ldb_result *naming_res;
- struct ldb_dn *naming_master_dn;
int ret;
static const char *naming_attrs[] = {
"fSMORoleOwner",
@@ -95,13 +90,20 @@ static int naming_fsmo_init(struct ldb_module *module)
return LDB_ERR_CONSTRAINT_VIOLATION;
}
- naming_master_dn = ldb_msg_find_attr_as_dn(module->ldb, mem_ctx, naming_res->msgs[0], "fSMORoleOwner");
- if (ldb_dn_compare(samdb_ntds_settings_dn(module->ldb), naming_master_dn) == 0) {
+ naming_fsmo->master_dn = ldb_msg_find_attr_as_dn(module->ldb, naming_fsmo, naming_res->msgs[0], "fSMORoleOwner");
+ if (ldb_dn_compare(samdb_ntds_settings_dn(module->ldb), naming_fsmo->master_dn) == 0) {
naming_fsmo->we_are_master = true;
} else {
naming_fsmo->we_are_master = false;
}
+ if (ldb_set_opaque(module->ldb, "dsdb_naming_fsmo", naming_fsmo) != LDB_SUCCESS) {
+ ldb_oom(module->ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ talloc_steal(module, naming_fsmo);
+
ldb_debug(module->ldb, LDB_DEBUG_TRACE,
"naming_fsmo_init: we are master: %s\n",
(naming_fsmo->we_are_master?"yes":"no"));
diff --git a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
index 16b40ef8d9..35a1636a4d 100644
--- a/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
+++ b/source4/dsdb/samdb/ldb_modules/pdc_fsmo.c
@@ -31,17 +31,12 @@
#include "librpc/gen_ndr/ndr_drsblobs.h"
#include "lib/util/dlinklist.h"
-struct dsdb_pdc_fsmo {
- bool we_are_master;
-};
-
static int pdc_fsmo_init(struct ldb_module *module)
{
TALLOC_CTX *mem_ctx;
struct ldb_dn *pdc_dn;
struct dsdb_pdc_fsmo *pdc_fsmo;
struct ldb_result *pdc_res;
- struct ldb_dn *pdc_master_dn;
int ret;
static const char *pdc_attrs[] = {
"fSMORoleOwner",
@@ -94,13 +89,20 @@ static int pdc_fsmo_init(struct ldb_module *module)
return LDB_ERR_CONSTRAINT_VIOLATION;
}
- pdc_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_master_dn) == 0) {
+ 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->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);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ talloc_steal(module, pdc_fsmo);
+
ldb_debug(module->ldb, LDB_DEBUG_TRACE,
"pdc_fsmo_init: we are master: %s\n",
(pdc_fsmo->we_are_master?"yes":"no"));
diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c
index 9a469c4563..a698e0db43 100644
--- a/source4/dsdb/samdb/ldb_modules/rootdse.c
+++ b/source4/dsdb/samdb/ldb_modules/rootdse.c
@@ -163,6 +163,46 @@ 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) {
+ 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) {
+ goto failed;
+ }
+ }
+ }
+
+ naming_fsmo = talloc_get_type(ldb_get_opaque(module->ldb, "dsdb_naming_fsmo"),
+ struct dsdb_naming_fsmo);
+ if (naming_fsmo && naming_fsmo->we_are_master) {
+ dn_str = ldb_dn_get_linearized(samdb_partitions_dn(module->ldb, msg));
+ if (dn_str && dn_str[0]) {
+ if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != 0) {
+ goto failed;
+ }
+ }
+ }
+
+ pdc_fsmo = talloc_get_type(ldb_get_opaque(module->ldb, "dsdb_pdc_fsmo"),
+ struct dsdb_pdc_fsmo);
+ if (pdc_fsmo && pdc_fsmo->we_are_master) {
+ dn_str = ldb_dn_get_linearized(samdb_base_dn(module->ldb));
+ if (dn_str && dn_str[0]) {
+ if (ldb_msg_add_fmt(msg, "validFSMOs", "%s", dn_str) != 0) {
+ goto failed;
+ }
+ }
+ }
+ }
+
/* TODO: lots more dynamic attributes should be added here */
return LDB_SUCCESS;
diff --git a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
index c692b983dd..deba2b7d88 100644
--- a/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
+++ b/source4/dsdb/samdb/ldb_modules/schema_fsmo.c
@@ -32,10 +32,6 @@
#include "librpc/gen_ndr/ndr_drsblobs.h"
#include "lib/util/dlinklist.h"
-struct dsdb_schema_fsmo {
- bool we_are_master;
-};
-
static int schema_fsmo_init(struct ldb_module *module)
{
WERROR status;
@@ -44,7 +40,6 @@ static int schema_fsmo_init(struct ldb_module *module)
struct dsdb_schema *schema;
struct dsdb_schema_fsmo *schema_fsmo;
struct ldb_result *schema_res;
- struct ldb_dn *schema_master_dn;
const struct ldb_val *prefix_val;
const struct ldb_val *info_val;
struct ldb_result *a_res;
@@ -224,13 +219,20 @@ static int schema_fsmo_init(struct ldb_module *module)
return ret;
}
- schema_master_dn = ldb_msg_find_attr_as_dn(module->ldb, mem_ctx, schema_res->msgs[0], "fSMORoleOwner");
- if (ldb_dn_compare(samdb_ntds_settings_dn(module->ldb), schema_master_dn) == 0) {
+ 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;
+ }
+
+ 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"));
diff --git a/source4/dsdb/samdb/samdb.h b/source4/dsdb/samdb/samdb.h
index 17059b7ec5..c7608d44cd 100644
--- a/source4/dsdb/samdb/samdb.h
+++ b/source4/dsdb/samdb/samdb.h
@@ -77,4 +77,19 @@ 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;
+};
+
+struct dsdb_pdc_fsmo {
+ bool we_are_master;
+ struct ldb_dn *master_dn;
+};
+
#endif /* __SAMDB_H__ */