static int replmd_allow_missing_target(struct ldb_module *module,
				       TALLOC_CTX *mem_ctx,
				       struct ldb_dn *target_dn,
				       struct ldb_dn *source_dn,
				       bool is_obj_commit,
				       struct GUID *guid,
				       uint32_t dsdb_repl_flags,
				       bool *ignore_link,
				       const char * missing_str)
{
	struct ldb_context *ldb = ldb_module_get_ctx(module);
	bool is_in_same_nc;

	/*
	 * we may not be able to resolve link targets properly when
	 * dealing with subsets of objects, e.g. the source is a
	 * critical object and the target isn't
	 *
	 * TODO:
	 * When we implement Trusted Domains we need to consider
	 * whether they get treated as an incomplete replica here or not
	 */
	if (dsdb_repl_flags & DSDB_REPL_FLAG_OBJECT_SUBSET) {

		/*
		 * Ignore the link. We don't increase the highwater-mark in
		 * the object subset cases, so subsequent replications should
		 * resolve any missing links
		 */
		DEBUG(2, ("%s target %s linked from %s\n", missing_str,
			  ldb_dn_get_linearized(target_dn),
			  ldb_dn_get_linearized(source_dn)));
		*ignore_link = true;
		return LDB_SUCCESS;
	}

	is_in_same_nc = dsdb_objects_have_same_nc(ldb,
						  mem_ctx,
						  source_dn,
						  target_dn);
	if (is_in_same_nc) {

		/*
		 * if the target is already be up-to-date there's no point in
		 * retrying. This could be due to bad timing, or if a target
		 * on a one-way link was deleted. We ignore the link rather
		 * than failing the replication cycle completely
		 */
		if (dsdb_repl_flags & DSDB_REPL_FLAG_TARGETS_UPTODATE) {
			*ignore_link = true;
			DBG_WARNING("%s is %s "
				    "but up to date. Ignoring link from %s\n",
				    ldb_dn_get_linearized(target_dn), missing_str,
				    ldb_dn_get_linearized(source_dn));
			return LDB_SUCCESS;
		}

		/* otherwise fail the replication and retry with GET_TGT */
		ldb_asprintf_errstring(ldb, "%s target %s GUID %s linked from %s\n",
				       missing_str,
				       ldb_dn_get_linearized(target_dn),
				       GUID_string(mem_ctx, guid),
				       ldb_dn_get_linearized(source_dn));
		return LDB_ERR_NO_SUCH_OBJECT;
	}

	/*
	 * The target of the cross-partition link is missing. Continue
	 * and try to at least add the forward-link. This isn't great,
	 * but a partial link can be fixed by dbcheck, so it's better
	 * than dropping the link completely.
	 */
	*ignore_link = false;

	if (is_obj_commit) {

		/*
		 * Only log this when we're actually committing the objects.
		 * This avoids spurious logs, i.e. if we're just verifying the
		 * received link during a join.
		 */
		DBG_WARNING("%s cross-partition target %s linked from %s\n",
			    missing_str, ldb_dn_get_linearized(target_dn),
			    ldb_dn_get_linearized(source_dn));
	}
	
	return LDB_SUCCESS;
}
static int replmd_allow_missing_target(struct ldb_module *module,
				       TALLOC_CTX *mem_ctx,
				       struct ldb_dn *target_dn,
				       struct ldb_dn *source_dn,
				       bool is_obj_commit,
				       struct GUID *guid,
				       uint32_t dsdb_repl_flags,
				       bool *ignore_link,
				       const char * missing_str)
{
	struct ldb_context *ldb = ldb_module_get_ctx(module);
	bool is_in_same_nc;

	 
	if (dsdb_repl_flags & DSDB_REPL_FLAG_OBJECT_SUBSET) {

		 
		DEBUG(2, ("%s target %s linked from %s\n", missing_str,
			  ldb_dn_get_linearized(target_dn),
			  ldb_dn_get_linearized(source_dn)));
		*ignore_link = true;
		return LDB_SUCCESS;
	}

	is_in_same_nc = dsdb_objects_have_same_nc(ldb,
						  mem_ctx,
						  source_dn,
						  target_dn);
	if (is_in_same_nc) {

		 
		if (dsdb_repl_flags & DSDB_REPL_FLAG_TARGETS_UPTODATE) {
			*ignore_link = true;
			DBG_WARNING("%s is %s "
				    "but up to date. Ignoring link from %s\n",
				    ldb_dn_get_linearized(target_dn), missing_str,
				    ldb_dn_get_linearized(source_dn));
			return LDB_SUCCESS;
		}

		 
		ldb_asprintf_errstring(ldb, "%s target %s GUID %s linked from %s\n",
				       missing_str,
				       ldb_dn_get_linearized(target_dn),
				       GUID_string(mem_ctx, guid),
				       ldb_dn_get_linearized(source_dn));
		return LDB_ERR_NO_SUCH_OBJECT;
	}

	 
	*ignore_link = false;

	if (is_obj_commit) {

		 
		DBG_WARNING("%s cross-partition target %s linked from %s\n",
			    missing_str, ldb_dn_get_linearized(target_dn),
			    ldb_dn_get_linearized(source_dn));
	}
	
	return LDB_SUCCESS;
}