static bool samdb_set_ntds_GUID(struct ldb_context *ldb,
				const struct GUID *ntds_guid_in,
				const char *attribute,
				const char *cache_name)
{
	TALLOC_CTX *tmp_ctx;
	struct GUID *ntds_guid_new;
	struct GUID *ntds_guid_old;

	/* see if we have a cached copy */
	ntds_guid_old = (struct GUID *)ldb_get_opaque(ldb, cache_name);

	tmp_ctx = talloc_new(ldb);
	if (tmp_ctx == NULL) {
		goto failed;
	}

	ntds_guid_new = talloc(tmp_ctx, struct GUID);
	if (!ntds_guid_new) {
		goto failed;
	}

	*ntds_guid_new = *ntds_guid_in;

	/* cache the domain_sid in the ldb */
	if (ldb_set_opaque(ldb, cache_name, ntds_guid_new) != LDB_SUCCESS) {
		goto failed;
	}

	talloc_steal(ldb, ntds_guid_new);
	talloc_free(tmp_ctx);
	talloc_free(ntds_guid_old);

	return true;

failed:
	DBG_WARNING("Failed to set our own cached %s in the ldb!\n",
		    attribute);
	talloc_free(tmp_ctx);
	return false;
}
static bool samdb_set_ntds_GUID(struct ldb_context *ldb,
				const struct GUID *ntds_guid_in,
				const char *attribute,
				const char *cache_name)
{
	TALLOC_CTX *tmp_ctx;
	struct GUID *ntds_guid_new;
	struct GUID *ntds_guid_old;

	 
	ntds_guid_old = (struct GUID *)ldb_get_opaque(ldb, cache_name);

	tmp_ctx = talloc_new(ldb);
	if (tmp_ctx == NULL) {
		goto failed;
	}

	ntds_guid_new = talloc(tmp_ctx, struct GUID);
	if (!ntds_guid_new) {
		goto failed;
	}

	*ntds_guid_new = *ntds_guid_in;

	 
	if (ldb_set_opaque(ldb, cache_name, ntds_guid_new) != LDB_SUCCESS) {
		goto failed;
	}

	talloc_steal(ldb, ntds_guid_new);
	talloc_free(tmp_ctx);
	talloc_free(ntds_guid_old);

	return true;

failed:
	DBG_WARNING("Failed to set our own cached %s in the ldb!\n",
		    attribute);
	talloc_free(tmp_ctx);
	return false;
}