s4:dsdb rework instanceType module - put instanceType in provision
authorAndrew Bartlett <abartlet@samba.org>
Thu, 24 Sep 2009 22:06:11 +0000 (15:06 -0700)
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Fri, 2 Oct 2009 10:45:07 +0000 (12:45 +0200)
The instanceType needs to be specified in future because that's how
the partitions are actually created.

source4/dsdb/samdb/ldb_modules/instancetype.c
source4/scripting/python/samba/provision.py
source4/setup/provision_basedn.ldif
source4/setup/provision_configuration_basedn.ldif
source4/setup/provision_schema_basedn.ldif

index de46c0a42aa3982ee311b403d1f900ac4a54f9ca..201ed044125c8a6400e858612b79d52a3d0ffe20 100644 (file)
@@ -77,8 +77,6 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req)
        struct it_context *ac;
        uint32_t instance_type;
        int ret;
-       const struct ldb_control *partition_ctrl;
-       const struct dsdb_control_current_partition *partition;
 
        ldb = ldb_module_get_ctx(module);
 
@@ -90,31 +88,19 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req)
        }
 
        if (ldb_msg_find_element(req->op.add.message, "instanceType")) {
+               unsigned int instanceType = ldb_msg_find_attr_as_uint(req->op.add.message, "instanceType", 0);
+
+               if (instanceType & INSTANCE_TYPE_IS_NC_HEAD) {
+                       /* Do something in future */
+               }
+               
                /* TODO: we need to validate and possibly create a new
                   partition */
                return ldb_next_request(module, req);           
        }
 
-       partition_ctrl = ldb_request_get_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID);
-       if (!partition_ctrl) {
-               ldb_debug_set(ldb, LDB_DEBUG_FATAL,
-                             "instancetype_add: no current partition control found");
-               return LDB_ERR_CONSTRAINT_VIOLATION;
-       }
-
-       partition = talloc_get_type(partition_ctrl->data,
-                                   struct dsdb_control_current_partition);
-       SMB_ASSERT(partition && partition->version == DSDB_CONTROL_CURRENT_PARTITION_VERSION);
-
-       ac = talloc(req, struct it_context);
-       if (ac == NULL) {
-               return LDB_ERR_OPERATIONS_ERROR;
-       }
-       ac->module = module;
-       ac->req = req;
-
        /* we have to copy the message as the caller might have it as a const */
-       msg = ldb_msg_copy_shallow(ac, req->op.add.message);
+       msg = ldb_msg_copy_shallow(req, req->op.add.message);
        if (msg == NULL) {
                ldb_oom(ldb);
                return LDB_ERR_OPERATIONS_ERROR;
@@ -124,12 +110,6 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req)
         * TODO: calculate correct instance type
         */
        instance_type = INSTANCE_TYPE_WRITE;
-       if (ldb_dn_compare(partition->dn, msg->dn) == 0) {
-               instance_type |= INSTANCE_TYPE_IS_NC_HEAD;
-               if (ldb_dn_compare(msg->dn, samdb_base_dn(ldb)) != 0) {
-                       instance_type |= INSTANCE_TYPE_NC_ABOVE;
-               }
-       }
 
        ret = ldb_msg_add_fmt(msg, "instanceType", "%u", instance_type);
        if (ret != LDB_SUCCESS) {
@@ -137,10 +117,10 @@ static int instancetype_add(struct ldb_module *module, struct ldb_request *req)
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       ret = ldb_build_add_req(&down_req, ldb, ac,
+       ret = ldb_build_add_req(&down_req, ldb, req,
                                msg,
                                req->controls,
-                               ac, it_callback,
+                               req->context, req->callback,
                                req);
        if (ret != LDB_SUCCESS) {
                return ret;
index e830870bb093ec2e89c93ae2f790b8f063a870f9..986a40a03baf320aa617e623ebb53921b0bd4d4d 100644 (file)
@@ -631,7 +631,8 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
                     "samldb",
                     "password_hash",
                     "operational",
-                    "kludge_acl"]
+                    "kludge_acl", 
+                    "instancetype"]
     tdb_modules_list = [
                     "subtree_rename",
                     "subtree_delete",
@@ -679,9 +680,9 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
                 "CONFIGDN_LDB": configdn_ldb,
                 "DOMAINDN": names.domaindn,
                 "DOMAINDN_LDB": domaindn_ldb,
-                "SCHEMADN_MOD": "schema_fsmo,instancetype",
-                "CONFIGDN_MOD": "naming_fsmo,instancetype",
-                "DOMAINDN_MOD": "pdc_fsmo,instancetype",
+                "SCHEMADN_MOD": "schema_fsmo",
+                "CONFIGDN_MOD": "naming_fsmo",
+                "DOMAINDN_MOD": "pdc_fsmo",
                 "MODULES_LIST": ",".join(modules_list),
                 "TDB_MODULES_LIST": tdb_modules_list_as_string,
                 "MODULES_LIST2": ",".join(modules_list2),
index 0d81df34537e6da2ecb2cf650940113d0ad28da5..0a5f618e8454427b760c9ac1643209f3d7d3cca8 100644 (file)
@@ -4,4 +4,5 @@
 dn: ${DOMAINDN}
 objectClass: top
 objectClass: ${DOMAIN_OC}
+instanceType: 5
 ${DOMAINGUID}
index b385359a61276bb1477293a0cca5f99e29046868..14a2c332583224d10fdeb2bf7c01d23db1c4d5b8 100644 (file)
@@ -6,3 +6,4 @@ objectClass: top
 objectClass: configuration
 cn: Configuration
 nTSecurityDescriptor:: ${DESCRIPTOR}
+instanceType: 13
index 5301a11965a23b07de41af5553c26dffed461e42..6fe0b0ea9325b9eb916f5dbb6fbf66753a16ce8d 100644 (file)
@@ -6,3 +6,4 @@ objectClass: top
 objectClass: dMD
 cn: Schema
 nTSecurityDescriptor:: ${DESCRIPTOR}
+instanceType: 13