Пример #1
0
        internal static T NewIPListEntry <T>(IPFilterRange range) where T : IConfigurable, new()
        {
            IPListEntry iplistEntry = (IPListEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T)));

            IPRange.Format  format          = (IPRange.Format)(range.Flags & 15);
            IPListEntryType iplistEntryType = (IPListEntryType)(range.Flags >> 4 & 15);

            IPListEntry.AuthorType authorType = (IPListEntry.AuthorType)(range.Flags >> 8 & 15);
            iplistEntry.identity = new IPListEntryIdentity(range.Identity);
            ulong high;
            ulong low;

            range.GetLowerBound(out high, out low);
            IPvxAddress startAddress = new IPvxAddress(high, low);

            range.GetUpperBound(out high, out low);
            IPvxAddress endAddress = new IPvxAddress(high, low);

            iplistEntry.range              = new IPRange(startAddress, endAddress, format);
            iplistEntry.expirationTimeUtc  = range.ExpiresOn.ToUniversalTime();
            iplistEntry.isMachineGenerated = (authorType == IPListEntry.AuthorType.Automatic);
            iplistEntry.listType           = iplistEntryType;
            iplistEntry.comment            = range.Comment;
            return((T)((object)iplistEntry));
        }
Пример #2
0
        private static IPAddress Mask(IPAddress iPAddress, int maskBits)
        {
            IPvxAddress v    = new IPvxAddress(iPAddress);
            IPvxAddress mask = ~(~IPvxAddress.Zero >> maskBits);

            return(v & mask);
        }
        protected override void ValidateWrite(List <ValidationError> errors)
        {
            base.ValidateWrite(errors);
            if (MultiValuedPropertyBase.IsNullOrEmpty(base.ConnectedDomains) && MultiValuedPropertyBase.IsNullOrEmpty(base.AddressSpaces))
            {
                errors.Add(new PropertyValidationError(DirectoryStrings.NoAddressSpaces, MailGatewaySchema.AddressSpaces, this));
            }
            if (!this.DNSRoutingEnabled && MultiValuedPropertyBase.IsNullOrEmpty(this.SmartHosts))
            {
                errors.Add(new PropertyValidationError(DirectoryStrings.SmartHostNotSet, SmtpSendConnectorConfigSchema.SmartHosts, this));
            }
            IPvxAddress pvxAddress = new IPvxAddress(this.SourceIPAddress);

            if (pvxAddress.IsMulticast || pvxAddress.IsBroadcast)
            {
                errors.Add(new PropertyValidationError(DirectoryStrings.InvalidSourceAddressSetting, SmtpSendConnectorConfigSchema.SourceIPAddress, this));
            }
            if ((this.SmartHostAuthMechanism == SmtpSendConnectorConfig.AuthMechanisms.BasicAuth || this.SmartHostAuthMechanism == SmtpSendConnectorConfig.AuthMechanisms.BasicAuthRequireTLS) && this.AuthenticationCredential == null)
            {
                errors.Add(new PropertyValidationError(DirectoryStrings.AuthenticationCredentialNotSet, SmtpSendConnectorConfigSchema.AuthenticationCredential, this));
            }
            if (this.DomainSecureEnabled)
            {
                if (!this.DNSRoutingEnabled)
                {
                    errors.Add(new PropertyValidationError(DirectoryStrings.DomainSecureWithoutDNSRoutingEnabled, SmtpSendConnectorConfigSchema.DNSRoutingEnabled, this));
                }
                if (this.IgnoreSTARTTLS)
                {
                    errors.Add(new PropertyValidationError(DirectoryStrings.DomainSecureWithIgnoreStartTLSEnabled, SmtpSendConnectorConfigSchema.IgnoreSTARTTLS, this));
                }
            }
            if (this.TlsAuthLevel != null)
            {
                if (!this.RequireTLS)
                {
                    errors.Add(new PropertyValidationError(DirectoryStrings.TlsAuthLevelWithRequireTlsDisabled, SmtpSendConnectorConfigSchema.TlsAuthLevel, this));
                }
                if (this.DomainSecureEnabled)
                {
                    errors.Add(new PropertyValidationError(DirectoryStrings.TlsAuthLevelWithDomainSecureEnabled, SmtpSendConnectorConfigSchema.TlsAuthLevel, this));
                }
            }
            if (this.TlsDomain != null)
            {
                if (this.TlsAuthLevel == null || this.TlsAuthLevel.Value != Microsoft.Exchange.Data.TlsAuthLevel.DomainValidation)
                {
                    errors.Add(new PropertyValidationError(DirectoryStrings.TlsDomainWithIncorrectTlsAuthLevel, SmtpSendConnectorConfigSchema.TlsDomain, this));
                    return;
                }
            }
            else if (!this.DNSRoutingEnabled && this.TlsAuthLevel != null && this.TlsAuthLevel.Value == Microsoft.Exchange.Data.TlsAuthLevel.DomainValidation)
            {
                errors.Add(new PropertyValidationError(DirectoryStrings.TlsAuthLevelWithNoDomainOnSmartHost, SmtpSendConnectorConfigSchema.TlsDomain, this));
            }
        }
