static int replmd_check_singleval_la_conflict(struct ldb_module *module,
					      struct replmd_private *replmd_private,
					      TALLOC_CTX *mem_ctx,
					      struct ldb_dn *src_obj_dn,
					      struct drsuapi_DsReplicaLinkedAttribute *la,
					      struct dsdb_dn *dsdb_dn,
					      struct parsed_dn *pdn_being_modified,
					      struct parsed_dn *pdn_list,
					      struct ldb_message_element *old_el,
					      const struct dsdb_schema *schema,
					      const struct dsdb_attribute *attr,
					      uint64_t seq_num,
					      bool *add_as_inactive)
{
	struct parsed_dn *active_pdn = NULL;
	bool update_is_newer = false;
	int ret;

	/*
	 * check if there's a conflict for single-valued links, i.e. an active
	 * linked attribute already exists, but it has a different target value
	 */
	ret = replmd_get_active_singleval_link(module, mem_ctx, pdn_list,
					       old_el->num_values, attr,
					       &active_pdn);

	if (ret != LDB_SUCCESS) {
		return ret;
	}

	/*
	 * If no active value exists (or the received info is for the currently
	 * active value), then no conflict exists
	 */
	if (active_pdn == NULL || active_pdn == pdn_being_modified) {
		return LDB_SUCCESS;
	}

	DBG_WARNING("Link conflict for %s attribute on %s\n",
		    attr->lDAPDisplayName, ldb_dn_get_linearized(src_obj_dn));

	/* Work out how to resolve the conflict based on which info is better */
	update_is_newer = replmd_link_update_is_newer(active_pdn, la);

	if (update_is_newer) {
		DBG_WARNING("Using received value %s, over existing target %s\n",
			    ldb_dn_get_linearized(dsdb_dn->dn),
			    ldb_dn_get_linearized(active_pdn->dsdb_dn->dn));

		/*
		 * Delete our existing active link. The received info will then
		 * be added (through normal link processing) as the active value
		 */
		ret = replmd_delete_link_value(module, replmd_private, old_el,
					       src_obj_dn, schema, attr,
					       seq_num, true, &active_pdn->guid,
					       active_pdn->dsdb_dn,
					       active_pdn->v);

		if (ret != LDB_SUCCESS) {
			return ret;
		}
	} else {
		DBG_WARNING("Using existing target %s, over received value %s\n",
			    ldb_dn_get_linearized(active_pdn->dsdb_dn->dn),
			    ldb_dn_get_linearized(dsdb_dn->dn));

		/*
		 * we want to keep our existing active link and add the
		 * received link as inactive
		 */
		*add_as_inactive = true;
	}

	return LDB_SUCCESS;
}
static int replmd_check_singleval_la_conflict(struct ldb_module *module,
					      struct replmd_private *replmd_private,
					      TALLOC_CTX *mem_ctx,
					      struct ldb_dn *src_obj_dn,
					      struct drsuapi_DsReplicaLinkedAttribute *la,
					      struct dsdb_dn *dsdb_dn,
					      struct parsed_dn *pdn_being_modified,
					      struct parsed_dn *pdn_list,
					      struct ldb_message_element *old_el,
					      const struct dsdb_schema *schema,
					      const struct dsdb_attribute *attr,
					      uint64_t seq_num,
					      bool *add_as_inactive)
{
	struct parsed_dn *active_pdn = NULL;
	bool update_is_newer = false;
	int ret;

	 
	ret = replmd_get_active_singleval_link(module, mem_ctx, pdn_list,
					       old_el->num_values, attr,
					       &active_pdn);

	if (ret != LDB_SUCCESS) {
		return ret;
	}

	 
	if (active_pdn == NULL || active_pdn == pdn_being_modified) {
		return LDB_SUCCESS;
	}

	DBG_WARNING("Link conflict for %s attribute on %s\n",
		    attr->lDAPDisplayName, ldb_dn_get_linearized(src_obj_dn));

	 
	update_is_newer = replmd_link_update_is_newer(active_pdn, la);

	if (update_is_newer) {
		DBG_WARNING("Using received value %s, over existing target %s\n",
			    ldb_dn_get_linearized(dsdb_dn->dn),
			    ldb_dn_get_linearized(active_pdn->dsdb_dn->dn));

		 
		ret = replmd_delete_link_value(module, replmd_private, old_el,
					       src_obj_dn, schema, attr,
					       seq_num, true, &active_pdn->guid,
					       active_pdn->dsdb_dn,
					       active_pdn->v);

		if (ret != LDB_SUCCESS) {
			return ret;
		}
	} else {
		DBG_WARNING("Using existing target %s, over received value %s\n",
			    ldb_dn_get_linearized(active_pdn->dsdb_dn->dn),
			    ldb_dn_get_linearized(dsdb_dn->dn));

		 
		*add_as_inactive = true;
	}

	return LDB_SUCCESS;
}