From a3c6d4c4d52c174d7fcac73fb315dc7e7c03fdd9 Mon Sep 17 00:00:00 2001 From: Matthias Dieter Wallnöfer Date: Thu, 5 Aug 2010 21:02:29 +0200 Subject: s4:objectclass LDB module - "add operation" - move two checks To be more consistent with the MS-ADTS doc. --- source4/dsdb/samdb/ldb_modules/objectclass.c | 29 ++++++++++++---------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'source4/dsdb') diff --git a/source4/dsdb/samdb/ldb_modules/objectclass.c b/source4/dsdb/samdb/ldb_modules/objectclass.c index 59f6cb0191..4feb8c3849 100644 --- a/source4/dsdb/samdb/ldb_modules/objectclass.c +++ b/source4/dsdb/samdb/ldb_modules/objectclass.c @@ -401,13 +401,6 @@ static int objectclass_add(struct ldb_module *module, struct ldb_request *req) } } - /* the various objectclasses must be specified on add operations */ - if (ldb_msg_find_element(req->op.add.message, "objectClass") == NULL) { - ldb_asprintf_errstring(ldb, "objectclass: Cannot add %s, no objectclass specified!", - ldb_dn_get_linearized(req->op.add.message->dn)); - return LDB_ERR_OBJECT_CLASS_VIOLATION; - } - ac = oc_init_context(module, req); if (ac == NULL) { return ldb_operr(ldb); @@ -494,14 +487,16 @@ static int objectclass_do_add(struct oc_context *ac) } if (ac->schema != NULL) { - /* This is now the objectClass list from the database */ objectclass_element = ldb_msg_find_element(msg, "objectClass"); - if (!objectclass_element) { - /* Where did it go? bail now... */ + ldb_asprintf_errstring(ldb, "objectclass: Cannot add %s, no objectclass specified!", + ldb_dn_get_linearized(msg->dn)); talloc_free(mem_ctx); - return ldb_operr(ldb); + return LDB_ERR_OBJECT_CLASS_VIOLATION; } + + /* Here we do now get the "objectClass" list from the + * database. */ ret = objectclass_sort(ac->module, ac->schema, mem_ctx, objectclass_element, &sorted); if (ret != LDB_SUCCESS) { @@ -570,6 +565,12 @@ static int objectclass_do_add(struct oc_context *ac) return LDB_ERR_NAMING_VIOLATION; } + if (objectclass->systemOnly && !ldb_request_get_control(ac->req, LDB_CONTROL_RELAX_OID)) { + ldb_asprintf_errstring(ldb, "objectClass %s is systemOnly, rejecting creation of %s", + objectclass->lDAPDisplayName, ldb_dn_get_linearized(msg->dn)); + return LDB_ERR_UNWILLING_TO_PERFORM; + } + if (ac->search_res && ac->search_res->message) { struct ldb_message_element *oc_el = ldb_msg_find_element(ac->search_res->message, "objectClass"); @@ -600,12 +601,6 @@ static int objectclass_do_add(struct oc_context *ac) } } - if (objectclass->systemOnly && !ldb_request_get_control(ac->req, LDB_CONTROL_RELAX_OID)) { - ldb_asprintf_errstring(ldb, "objectClass %s is systemOnly, rejecting creation of %s", - objectclass->lDAPDisplayName, ldb_dn_get_linearized(msg->dn)); - return LDB_ERR_UNWILLING_TO_PERFORM; - } - if (!ldb_msg_find_element(msg, "objectCategory")) { 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) { -- cgit