summaryrefslogtreecommitdiff
path: root/source4/dsdb/schema
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-11-16 18:48:46 +1100
committerAndrew Bartlett <abartlet@samba.org>2009-11-17 10:38:03 +1100
commite9f4dbce64b29882ae2f2f51cda50805c4e27190 (patch)
tree7816f64225e158e839e24d8ed38d19a589b04c04 /source4/dsdb/schema
parent07953142a4755354a8e76fa217c6cbf1b5dbcf30 (diff)
downloadsamba-e9f4dbce64b29882ae2f2f51cda50805c4e27190.tar.gz
samba-e9f4dbce64b29882ae2f2f51cda50805c4e27190.tar.bz2
samba-e9f4dbce64b29882ae2f2f51cda50805c4e27190.zip
s4:schema Add the GUID to each defaultObjectCategory when loading from LDIF
This makes these full extended DNs, so we set the right values into the database, even before we actually set the schema objects themselves. Andrew Bartlett
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r--source4/dsdb/schema/schema_set.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/source4/dsdb/schema/schema_set.c b/source4/dsdb/schema/schema_set.c
index ab870741cf..c321bc9cca 100644
--- a/source4/dsdb/schema/schema_set.c
+++ b/source4/dsdb/schema/schema_set.c
@@ -25,6 +25,8 @@
#include "dsdb/samdb/samdb.h"
#include "lib/ldb/include/ldb_module.h"
#include "param/param.h"
+#include "librpc/ndr/libndr.h"
+#include "librpc/gen_ndr/ndr_misc.h"
/*
override the name to attribute handler function
@@ -456,6 +458,47 @@ void dsdb_make_schema_global(struct ldb_context *ldb)
dsdb_set_global_schema(ldb);
}
+/* When loading the schema from LDIF files, we don't get the extended DNs.
+
+ We need to set these up, so that from the moment we start the provision, the defaultObjectCategory links are set up correctly.
+ */
+int dsdb_schema_fill_extended_dn(struct ldb_context *ldb, struct dsdb_schema *schema)
+{
+ struct dsdb_class *cur;
+ const struct dsdb_class *target_class;
+ for (cur = schema->classes; cur; cur = cur->next) {
+ enum ndr_err_code ndr_err;
+ const struct ldb_val *rdn;
+ struct ldb_val guid;
+ struct ldb_dn *dn = ldb_dn_new(NULL, ldb, cur->defaultObjectCategory);
+ if (!dn) {
+ return LDB_ERR_INVALID_DN_SYNTAX;
+ }
+ rdn = ldb_dn_get_component_val(dn, 0);
+ if (!rdn) {
+ talloc_free(dn);
+ return LDB_ERR_INVALID_DN_SYNTAX;
+ }
+ target_class = dsdb_class_by_cn_ldb_val(schema, rdn);
+ if (!target_class) {
+ talloc_free(dn);
+ return LDB_ERR_CONSTRAINT_VIOLATION;
+ }
+
+ ndr_err = ndr_push_struct_blob(&guid, dn, NULL, &target_class->objectGUID,
+ (ndr_push_flags_fn_t)ndr_push_GUID);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ talloc_free(dn);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ ldb_dn_set_extended_component(dn, "GUID", &guid);
+
+ cur->defaultObjectCategory = ldb_dn_get_extended_linearized(cur, dn, 1);
+ talloc_free(dn);
+ }
+ return LDB_SUCCESS;
+}
+
/**
* Add an element to the schema (attribute or class) from an LDB message
*/
@@ -580,6 +623,12 @@ WERROR dsdb_set_schema_from_ldif(struct ldb_context *ldb, const char *pf, const
goto failed;
}
+ ret = dsdb_schema_fill_extended_dn(ldb, schema);
+ if (ret != LDB_SUCCESS) {
+ status = WERR_FOOBAR;
+ goto failed;
+ }
+
goto done;
nomem: