svn commit: samba r20871 - in branches/SAMBA_4_0/source/dsdb/samdb: . ldb_modules

metze at samba.org metze at samba.org
Thu Jan 18 01:31:13 GMT 2007


Author: metze
Date: 2007-01-18 01:31:09 +0000 (Thu, 18 Jan 2007)
New Revision: 20871

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20871

Log:
implement the validFSMOs constructed attribute on the rootdse
for the schema, domain naming and pdc fsmo roles

infrastructure and rid manager will be added later,
when we have module for them

metze
Modified:
   branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/naming_fsmo.c
   branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/pdc_fsmo.c
   branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/rootdse.c
   branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/schema_fsmo.c
   branches/SAMBA_4_0/source/dsdb/samdb/samdb.h


Changeset:
Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/naming_fsmo.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/naming_fsmo.c	2007-01-18 00:49:52 UTC (rev 20870)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/naming_fsmo.c	2007-01-18 01:31:09 UTC (rev 20871)
@@ -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 @@
 		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"));

Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/pdc_fsmo.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/pdc_fsmo.c	2007-01-18 00:49:52 UTC (rev 20870)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/pdc_fsmo.c	2007-01-18 01:31:09 UTC (rev 20871)
@@ -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 @@
 		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"));

Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/rootdse.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/rootdse.c	2007-01-18 00:49:52 UTC (rev 20870)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/rootdse.c	2007-01-18 01:31:09 UTC (rev 20871)
@@ -163,6 +163,46 @@
 		}
 	}
 
+	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;

Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/schema_fsmo.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/schema_fsmo.c	2007-01-18 00:49:52 UTC (rev 20870)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/schema_fsmo.c	2007-01-18 01:31:09 UTC (rev 20871)
@@ -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 @@
 	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 @@
 		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"));

Modified: branches/SAMBA_4_0/source/dsdb/samdb/samdb.h
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/samdb.h	2007-01-18 00:49:52 UTC (rev 20870)
+++ branches/SAMBA_4_0/source/dsdb/samdb/samdb.h	2007-01-18 01:31:09 UTC (rev 20871)
@@ -77,4 +77,19 @@
 	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__ */



More information about the samba-cvs mailing list