static int replmd_verify_link_target(struct replmd_replicated_request *ar,
				     TALLOC_CTX *mem_ctx,
				     struct la_entry *la_entry,
				     struct ldb_dn *src_dn,
				     const struct dsdb_attribute *attr)
{
	int ret = LDB_SUCCESS;
	struct ldb_module *module = ar->module;
	struct dsdb_dn *tgt_dsdb_dn = NULL;
	struct GUID guid = GUID_zero();
	bool dummy;
	WERROR status;
	struct ldb_context *ldb = ldb_module_get_ctx(module);
	struct drsuapi_DsReplicaLinkedAttribute *la = la_entry->la;
	const struct dsdb_schema *schema = dsdb_get_schema(ldb, mem_ctx);

	/* the value blob for the attribute holds the target object DN */
	status = dsdb_dn_la_from_blob(ldb, attr, schema, mem_ctx,
				      la->value.blob, &tgt_dsdb_dn);
	if (!W_ERROR_IS_OK(status)) {
		ldb_asprintf_errstring(ldb, "Failed to parsed linked attribute blob for %s on %s - %s\n",
				       attr->lDAPDisplayName,
				       ldb_dn_get_linearized(src_dn),
				       win_errstr(status));
		return LDB_ERR_OPERATIONS_ERROR;
	}

	/*
	 * We can skip the target object checks if we're only syncing critical
	 * objects, or we know the target is up-to-date. If either case, we
	 * still continue even if the target doesn't exist
	 */
	if ((la_entry->dsdb_repl_flags & (DSDB_REPL_FLAG_OBJECT_SUBSET |
					  DSDB_REPL_FLAG_TARGETS_UPTODATE)) == 0) {

		ret = replmd_check_target_exists(module, tgt_dsdb_dn, la_entry,
						 src_dn, false, &guid, &dummy);
	}

	/*
	 * When we fail to find the target object, the error code we pass
	 * back here is really important. It flags back to the callers to
	 * retry this request with DRSUAPI_DRS_GET_TGT
	 */
	if (ret == LDB_ERR_NO_SUCH_OBJECT) {
		ret = replmd_replicated_request_werror(ar, WERR_DS_DRA_RECYCLED_TARGET);
	}

	return ret;
}
static int replmd_verify_link_target(struct replmd_replicated_request *ar,
				     TALLOC_CTX *mem_ctx,
				     struct la_entry *la_entry,
				     struct ldb_dn *src_dn,
				     const struct dsdb_attribute *attr)
{
	int ret = LDB_SUCCESS;
	struct ldb_module *module = ar->module;
	struct dsdb_dn *tgt_dsdb_dn = NULL;
	struct GUID guid = GUID_zero();
	bool dummy;
	WERROR status;
	struct ldb_context *ldb = ldb_module_get_ctx(module);
	struct drsuapi_DsReplicaLinkedAttribute *la = la_entry->la;
	const struct dsdb_schema *schema = dsdb_get_schema(ldb, mem_ctx);

	 
	status = dsdb_dn_la_from_blob(ldb, attr, schema, mem_ctx,
				      la->value.blob, &tgt_dsdb_dn);
	if (!W_ERROR_IS_OK(status)) {
		ldb_asprintf_errstring(ldb, "Failed to parsed linked attribute blob for %s on %s - %s\n",
				       attr->lDAPDisplayName,
				       ldb_dn_get_linearized(src_dn),
				       win_errstr(status));
		return LDB_ERR_OPERATIONS_ERROR;
	}

	 
	if ((la_entry->dsdb_repl_flags & (DSDB_REPL_FLAG_OBJECT_SUBSET |
					  DSDB_REPL_FLAG_TARGETS_UPTODATE)) == 0) {

		ret = replmd_check_target_exists(module, tgt_dsdb_dn, la_entry,
						 src_dn, false, &guid, &dummy);
	}

	 
	if (ret == LDB_ERR_NO_SUCH_OBJECT) {
		ret = replmd_replicated_request_werror(ar, WERR_DS_DRA_RECYCLED_TARGET);
	}

	return ret;
}