private static OrganizationRelationship ProvisionOrganizationRelationship(ICommonSession session, OrganizationRelationship existingOrgRel, IFederationInformation federationInfo, IEnumerable <SmtpDomain> domains, string relationshipName)
        {
            if (existingOrgRel != null)
            {
                session.RemoveOrganizationRelationship(existingOrgRel.Identity.ToString());
            }
            string targetApplicationUri  = (federationInfo != null) ? federationInfo.TargetApplicationUri : null;
            string targetAutodiscoverEpr = (federationInfo != null) ? federationInfo.TargetAutodiscoverEpr : null;

            session.NewOrganizationRelationship(relationshipName, targetApplicationUri, targetAutodiscoverEpr, domains);
            existingOrgRel = TaskCommon.GetOrganizationRelationship(session, relationshipName, from d in domains
                                                                    select d.Domain);
            if (existingOrgRel == null)
            {
                throw new LocalizedException(HybridStrings.ErrorOrgRelProvisionFailed(domains.First <SmtpDomain>().ToString()));
            }
            return(existingOrgRel);
        }