summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb/ldb_modules/objectclass.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2009-11-16 18:46:28 +1100
committerAndrew Bartlett <abartlet@samba.org>2009-11-17 10:38:02 +1100
commit07953142a4755354a8e76fa217c6cbf1b5dbcf30 (patch)
treeba9ce648b532d84b856782d2a29c7e97c4a565be /source4/dsdb/samdb/ldb_modules/objectclass.c
parent0238147a855c65ea0a81b0a945ae8ffd9b260c75 (diff)
downloadsamba-07953142a4755354a8e76fa217c6cbf1b5dbcf30.tar.gz
samba-07953142a4755354a8e76fa217c6cbf1b5dbcf30.tar.bz2
samba-07953142a4755354a8e76fa217c6cbf1b5dbcf30.zip
s4:dsdb Rework samdb code to use 'storage format' DNs for defaultObjectCategory
It is important to always ensure that this attribute has an extended DN if the rest of the database stores things that way. The knowlege of what format the DN is stored on disk with is passed around in an LDB opaque. Andrew Bartlett
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules/objectclass.c')
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectclass.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c
index ba28d42e7f..a26dcd2cea 100644
--- a/source4/dsdb/samdb/ldb_modules/objectclass.c
+++ b/source4/dsdb/samdb/ldb_modules/objectclass.c
@@ -621,7 +621,15 @@ static int objectclass_do_add(struct oc_context *ac)
}
if (!ldb_msg_find_element(msg, "objectCategory")) {
- value = talloc_strdup(msg, current->objectclass->defaultObjectCategory);
+ struct dsdb_extended_dn_store_format *dn_format = talloc_get_type(ldb_module_get_private(ac->module), struct dsdb_extended_dn_store_format);
+ if (dn_format && dn_format->store_extended_dn_in_ldb == false) {
+ /* Strip off extended components */
+ struct ldb_dn *dn = ldb_dn_new(msg, ldb, current->objectclass->defaultObjectCategory);
+ value = ldb_dn_alloc_linearized(msg, dn);
+ talloc_free(dn);
+ } else {
+ value = talloc_strdup(msg, current->objectclass->defaultObjectCategory);
+ }
if (value == NULL) {
ldb_oom(ldb);
talloc_free(mem_ctx);
@@ -1189,9 +1197,26 @@ static int objectclass_do_rename(struct oc_context *ac)
return ldb_next_request(ac->module, rename_req);
}
+static int objectclass_init(struct ldb_module *module)
+{
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
+ int ret;
+ /* Init everything else */
+ ret = ldb_next_init(module);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
+
+ /* Look for the opaque to indicate we might have to cut down the DN of defaultObjectCategory */
+ ldb_module_set_private(module, ldb_get_opaque(ldb, DSDB_EXTENDED_DN_STORE_FORMAT_OPAQUE_NAME));
+
+ return ldb_next_init(module);
+}
+
_PUBLIC_ const struct ldb_module_ops ldb_objectclass_module_ops = {
.name = "objectclass",
.add = objectclass_add,
.modify = objectclass_modify,
.rename = objectclass_rename,
+ .init_context = objectclass_init
};