samdb rid: clear cache to prevent old ntds_guid
authorAaron Haslett <aaronhaslett@catalyst.net.nz>
Tue, 1 May 2018 03:51:10 +0000 (15:51 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 12 May 2018 07:15:07 +0000 (09:15 +0200)
During the new samba-tool domain backup restore the NTDS GUID changes
as the server is taken over by the new DC record.

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dsdb/samdb/ldb_modules/ridalloc.c

index abfe14a5a805958675a32bed43d5be6567b7fe79..b436b9b5435e996ca9b487bdde6bc13a8e515dd3 100644 (file)
@@ -443,6 +443,12 @@ int ridalloc_create_own_rid_set(struct ldb_module *module, TALLOC_CTX *mem_ctx,
                return ldb_operr(ldb_module_get_ctx(module));
        }
 
+       /* clear the cache so we don't get an old ntds_guid */
+       if (ldb_set_opaque(ldb, "cache.ntds_guid", NULL) != LDB_SUCCESS) {
+               talloc_free(tmp_ctx);
+               return ldb_operr(ldb_module_get_ctx(module));
+       }
+
        our_ntds_guid = samdb_ntds_objectGUID(ldb_module_get_ctx(module));
        if (!our_ntds_guid) {
                talloc_free(tmp_ctx);