public static LocalizedException ValidateConnectorNameReferences(TenantOutboundConnector tenantOutboundConnector, string previousName, IConfigDataProvider dataSession)
        {
            IEnumerable <TransportRule> source;

            if ((tenantOutboundConnector.IsChanged(TenantOutboundConnectorSchema.Enabled) || tenantOutboundConnector.IsChanged(TenantOutboundConnectorSchema.IsTransportRuleScoped) || tenantOutboundConnector.IsChanged(ADObjectSchema.Name)) && (!tenantOutboundConnector.Enabled || !tenantOutboundConnector.IsTransportRuleScoped || !string.Equals(previousName, tenantOutboundConnector.Name, StringComparison.OrdinalIgnoreCase)) && Utils.TryGetTransportRules(dataSession, new Utils.TransportRuleSelectionDelegate(Utils.RuleHasOutboundConnectorReference), out source, previousName) && source.Any <TransportRule>())
            {
                return(new ConnectorIncorrectUsageConnectorStillReferencedException());
            }
            return(null);
        }
 private static void ValidateSmartHostRestrictions(TenantOutboundConnector tenantOutboundConnector, Task task, bool skipIpIsNotReservedValidation)
 {
     if (tenantOutboundConnector.IsChanged(TenantOutboundConnectorSchema.SmartHosts) && !MultiValuedPropertyBase.IsNullOrEmpty(tenantOutboundConnector.SmartHosts))
     {
         MultiValuedProperty <IPRange> multiValuedProperty = null;
         bool flag = false;
         using (MultiValuedProperty <SmartHost> .Enumerator enumerator = tenantOutboundConnector.SmartHosts.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 SmartHost smartHost = enumerator.Current;
                 if (smartHost.IsIPAddress)
                 {
                     if (smartHost.Address.AddressFamily != AddressFamily.InterNetwork || !IPAddressValidation.IsValidIPv4Address(smartHost.Address.ToString()))
                     {
                         task.WriteError(new SmartHostsIPValidationFailedException(smartHost.Address.ToString()), ErrorCategory.InvalidArgument, null);
                     }
                     if (!skipIpIsNotReservedValidation)
                     {
                         if (IPAddressValidation.IsReservedIPv4Address(smartHost.Address.ToString()))
                         {
                             task.WriteError(new IPRangeInConnectorContainsReservedIPAddressesException(smartHost.Address.ToString()), ErrorCategory.InvalidArgument, null);
                         }
                         if (!flag)
                         {
                             if (!HygieneDCSettings.GetFfoDCPublicIPAddresses(out multiValuedProperty))
                             {
                                 task.WriteError(new ConnectorValidationFailedException(), ErrorCategory.ConnectionError, null);
                             }
                             flag = true;
                         }
                         if (!MultiValuedPropertyBase.IsNullOrEmpty(multiValuedProperty))
                         {
                             if (multiValuedProperty.Any((IPRange ffoDCIP) => ffoDCIP.Contains(smartHost.Address)))
                             {
                                 task.WriteError(new IPRangeInConnectorContainsReservedIPAddressesException(smartHost.Address.ToString()), ErrorCategory.InvalidArgument, null);
                             }
                         }
                     }
                 }
             }
         }
     }
 }