bool dsdb_objects_have_same_nc(struct ldb_context *ldb,
			       TALLOC_CTX *mem_ctx,
			       struct ldb_dn *source_dn,
			       struct ldb_dn *target_dn)
{
	TALLOC_CTX *tmp_ctx;
	struct ldb_dn *source_nc = NULL;
	struct ldb_dn *target_nc = NULL;
	int ret;
	bool same_nc = true;

	tmp_ctx = talloc_new(mem_ctx);

	ret = dsdb_find_nc_root(ldb, tmp_ctx, source_dn, &source_nc);
	/* fix clang warning */
	if (source_nc == NULL) {
		ret = LDB_ERR_OTHER;
	}
	if (ret != LDB_SUCCESS) {
		DBG_ERR("Failed to find base DN for source %s\n",
			ldb_dn_get_linearized(source_dn));
		talloc_free(tmp_ctx);
		return true;
	}

	ret = dsdb_find_nc_root(ldb, tmp_ctx, target_dn, &target_nc);
	/* fix clang warning */
	if (target_nc == NULL) {
		ret = LDB_ERR_OTHER;
	}
	if (ret != LDB_SUCCESS) {
		DBG_ERR("Failed to find base DN for target %s\n",
			ldb_dn_get_linearized(target_dn));
		talloc_free(tmp_ctx);
		return true;
	}

	same_nc = (ldb_dn_compare(source_nc, target_nc) == 0);

	talloc_free(tmp_ctx);

	return same_nc;
}
bool dsdb_objects_have_same_nc(struct ldb_context *ldb,
			       TALLOC_CTX *mem_ctx,
			       struct ldb_dn *source_dn,
			       struct ldb_dn *target_dn)
{
	TALLOC_CTX *tmp_ctx;
	struct ldb_dn *source_nc = NULL;
	struct ldb_dn *target_nc = NULL;
	int ret;
	bool same_nc = true;

	tmp_ctx = talloc_new(mem_ctx);

	ret = dsdb_find_nc_root(ldb, tmp_ctx, source_dn, &source_nc);
	 
	if (source_nc == NULL) {
		ret = LDB_ERR_OTHER;
	}
	if (ret != LDB_SUCCESS) {
		DBG_ERR("Failed to find base DN for source %s\n",
			ldb_dn_get_linearized(source_dn));
		talloc_free(tmp_ctx);
		return true;
	}

	ret = dsdb_find_nc_root(ldb, tmp_ctx, target_dn, &target_nc);
	 
	if (target_nc == NULL) {
		ret = LDB_ERR_OTHER;
	}
	if (ret != LDB_SUCCESS) {
		DBG_ERR("Failed to find base DN for target %s\n",
			ldb_dn_get_linearized(target_dn));
		talloc_free(tmp_ctx);
		return true;
	}

	same_nc = (ldb_dn_compare(source_nc, target_nc) == 0);

	talloc_free(tmp_ctx);

	return same_nc;
}