dsdb: Force a schema reload before dealing with replicated objects
authorAndrew Bartlett <abartlet@samba.org>
Sat, 22 Jun 2013 08:02:02 +0000 (18:02 +1000)
committerStefan Metzmacher <metze@samba.org>
Sun, 29 Jun 2014 21:45:23 +0000 (23:45 +0200)
The schema is critical here, we should always ensure it is current.

Andrew Bartlett

source4/dsdb/repl/replicated_objects.c
source4/rpc_server/drsuapi/getncchanges.c

index 97b8b2a7a3a16e42a7428eef7fc4cfe25c7fc80b..4614857780c9473c4decc41c38723780e5414181 100644 (file)
@@ -768,6 +768,18 @@ WERROR dsdb_replicated_objects_commit(struct ldb_context *ldb,
                        TALLOC_FREE(tmp_ctx);
                        return WERR_INTERNAL_ERROR;
                }
+       } else {
+               /* Force a reload of whatever schema is on the DB, if it is DB based */
+               struct dsdb_schema *refresh_schema = NULL;
+               refresh_schema = dsdb_get_schema(ldb, tmp_ctx);
+               refresh_schema->last_refresh = 0;
+               refresh_schema->metadata_usn = 0;
+               talloc_unlink(tmp_ctx, refresh_schema);
+               refresh_schema = dsdb_get_schema(ldb, tmp_ctx);
+               if (!refresh_schema) {
+                       DEBUG(0,("Schema reload failed\n"));
+                       return WERR_DS_DRA_INTERNAL_ERROR;
+               }
        }
 
        ret = ldb_extended(ldb, DSDB_EXTENDED_REPLICATED_OBJECTS_OID, objects, &ext_res);
index 9a405fd86451c46c08c9bf0f1bf9a5900da57d72..c6e5aa181e0890582715c5a4e29a1cce77ae713c 100644 (file)
@@ -1841,6 +1841,17 @@ allowed:
                return WERR_DS_DRA_INTERNAL_ERROR;
        }
 
+       /* Force a reload */
+       schema->last_refresh = 0;
+       schema->metadata_usn = 0;
+       talloc_unlink(mem_ctx, schema);
+
+       schema = dsdb_get_schema(sam_ctx, mem_ctx);
+       if (!schema) {
+               DEBUG(0,("No schema in sam_ctx\n"));
+               return WERR_DS_DRA_INTERNAL_ERROR;
+       }
+
        r->out.ctr->ctr6.naming_context = talloc(mem_ctx, struct drsuapi_DsReplicaObjectIdentifier);
        *r->out.ctr->ctr6.naming_context = *ncRoot;