static int samldb_check_linkid_used(struct samldb_ctx *ac,
				    struct dsdb_schema *schema,
				    struct ldb_dn *schema_dn,
				    struct ldb_context *ldb,
				    int32_t linkID,
				    bool *found)
{
	int ret;
	struct ldb_result *ldb_res;

	if (dsdb_attribute_by_linkID(schema, linkID)) {
		*found = true;
		return LDB_SUCCESS;
	}

	ret = dsdb_module_search(ac->module, ac,
				 &ldb_res,
				 schema_dn, LDB_SCOPE_ONELEVEL, NULL,
				 DSDB_FLAG_NEXT_MODULE,
				 ac->req,
				 "(linkID=%d)", linkID);
	if (ret != LDB_SUCCESS) {
		ldb_debug_set(ldb, LDB_DEBUG_ERROR,
			      __location__": Searching for linkID=%d failed - %s\n",
			      linkID,
			      ldb_errstring(ldb));
		return ldb_operr(ldb);
	}

	*found = (ldb_res->count != 0);
	talloc_free(ldb_res);

	return LDB_SUCCESS;
}
static int samldb_check_linkid_used(struct samldb_ctx *ac,
				    struct dsdb_schema *schema,
				    struct ldb_dn *schema_dn,
				    struct ldb_context *ldb,
				    int32_t linkID,
				    bool *found)
{
	int ret;
	struct ldb_result *ldb_res;

	if (dsdb_attribute_by_linkID(schema, linkID)) {
		*found = true;
		return LDB_SUCCESS;
	}

	ret = dsdb_module_search(ac->module, ac,
				 &ldb_res,
				 schema_dn, LDB_SCOPE_ONELEVEL, NULL,
				 DSDB_FLAG_NEXT_MODULE,
				 ac->req,
				 "(linkID=%d)", linkID);
	if (ret != LDB_SUCCESS) {
		ldb_debug_set(ldb, LDB_DEBUG_ERROR,
			      __location__": Searching for linkID=%d failed - %s\n",
			      linkID,
			      ldb_errstring(ldb));
		return ldb_operr(ldb);
	}

	*found = (ldb_res->count != 0);
	talloc_free(ldb_res);

	return LDB_SUCCESS;
}