Author: abartlet
Date: 2007-10-18 05:39:55 +0000 (Thu, 18 Oct 2007)
New Revision: 25693

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

Log:
Implement the rest of subtree renames, now that tridge waved his magic
over the ldb_tdb part of the problem.

Andrew Bartlett

Modified:
   branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/subtree_rename.c
   branches/SAMBA_4_0/source/scripting/libjs/provision.js


Changeset:
Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/subtree_rename.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/subtree_rename.c   
2007-10-18 03:32:07 UTC (rev 25692)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/subtree_rename.c   
2007-10-18 05:39:55 UTC (rev 25693)
@@ -79,20 +79,26 @@
 
 static int subtree_rename_search_callback(struct ldb_context *ldb, void 
*context, struct ldb_reply *ares) 
 {
+       struct ldb_request *req;
+       struct subtree_rename_context *ac = talloc_get_type(context, struct 
subtree_rename_context);
+       TALLOC_CTX *mem_ctx = talloc_new(ac);
+    
+       if (!mem_ctx) {
+               ldb_oom(ac->module->ldb);
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
        /* OK, we have one of *many* search results here:
 
           We should also get the entry we tried to rename.  This
           callback handles this and everything below it.
         */
 
-       if (ares->type == LDB_REPLY_ENTRY) {
+       /* Only entries are interesting, and we handle the case of the parent 
seperatly */
+       if (ares->type == LDB_REPLY_ENTRY
+           && ldb_dn_compare(ares->message->dn, ac->orig_req->op.rename.olddn) 
!= 0) {
                /* And it is an actual entry: now create a rename from it */
-               struct subtree_rename_context *ac = talloc_get_type(context, 
struct subtree_rename_context);
-               struct ldb_request *req;
                int ret;
 
-               TALLOC_CTX *mem_ctx = talloc_new(ac);
-               
                struct ldb_dn *newdn = ldb_dn_copy(mem_ctx, ares->message->dn);
                if (!newdn) {
                        ldb_oom(ac->module->ldb);
@@ -118,26 +124,30 @@
                talloc_steal(req, newdn);
 
                talloc_steal(req, ares->message->dn);
-
+               
                talloc_free(ares);
-
-               ac->down_req = talloc_realloc(ac, ac->down_req, 
-                                             struct ldb_request *, 
ac->num_requests + 1);
-               if (!ac->down_req) {
-                       ldb_oom(ac->module->ldb);
-                       return LDB_ERR_OPERATIONS_ERROR;
-               }
-               ac->down_req[ac->num_requests] = req;
-               ac->num_requests++;
                
-               return ldb_next_request(ac->module, req);
+       } else if (ares->type == LDB_REPLY_DONE) {
+               req = talloc(mem_ctx, struct ldb_request);
+               *req = *ac->orig_req;
+               talloc_free(ares);
 
        } else {
                talloc_free(ares);
+               return LDB_SUCCESS;
        }
-
-       return LDB_SUCCESS;
-
+       
+       ac->down_req = talloc_realloc(ac, ac->down_req, 
+                                     struct ldb_request *, ac->num_requests + 
1);
+       if (!ac->down_req) {
+               ldb_oom(ac->module->ldb);
+               return LDB_ERR_OPERATIONS_ERROR;
+       }
+       ac->down_req[ac->num_requests] = req;
+       ac->num_requests++;
+       
+       return ldb_next_request(ac->module, req);
+       
 }
 
 /* rename */
@@ -148,7 +158,7 @@
        struct subtree_rename_context *ac;
        int ret;
        struct ldb_search_options_control *search_options;
-       if (ldb_dn_is_special(req->op.mod.message->dn)) { /* do not manipulate 
our control entries */
+       if (ldb_dn_is_special(req->op.rename.olddn)) { /* do not manipulate our 
control entries */
                return ldb_next_request(module, req);
        }
 
@@ -175,6 +185,10 @@
                                   ac, 
                                   subtree_rename_search_callback);
 
+       if (ret != LDB_SUCCESS) {
+               return ret;
+       }
+
        /* We want to find any partitions under this entry.  That way,
         * if we try and rename a whole partition, the partitions
         * module should cause us to fail the lot */
@@ -238,8 +252,6 @@
                }
        }
 
-       ret = LDB_SUCCESS;
-
 done:
        handle->state = LDB_ASYNC_DONE;
        return ret;

Modified: branches/SAMBA_4_0/source/scripting/libjs/provision.js
===================================================================
--- branches/SAMBA_4_0/source/scripting/libjs/provision.js      2007-10-18 
03:32:07 UTC (rev 25692)
+++ branches/SAMBA_4_0/source/scripting/libjs/provision.js      2007-10-18 
05:39:55 UTC (rev 25693)
@@ -972,8 +972,8 @@
        subobj.CONFIGDN_LDB = "configuration.ldb";
        subobj.SCHEMADN_LDB = "schema.ldb";
        subobj.DOMAINDN_MOD = "subtree_rename,pdc_fsmo,password_hash";
-       subobj.CONFIGDN_MOD = "naming_fsmo";
-       subobj.SCHEMADN_MOD = "schema_fsmo";
+       subobj.CONFIGDN_MOD = "subtree_rename,naming_fsmo";
+       subobj.SCHEMADN_MOD = "subtree_rename,schema_fsmo";
        subobj.DOMAINDN_MOD2 = ",objectguid";
        subobj.CONFIGDN_MOD2 = ",objectguid";
        subobj.SCHEMADN_MOD2 = ",objectguid";

Reply via email to