s4-drs: if schema has changed during replication notify other process that they have...
authorMatthieu Patou <mat@matws.net>
Wed, 30 May 2012 17:42:56 +0000 (10:42 -0700)
committerMatthieu Patou <mat@matws.net>
Sat, 23 Jun 2012 06:22:04 +0000 (23:22 -0700)
source4/dsdb/repl/replicated_objects.c

index 5ccf05255487213c7e3a76dec7a7a9b6743a1067..481ff60217c5c65441f56e010023fec3134909b7 100644 (file)
@@ -624,12 +624,67 @@ WERROR dsdb_replicated_objects_commit(struct ldb_context *ldb,
         * a schema cache being refreshed from database.
         */
        if (working_schema) {
+               struct ldb_message *msg;
+               struct ldb_request *req;
+
+               /* Force a reload */
+               working_schema->last_refresh = 0;
                cur_schema = dsdb_get_schema(ldb, NULL);
                /* TODO: What we do in case dsdb_get_schema() fail?
                 *       We can't fallback at this point anymore */
                if (cur_schema) {
                        dsdb_make_schema_global(ldb, cur_schema);
                }
+               msg = ldb_msg_new(ldb);
+               if (msg == 0) {
+                       return WERR_NOMEM;
+               }
+               msg->dn = NULL;
+
+               ret = ldb_msg_add_string(msg, "schemaUpdateNow", "1");
+               if (ret != LDB_SUCCESS) {
+                       talloc_free(msg);
+                       return WERR_INTERNAL_ERROR;
+               }
+
+               ret = ldb_build_mod_req(&req, ldb, ldb,
+                               msg,
+                               LDB_SCOPE_BASE,
+                               NULL,
+                               ldb_op_default_callback,
+                               NULL);
+
+               if (ret != LDB_SUCCESS) {
+                       talloc_free(msg);
+                       return WERR_DS_DRA_INTERNAL_ERROR;
+               }
+
+               ret = ldb_transaction_start(ldb);
+               if (ret != LDB_SUCCESS) {
+                       talloc_free(msg);
+                       talloc_free(req);
+                       DEBUG(0, ("Autotransaction start failed\n"));
+                       return WERR_DS_DRA_INTERNAL_ERROR;
+               }
+
+               ret = ldb_request(ldb, req);
+               if (ret == LDB_SUCCESS) {
+                       ret = ldb_wait(req->handle, LDB_WAIT_ALL);
+               }
+
+               if (ret == LDB_SUCCESS) {
+                       ret = ldb_transaction_commit(ldb);
+               } else {
+                       DEBUG(0, ("Schema update now failed: %s\n", ldb_strerror(ret)));
+                       ldb_transaction_cancel(ldb);
+               }
+
+               talloc_free(msg);
+               talloc_free(req);
+               if (ret != LDB_SUCCESS) {
+                       DEBUG(0, ("Commit failed: %s\n", ldb_strerror(ret)));
+                       return WERR_DS_INTERNAL_FAILURE;
+               }
        }
 
        DEBUG(2,("Replicated %u objects (%u linked attributes) for %s\n",