public static void ValidateIfAcceptedDomainsCanBeRoutedWithConnectors(TenantOutboundConnector dataObject, IConfigDataProvider dataSession, Task task, bool dataObjectDeleted = false)
        {
            ArgumentValidator.ThrowIfNull("dataObject", dataObject);
            ArgumentValidator.ThrowIfNull("dataSession", dataSession);
            ArgumentValidator.ThrowIfNull("task", task);
            if (!VariantConfiguration.InvariantNoFlightingSnapshot.Transport.EnforceOutboundConnectorAndAcceptedDomainsRestriction.Enabled)
            {
                return;
            }
            if (!dataObjectDeleted && dataObject.Enabled && dataObject.ConnectorType == TenantConnectorType.OnPremises && dataObject.AllAcceptedDomains)
            {
                return;
            }
            List <SmtpDomainWithSubdomains> nonAuthoritativeAcceptedDomains = ManageTenantOutboundConnectors.GetNonAuthoritativeAcceptedDomains(dataSession);

            if (nonAuthoritativeAcceptedDomains == null)
            {
                return;
            }
            List <SmtpDomainWithSubdomains> source;

            if (!ManageTenantOutboundConnectors.ValidateIfConnectorsCanRouteDomains(ManageTenantOutboundConnectors.GetOutboundConnectorsToValidate(dataSession, dataObjectDeleted ? null : dataObject), nonAuthoritativeAcceptedDomains, out source))
            {
                task.WriteWarning(Strings.AcceptedDomainsCannotBeRoutedByOutboundConnector(string.Join(",", from d in source
                                                                                                       select d.Domain)));
            }
        }
        public static bool ValidateIfAcceptedDomainCanBeRoutedUsingConnectors(IConfigDataProvider dataSession, SmtpDomainWithSubdomains acceptedDomain)
        {
            ArgumentValidator.ThrowIfNull("dataSession", dataSession);
            ArgumentValidator.ThrowIfNull("acceptedDomain", acceptedDomain);
            TenantOutboundConnector[]       connectors = (TenantOutboundConnector[])dataSession.Find <TenantOutboundConnector>(null, null, true, null);
            List <SmtpDomainWithSubdomains> list;

            return(ManageTenantOutboundConnectors.ValidateIfConnectorsCanRouteDomains(connectors, new SmtpDomainWithSubdomains[]
            {
                acceptedDomain
            }, out list));
        }