Пример #4
0
        internal IPFilterRange ToIPFilterRange()
        {
            IPFilterRange ipfilterRange = new IPFilterRange();

            ipfilterRange.ExpiresOn = this.expirationTimeUtc;
            IPvxAddress pvxAddress = this.IPRange.LowerBound;

            ipfilterRange.SetLowerBound((ulong)(pvxAddress >> 64), (ulong)pvxAddress);
            pvxAddress = this.IPRange.UpperBound;
            ipfilterRange.SetUpperBound((ulong)(pvxAddress >> 64), (ulong)pvxAddress);
            ipfilterRange.Flags   = (int)this.IPRange.RangeFormat;
            ipfilterRange.Comment = this.comment;
            return(ipfilterRange);
        }
Пример #5
0
 protected override void InternalValidate()
 {
     try
     {
         base.InternalValidate();
         Schema.Utilities.ValidateParameters(this, () => base.ConfigSession, new HashSet <CmdletValidator.ValidatorTypes>
         {
             CmdletValidator.ValidatorTypes.Preprocessing
         });
         Schema.Utilities.VerifyDateRange(this.StartDate, this.EndDate);
         DateTime dateTime = (DateTime)ExDateTime.UtcNow;
         int      days     = dateTime.Subtract(this.StartDate).Days;
         if (days > 90)
         {
             base.WriteError(new ArgumentException(Strings.InvalidStartDate(90)), ErrorCategory.InvalidArgument, null);
         }
         if (this.EndDate > dateTime)
         {
             this.EndDate = dateTime;
         }
         if ((this.ReportType == HistoricalSearchReportType.MessageTrace || this.ReportType == HistoricalSearchReportType.MessageTraceDetail) && this.MessageID == null && this.RecipientAddress == null && this.SenderAddress == null)
         {
             base.WriteError(new ArgumentException(Strings.MessageTraceMinimumCriteriaFieldsInErrorDeliveryStatus), ErrorCategory.InvalidArgument, null);
         }
         if (!string.IsNullOrEmpty(this.OriginalClientIP))
         {
             IPvxAddress none = IPvxAddress.None;
             if (!IPvxAddress.TryParse(this.OriginalClientIP, out none))
             {
                 base.WriteError(new ArgumentException(Strings.InvalidIPAddress(this.OriginalClientIP)), ErrorCategory.InvalidArgument, null);
             }
         }
     }
     catch (InvalidExpressionException exception)
     {
         base.WriteError(exception, ErrorCategory.InvalidArgument, null);
     }
     catch (Exception exception2)
     {
         base.WriteError(exception2, ErrorCategory.InvalidOperation, null);
     }
 }
Пример #6
0
 protected override void InternalValidate()
 {
     try
     {
         base.InternalValidate();
         Schema.Utilities.ValidateParameters(this, () => base.ConfigSession, new HashSet <CmdletValidator.ValidatorTypes>
         {
             CmdletValidator.ValidatorTypes.Preprocessing
         });
         Schema.Utilities.VerifyDateRange(this.StartDate, this.EndDate);
         DateTime dateTime = (DateTime)ExDateTime.UtcNow;
         int      days     = dateTime.Subtract(this.StartDate).Days;
         if (days > 90)
         {
             base.WriteError(new ArgumentException(Strings.InvalidStartDate(90)), ErrorCategory.InvalidArgument, null);
         }
         if (this.EndDate > dateTime)
         {
             this.EndDate = dateTime;
         }
         if (!string.IsNullOrEmpty(this.OriginalClientIP))
         {
             IPvxAddress none = IPvxAddress.None;
             if (!IPvxAddress.TryParse(this.OriginalClientIP, out none))
             {
                 base.WriteError(new ArgumentException(Strings.InvalidIPAddress(this.OriginalClientIP)), ErrorCategory.InvalidArgument, null);
             }
         }
     }
     catch (InvalidExpressionException exception)
     {
         base.WriteError(exception, ErrorCategory.InvalidArgument, null);
     }
     catch (Exception exception2)
     {
         base.WriteError(exception2, ErrorCategory.InvalidOperation, null);
     }
 }
Пример #7
0
            private IEnumerator <IPFilterRange[]> GetPages()
            {
                bool        finished     = false;
                int         startIndex   = 0;
                IPvxAddress address      = (this.filter != null) ? this.filter.Address : IPvxAddress.None;
                int         listTypeMask = this.provider.GetFilterMask <T>();

                while (!finished)
                {
                    IPFilterRange[] matches = this.provider.GetItems(startIndex, listTypeMask, address, this.pageSize);
                    if (matches == null || matches.Length <= 0)
                    {
                        finished = true;
                    }
                    else
                    {
                        yield return(matches);

                        startIndex = matches[matches.Length - 1].Identity + 1;
                    }
                }
                yield break;
            }
Пример #8
0
 private IPFilterRange[] GetItems(int startIndex, int typeFilter, IPvxAddress address, int count)
 {
     return((IPFilterRange[])RpcClientHelper.Invoke(() => this.connection.GetItems(startIndex, typeFilter, (ulong)(address >> 64), (ulong)address, count)));
 }