示例#1
0
 private void ValidateForEnterprise(IRMConfiguration config)
 {
     if (config.ExternalLicensingEnabled && !ExternalAuthentication.GetCurrent().Enabled)
     {
         base.WriteError(new OrganizationNotFederatedException(), ErrorCategory.InvalidOperation, base.Identity);
     }
     if (config.InternalLicensingEnabled)
     {
         Uri rmsserviceLocation = RmsClientManager.GetRMSServiceLocation(OrganizationId.ForestWideOrgId, ServiceType.Certification);
         if (rmsserviceLocation == null)
         {
             base.WriteError(new NoRMSServersFoundException(), ErrorCategory.InvalidOperation, base.Identity);
         }
         this.ValidateRmsVersion(rmsserviceLocation, ServiceType.CertificationService);
         this.ValidateRmsVersion(rmsserviceLocation, ServiceType.LicensingService);
     }
     if (!MultiValuedPropertyBase.IsNullOrEmpty(config.LicensingLocation))
     {
         foreach (Uri uri in config.LicensingLocation)
         {
             if (string.IsNullOrEmpty(RMUtil.ConvertUriToLicenseUrl(uri)))
             {
                 base.WriteError(new RmsUrlIsInvalidException(uri), ErrorCategory.InvalidOperation, base.Identity);
             }
             this.ValidateRmsVersion(uri, ServiceType.LicensingService);
         }
     }
 }
 internal static void ValidateSenderIPAddressRestrictions(MultiValuedProperty <IPRange> addressRanges, MultiValuedProperty <IPRange> ffoDCIPs, MultiValuedProperty <ServiceProviderSettings> serviceProviders, Task task)
 {
     if (MultiValuedPropertyBase.IsNullOrEmpty(addressRanges))
     {
         return;
     }
     using (MultiValuedProperty <IPRange> .Enumerator enumerator = addressRanges.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             IPRange ipRange = enumerator.Current;
             if (!MultiValuedPropertyBase.IsNullOrEmpty(ffoDCIPs))
             {
                 if (ffoDCIPs.Any((IPRange ffoDCIP) => ffoDCIP.Overlaps(ipRange)))
                 {
                     task.WriteError(new SenderIPAddressOverlapsFfoDCIPAddressesException(ipRange.Expression), ErrorCategory.InvalidArgument, null);
                 }
             }
             if (!MultiValuedPropertyBase.IsNullOrEmpty(serviceProviders))
             {
                 if (serviceProviders.Any((ServiceProviderSettings serviceProvider) => serviceProvider.IPRanges != null && serviceProvider.IPRanges.Any((IPRange providerIPRange) => providerIPRange != null && providerIPRange.Overlaps(ipRange))))
                 {
                     task.WriteError(new SenderIPAddressOverlapsServiceProviderIPAddressesException(ipRange.Expression), ErrorCategory.InvalidArgument, null);
                 }
             }
         }
     }
 }
示例#3
0
            // Token: 0x06000AA7 RID: 2727 RVA: 0x0002F7E4 File Offset: 0x0002D9E4
            public override object GetValueInternal(object val)
            {
                MultiValuedPropertyBase multiValuedPropertyBase = val as MultiValuedPropertyBase;

                if (multiValuedPropertyBase == null)
                {
                    return(null);
                }
                StringBuilder stringBuilder = new StringBuilder();
                bool          flag          = true;

                foreach (object arg in ((IEnumerable)multiValuedPropertyBase))
                {
                    if (flag)
                    {
                        stringBuilder.AppendFormat("{0}", arg);
                        flag = false;
                    }
                    else
                    {
                        stringBuilder.AppendFormat(";{0}", arg);
                    }
                }
                return(stringBuilder.ToString());
            }
 protected override void ValidateWrite(List <ValidationError> errors)
 {
     base.ValidateWrite(errors);
     if (this.ConnectorType == TenantConnectorType.OnPremises && MultiValuedPropertyBase.IsNullOrEmpty(this.SenderIPAddresses) && this.TlsSenderCertificateName == null)
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.InboundConnectorMissingTlsCertificateOrSenderIP, TenantInboundConnectorSchema.RemoteIPRanges, this));
     }
     if (this.TlsSenderCertificateName != null && !this.RequireTls)
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.InboundConnectorRequiredTlsSettingsInvalid, TenantInboundConnectorSchema.RequireTls, this));
     }
     if (this.RestrictDomainsToIPAddresses && MultiValuedPropertyBase.IsNullOrEmpty(this.SenderIPAddresses))
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.InboundConnectorInvalidRestrictDomainsToIPAddresses, TenantInboundConnectorSchema.RestrictDomainsToIPAddresses, this));
     }
     if (this.RestrictDomainsToIPAddresses && this.RestrictDomainsToCertificate)
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.InboundConnectorInvalidIPCertificateCombinations, TenantInboundConnectorSchema.RestrictDomainsToCertificate, this));
     }
     if (this.RestrictDomainsToCertificate && this.TlsSenderCertificateName == null)
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.InboundConnectorInvalidRestrictDomainsToCertificate, TenantInboundConnectorSchema.RestrictDomainsToCertificate, this));
     }
     if (this.ConnectorType != TenantConnectorType.OnPremises && this.CloudServicesMailEnabled)
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.InboundConnectorIncorrectCloudServicesMailEnabled, TenantInboundConnectorSchema.CloudServicesMailEnabled, this));
     }
 }
        protected override IConfigurable PrepareDataObject()
        {
            DeliveryAgentConnector deliveryAgentConnector = (DeliveryAgentConnector)base.PrepareDataObject();

            if (!MultiValuedPropertyBase.IsNullOrEmpty(this.SourceTransportServers))
            {
                deliveryAgentConnector.SourceTransportServers = base.ResolveIdParameterCollection <ServerIdParameter, Server, ADObjectId>(this.SourceTransportServers, base.DataSession, this.RootId, null, (ExchangeErrorCategory)0, new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotFound), new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotUnique), null, null);
            }
            else
            {
                Server server = null;
                try
                {
                    server = ((ITopologyConfigurationSession)base.DataSession).ReadLocalServer();
                }
                catch (TransientException exception)
                {
                    base.WriteError(exception, ErrorCategory.ResourceUnavailable, this.DataObject);
                }
                if (server != null && server.IsHubTransportServer && server.IsExchange2007OrLater)
                {
                    deliveryAgentConnector.SourceTransportServers = new MultiValuedProperty <ADObjectId>(false, SendConnectorSchema.SourceTransportServers, new ADObjectId[]
                    {
                        server.Id
                    });
                }
            }
            if (!MultiValuedPropertyBase.IsNullOrEmpty(deliveryAgentConnector.SourceTransportServers))
            {
                ManageSendConnectors.SetConnectorHomeMta(deliveryAgentConnector, (IConfigurationSession)base.DataSession);
            }
            ManageSendConnectors.SetConnectorId(deliveryAgentConnector, ((ITopologyConfigurationSession)base.DataSession).GetRoutingGroupId());
            return(deliveryAgentConnector);
        }
示例#6
0
        // Token: 0x060039E0 RID: 14816 RVA: 0x000DFCD0 File Offset: 0x000DDED0
        internal void ApplyCloneableProperties(ADPresentationObject source)
        {
            IEnumerable <PropertyInfo> enabledPropertiesFromPropertyInfoList = ADPresentationObject.GetEnabledPropertiesFromPropertyInfoList(source);

            IEnumerable <PropertyInfo>[] array = new IEnumerable <PropertyInfo>[]
            {
                this.CloneableOnceProperties,
                this.CloneableProperties,
                enabledPropertiesFromPropertyInfoList
            };
            foreach (IEnumerable <PropertyInfo> enumerable in array)
            {
                foreach (PropertyInfo propertyInfo in enumerable)
                {
                    object value  = propertyInfo.GetValue(source, null);
                    object value2 = propertyInfo.GetValue(this, null);
                    if (value != null && value2 != value)
                    {
                        MultiValuedPropertyBase multiValuedPropertyBase = value as MultiValuedPropertyBase;
                        if (multiValuedPropertyBase == null || multiValuedPropertyBase.Count != 0)
                        {
                            if (propertyInfo.PropertyType == typeof(MultiValuedProperty <Capability>))
                            {
                                MultiValuedProperty <Capability> multiValuedProperty = (MultiValuedProperty <Capability>)value;
                                CapabilityHelper.SetSKUCapability((multiValuedProperty.Count == 0) ? null : new Capability?(multiValuedProperty[0]), (MultiValuedProperty <Capability>)value2);
                            }
                            else
                            {
                                propertyInfo.SetValue(this, value, null);
                            }
                        }
                    }
                }
            }
        }
        public static object GetValuesFromDirectoryProperty(SyncPropertyDefinition property, DirectoryProperty originalValues, List <ValidationError> errors)
        {
            if (originalValues == null)
            {
                return(null);
            }
            IList values = originalValues.GetValues();

            if (values == null || values.Count == 0 || values == DirectoryProperty.EmptyValues)
            {
                return(null);
            }
            if (property.IsMultivalued)
            {
                IList values2 = new ArrayList(values.Count);
                SyncValueConvertor.ConvertMultipleValues(property, values, ref values2, errors);
                MultiValuedPropertyBase multiValuedPropertyBase = ADValueConvertor.CreateGenericMultiValuedProperty(property, property.IsReadOnly, values2, null, null);
                multiValuedPropertyBase.IsCompletelyRead = true;
                return(multiValuedPropertyBase);
            }
            ValidationError validationError = null;
            object          result          = SyncValueConvertor.ConvertSingleValue(property, values[0], out validationError);

            if (validationError != null)
            {
                errors.Add(validationError);
            }
            return(result);
        }
示例#8
0
 private static void SaveChangesInRepairMode(IRecipientSession session, ulong puid, IEnumerable <ADPropertyDefinition> propertiesToSet, PropertyBag propertyValuesBag, Action <string> logAction, Action <string> warningLogAction)
 {
     foreach (ADPropertyDefinition adpropertyDefinition in propertiesToSet)
     {
         if (propertyValuesBag.IsModified(adpropertyDefinition))
         {
             if (adpropertyDefinition.IsMultivalued)
             {
                 MultiValuedPropertyBase multiValuedPropertyBase = (MultiValuedPropertyBase)propertyValuesBag[adpropertyDefinition];
                 foreach (object addedValue in multiValuedPropertyBase.Added)
                 {
                     ConsumerMailboxHelper.TrySaveChanges(session, puid, adpropertyDefinition, addedValue, null, logAction, warningLogAction);
                 }
                 foreach (object removedValue in multiValuedPropertyBase.Removed)
                 {
                     ConsumerMailboxHelper.TrySaveChanges(session, puid, adpropertyDefinition, null, removedValue, logAction, warningLogAction);
                 }
             }
             else
             {
                 ConsumerMailboxHelper.TrySaveChanges(session, puid, adpropertyDefinition, propertyValuesBag[adpropertyDefinition], null, logAction, warningLogAction);
             }
         }
     }
 }
示例#9
0
        internal static PropertyXML Create(ProviderPropertyDefinition pdef, object value)
        {
            PropertyXML propertyXML = new PropertyXML();

            propertyXML.PropertyName = pdef.Name;
            propertyXML.ClassName    = pdef.Type.FullName;
            propertyXML.values       = new List <PropertyValueBaseXML>();
            propertyXML.isDefault    = object.Equals(value, pdef.DefaultValue);
            if (pdef.IsMultivalued && value is MultiValuedPropertyBase)
            {
                MultiValuedPropertyBase multiValuedPropertyBase = (MultiValuedPropertyBase)value;
                using (IEnumerator enumerator = ((IEnumerable)multiValuedPropertyBase).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        object value2 = enumerator.Current;
                        PropertyValueBaseXML propertyValueBaseXML = PropertyValueBaseXML.Create(pdef, value2);
                        if (propertyValueBaseXML != null)
                        {
                            propertyXML.values.Add(propertyValueBaseXML);
                        }
                    }
                    return(propertyXML);
                }
            }
            if (value != null)
            {
                PropertyValueBaseXML propertyValueBaseXML2 = PropertyValueBaseXML.Create(pdef, value);
                if (propertyValueBaseXML2 != null)
                {
                    propertyXML.values.Add(propertyValueBaseXML2);
                }
            }
            return(propertyXML);
        }
 protected override void ValidateWrite(List <ValidationError> errors)
 {
     if (!(this.IsTransportRuleScoped ^ (!MultiValuedPropertyBase.IsNullOrEmpty(this.RecipientDomains) || this.AllAcceptedDomains)))
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.OutboundConnectorIncorrectTransportRuleScopedParameters, TenantOutboundConnectorSchema.IsTransportRuleScoped, this));
     }
     if (this.TlsDomain != null && this.TlsSettings != TlsAuthLevel.DomainValidation)
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.OutboundConnectorTlsSettingsInvalidTlsDomainWithoutDomainValidation, TenantOutboundConnectorSchema.TlsSettings, this));
     }
     if (this.TlsDomain == null && this.TlsSettings == TlsAuthLevel.DomainValidation)
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.OutboundConnectorTlsSettingsInvalidDomainValidationWithoutTlsDomain, TenantOutboundConnectorSchema.TlsSettings, this));
     }
     this.ValidateSmartHosts(errors);
     if (this.ConnectorType != TenantConnectorType.OnPremises && this.RouteAllMessagesViaOnPremises)
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.OutboundConnectorIncorrectRouteAllMessagesViaOnPremises, TenantOutboundConnectorSchema.RouteAllMessagesViaOnPremises, this));
     }
     if (this.ConnectorType != TenantConnectorType.OnPremises && this.CloudServicesMailEnabled)
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.OutboundConnectorIncorrectCloudServicesMailEnabled, TenantOutboundConnectorSchema.CloudServicesMailEnabled, this));
     }
     if (this.ConnectorType != TenantConnectorType.OnPremises && this.AllAcceptedDomains)
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.InboundConnectorIncorrectAllAcceptedDomains, TenantOutboundConnectorSchema.AllAcceptedDomains, this));
     }
 }
示例#11
0
 protected override void ValidateWrite(List <ValidationError> errors)
 {
     base.ValidateWrite(errors);
     if (!this.AnyMatch && this.BitmaskMatch == null && MultiValuedPropertyBase.IsNullOrEmpty(this.IPAddressesMatch))
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.BitMaskOrIpAddressMatchMustBeSet, IPListProviderSchema.AnyMatch, this));
     }
 }
示例#12
0
 public static string[] ToStringArray(this MultiValuedProperty <string> stringProperty)
 {
     if (MultiValuedPropertyBase.IsNullOrEmpty(stringProperty))
     {
         return(new string[0]);
     }
     return(stringProperty.ToArray());
 }
示例#13
0
        // Token: 0x06000B48 RID: 2888 RVA: 0x00033CCC File Offset: 0x00031ECC
        private bool AreMultivaluedPropertiesEqual(object leftValue, object rightValue, ADPropertyDefinition adProperty)
        {
            MultiValuedPropertyBase multiValuedPropertyBase  = leftValue as MultiValuedPropertyBase;
            MultiValuedPropertyBase multiValuedPropertyBase2 = rightValue as MultiValuedPropertyBase;

            if (multiValuedPropertyBase != null && multiValuedPropertyBase.Count > 0 && rightValue == null)
            {
                return(false);
            }
            if (multiValuedPropertyBase == null && multiValuedPropertyBase2 != null && multiValuedPropertyBase2.Count > 0)
            {
                return(false);
            }
            if (multiValuedPropertyBase == null && multiValuedPropertyBase2 != null && multiValuedPropertyBase2.Count == 0)
            {
                return(true);
            }
            if (multiValuedPropertyBase != null && multiValuedPropertyBase.Count == 0 && multiValuedPropertyBase2 == null)
            {
                return(true);
            }
            if (multiValuedPropertyBase.Count == 0 && multiValuedPropertyBase2.Count == 0)
            {
                return(true);
            }
            IEnumerable   enumerable = (IEnumerable)leftValue;
            List <byte[]> list       = new List <byte[]>();
            List <string> list2      = new List <string>();

            foreach (object originalValue in enumerable)
            {
                if (adProperty.IsBinary)
                {
                    list.Add(ADValueConvertor.ConvertValueToBinary(originalValue, adProperty.FormatProvider));
                }
                else
                {
                    list2.Add(ADValueConvertor.ConvertValueToString(originalValue, adProperty.FormatProvider));
                }
            }
            IEnumerable   enumerable2 = (IEnumerable)rightValue;
            List <byte[]> list3       = new List <byte[]>();
            List <string> list4       = new List <string>();

            foreach (object originalValue2 in enumerable2)
            {
                if (adProperty.IsBinary)
                {
                    list3.Add(ADValueConvertor.ConvertValueToBinary(originalValue2, adProperty.FormatProvider));
                }
                else
                {
                    list4.Add(ADValueConvertor.ConvertValueToString(originalValue2, adProperty.FormatProvider));
                }
            }
            return(list.Equals(list3, ByteArrayComparer.Instance) && list2.Equals(list4, StringComparer.Ordinal));
        }
        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));
            }
        }
 private void ValidateSmartHosts(List <ValidationError> errors)
 {
     if (this.UseMXRecord && !MultiValuedPropertyBase.IsNullOrEmpty(this.SmartHosts))
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.OutboundConnectorUseMXRecordShouldBeFalseIfSmartHostsIsPresent, TenantOutboundConnectorSchema.UseMxRecord, this));
     }
     if (!this.UseMXRecord && MultiValuedPropertyBase.IsNullOrEmpty(this.SmartHosts))
     {
         errors.Add(new PropertyValidationError(DirectoryStrings.OutboundConnectorSmartHostShouldBePresentIfUseMXRecordFalse, TenantOutboundConnectorSchema.SmartHostsString, this));
     }
 }
示例#16
0
        protected static object GetPropertyBasedOnDefinition(PropertyDefinition definition, object propertyValue)
        {
            if (!(propertyValue is PSObject) || !(((PSObject)propertyValue).BaseObject is IList))
            {
                return(MockObjectCreator.GetSingleProperty(propertyValue, definition.Type));
            }
            IList list = ((PSObject)propertyValue).BaseObject as IList;

            if (definition.Type == typeof(ScheduleInterval[]))
            {
                List <ScheduleInterval> list2 = new List <ScheduleInterval>();
                foreach (object prop in list)
                {
                    list2.Add((ScheduleInterval)MockObjectCreator.GetSingleProperty(prop, typeof(ScheduleInterval)));
                }
                return(list2.ToArray());
            }
            MultiValuedPropertyBase multiValuedPropertyBase = null;

            if (definition.Type == typeof(ProxyAddress))
            {
                multiValuedPropertyBase = new ProxyAddressCollection();
            }
            else if (definition.Type == typeof(ApprovedApplicationCollection))
            {
                multiValuedPropertyBase = new ApprovedApplicationCollection();
            }
            else
            {
                if (definition.Type.FullName == "Microsoft.Exchange.Management.RecipientTasks.MailboxRights[]")
                {
                    if (MockObjectCreator.mailboxRightsEnum == null)
                    {
                        string assemblyFile = Path.Combine(ConfigurationContext.Setup.BinPath, "Microsoft.Exchange.Management.Recipient.dll");
                        MockObjectCreator.mailboxRightsEnum = Assembly.LoadFrom(assemblyFile).GetType("Microsoft.Exchange.Management.RecipientTasks.MailboxRights");
                    }
                    Array array = Array.CreateInstance(MockObjectCreator.mailboxRightsEnum, list.Count);
                    int   num   = 0;
                    foreach (object prop2 in list)
                    {
                        array.SetValue(MockObjectCreator.GetSingleProperty(prop2, MockObjectCreator.mailboxRightsEnum), num);
                        num++;
                    }
                    return(array);
                }
                multiValuedPropertyBase = new MultiValuedProperty <object>();
            }
            foreach (object prop3 in list)
            {
                multiValuedPropertyBase.Add(MockObjectCreator.GetSingleProperty(prop3, definition.Type));
            }
            return(multiValuedPropertyBase);
        }
示例#17
0
        protected override IConfigurable PrepareDataObject()
        {
            ForeignConnector foreignConnector = (ForeignConnector)base.PrepareDataObject();

            if (!MultiValuedPropertyBase.IsNullOrEmpty(this.SourceTransportServers))
            {
                foreignConnector.SourceTransportServers = base.ResolveIdParameterCollection <ServerIdParameter, Server, ADObjectId>(this.SourceTransportServers, base.DataSession, this.RootId, null, (ExchangeErrorCategory)0, new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotFound), new Func <IIdentityParameter, LocalizedString>(Strings.ErrorServerNotUnique), null, null);
                if (this.SourceTransportServers.Count > 0)
                {
                    ManageSendConnectors.SetConnectorHomeMta(foreignConnector, (IConfigurationSession)base.DataSession);
                }
            }
            return(foreignConnector);
        }
 internal static void ValidateTlsSenderCertificateRestrictions(TlsCertificate certificate, MultiValuedProperty <SmtpX509IdentifierEx> ffoFDSmtpCerts, MultiValuedProperty <ServiceProviderSettings> serviceProviders, Task task)
 {
     if (certificate == null)
     {
         return;
     }
     if (!MultiValuedPropertyBase.IsNullOrEmpty(ffoFDSmtpCerts) && ffoFDSmtpCerts.Any((SmtpX509IdentifierEx ffoFDSmtpCert) => ffoFDSmtpCert.Matches(certificate)))
     {
         task.WriteError(new TlsSenderCertificateNameMatchesFfoFDSmtpCertificateException(certificate.ToString()), ErrorCategory.InvalidArgument, null);
     }
     if (!MultiValuedPropertyBase.IsNullOrEmpty(serviceProviders) && serviceProviders.Any((ServiceProviderSettings serviceProvider) => serviceProvider.Certificates != null && serviceProvider.Certificates.Any((TlsCertificate providerCertificate) => providerCertificate != null && providerCertificate.Equals(certificate))))
     {
         task.WriteError(new TlsSenderCertificateNameMatchesServiceProviderCertificateException(certificate.ToString()), ErrorCategory.InvalidArgument, null);
     }
 }
        private IEnumerable <RmsTemplate> AcquireRmsTemplates()
        {
            if (this.orgId == OrganizationId.ForestWideOrgId)
            {
                return(RmsClientManager.AcquireRmsTemplates(this.orgId, true));
            }
            if (this.irmConfiguration == null || (!this.irmConfiguration.InternalLicensingEnabled && !this.displayTemplatesIfInternalLicensingDisabled))
            {
                return(DrmEmailConstants.EmptyTemplateArray);
            }
            RMSTrustedPublishingDomain rmstrustedPublishingDomain = this.FindTPD();

            if (rmstrustedPublishingDomain == null)
            {
                return(DrmEmailConstants.EmptyTemplateArray);
            }
            List <RmsTemplate> list = null;

            if (!MultiValuedPropertyBase.IsNullOrEmpty(rmstrustedPublishingDomain.RMSTemplates))
            {
                list = new List <RmsTemplate>(rmstrustedPublishingDomain.RMSTemplates.Count + 2);
                using (MultiValuedProperty <string> .Enumerator enumerator = rmstrustedPublishingDomain.RMSTemplates.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        string          encodedTemplate = enumerator.Current;
                        RmsTemplateType type            = RmsTemplateType.Archived;
                        string          templateXrml    = RMUtil.DecompressTemplate(encodedTemplate, out type);
                        if (this.ShouldFetch(type))
                        {
                            list.Add(RmsTemplate.CreateServerTemplateFromTemplateDefinition(templateXrml, type));
                        }
                    }
                    goto IL_CE;
                }
            }
            list = new List <RmsTemplate>(2);
IL_CE:
            if (this.typeToFetch != RmsTemplateType.Archived && rmstrustedPublishingDomain.Default)
            {
                list.Add(RmsTemplate.DoNotForward);
                if (this.irmConfiguration.InternetConfidentialEnabled)
                {
                    list.Add(RmsTemplate.InternetConfidential);
                }
            }
            return(list);
        }
 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);
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        public void Save(IConfigurable instance)
        {
            if (this.orgId == OrganizationId.ForestWideOrgId)
            {
                throw new NotSupportedException();
            }
            RmsTemplatePresentation rmsTemplatePresentation = instance as RmsTemplatePresentation;

            if (rmsTemplatePresentation == null)
            {
                throw new ArgumentException("passed in instance not of type RmsTemplatePresentation", "instance");
            }
            Guid templateGuid = rmsTemplatePresentation.TemplateGuid;
            RMSTrustedPublishingDomain rmstrustedPublishingDomain = this.FindDefaultTPD();

            if (rmstrustedPublishingDomain == null)
            {
                return;
            }
            if (!MultiValuedPropertyBase.IsNullOrEmpty(rmstrustedPublishingDomain.RMSTemplates))
            {
                string text  = null;
                string text2 = null;
                foreach (string text3 in rmstrustedPublishingDomain.RMSTemplates)
                {
                    RmsTemplateType rmsTemplateType;
                    string          text4 = RMUtil.DecompressTemplate(text3, out rmsTemplateType);
                    Guid            templateGuidFromLicense = DrmClientUtils.GetTemplateGuidFromLicense(text4);
                    if (templateGuidFromLicense == templateGuid && rmsTemplateType != rmsTemplatePresentation.Type)
                    {
                        text  = text3;
                        text2 = RMUtil.CompressTemplate(text4, rmsTemplatePresentation.Type);
                        break;
                    }
                }
                if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2))
                {
                    rmstrustedPublishingDomain.RMSTemplates.Remove(text);
                    rmstrustedPublishingDomain.RMSTemplates.Add(text2);
                    this.adSession.Save(rmstrustedPublishingDomain);
                }
            }
        }
示例#22
0
        internal static Dns GetAndInitializeDns(Server server)
        {
            Dns dns = new Dns();

            dns.Options = Provider.GetDnsOptions(server.ExternalDNSProtocolOption);
            MultiValuedProperty <IPAddress> externalDNSServers = server.ExternalDNSServers;

            if (server.ExternalDNSAdapterEnabled || MultiValuedPropertyBase.IsNullOrEmpty(externalDNSServers))
            {
                dns.AdapterServerList(server.ExternalDNSAdapterGuid);
            }
            else
            {
                IPAddress[] array = new IPAddress[externalDNSServers.Count];
                externalDNSServers.CopyTo(array, 0);
                dns.ServerList.Initialize(array);
            }
            return(dns);
        }
        protected static HybridMailflowConfiguration ConvertToHybridMailflowConfiguration(TenantInboundConnector inbound, TenantOutboundConnector outbound)
        {
            ArgumentValidator.ThrowIfNull("inbound", inbound);
            ArgumentValidator.ThrowIfNull("outbound", outbound);
            HybridMailflowConfiguration hybridMailflowConfiguration = new HybridMailflowConfiguration();

            hybridMailflowConfiguration.OutboundDomains = new List <SmtpDomainWithSubdomains>();
            foreach (SmtpDomainWithSubdomains smtpDomainWithSubdomains in outbound.RecipientDomains)
            {
                if (!HybridMailflowTaskBase.IsWildcardDomain(smtpDomainWithSubdomains))
                {
                    hybridMailflowConfiguration.OutboundDomains.Add(new SmtpDomainWithSubdomains(smtpDomainWithSubdomains.Address));
                }
            }
            if (inbound.SenderIPAddresses != null)
            {
                hybridMailflowConfiguration.InboundIPs = new List <IPRange>();
                foreach (IPRange item in inbound.SenderIPAddresses)
                {
                    hybridMailflowConfiguration.InboundIPs.Add(item);
                }
            }
            if (!MultiValuedPropertyBase.IsNullOrEmpty(outbound.SmartHosts))
            {
                SmartHost smartHost = outbound.SmartHosts[0];
                if (smartHost.IsIPAddress)
                {
                    hybridMailflowConfiguration.OnPremisesFQDN = new Fqdn(smartHost.Address.ToString());
                }
                else
                {
                    hybridMailflowConfiguration.OnPremisesFQDN = new Fqdn(smartHost.ToString());
                }
            }
            if (inbound.TlsSenderCertificateName != null)
            {
                hybridMailflowConfiguration.CertificateSubject = inbound.TlsSenderCertificateName.ToString();
            }
            hybridMailflowConfiguration.SecureMailEnabled           = new bool?(inbound.RequireTls && outbound.TlsSettings != null && outbound.TlsSettings == TlsAuthLevel.DomainValidation);
            hybridMailflowConfiguration.CentralizedTransportEnabled = new bool?((inbound.RestrictDomainsToIPAddresses && HybridMailflowTaskBase.IsRecipientDomainsWildcard(outbound.RecipientDomains)) || outbound.RouteAllMessagesViaOnPremises);
            return(hybridMailflowConfiguration);
        }
示例#24
0
 internal bool TryGetValue(ProviderPropertyDefinition pdef, out object result)
 {
     if (this.values.Count == 0)
     {
         result = null;
         return(true);
     }
     if (pdef.IsMultivalued)
     {
         List <object> list = new List <object>(this.values.Count);
         foreach (PropertyValueBaseXML propertyValueBaseXML in this.values)
         {
             object item;
             if (propertyValueBaseXML.TryGetValue(pdef, out item))
             {
                 list.Add(item);
             }
         }
         MultiValuedPropertyBase multiValuedPropertyBase = null;
         List <object>           invalidValues           = new List <object>();
         if (!ADValueConvertor.TryCreateGenericMultiValuedProperty(pdef, false, list, invalidValues, null, out multiValuedPropertyBase))
         {
             MrsTracer.Common.Warning("Failed to convert array to MultiValued property {0}", new object[]
             {
                 pdef.Name
             });
             result = null;
             return(false);
         }
         result = multiValuedPropertyBase;
         return(true);
     }
     else
     {
         if (this.values.Count != 1)
         {
             result = null;
             return(false);
         }
         return(this.values[0].TryGetValue(pdef, out result));
     }
 }
        public static IList GetValuesForDirectoryProperty(SyncPropertyDefinition property, object value)
        {
            ArrayList result = new ArrayList();

            if (property.IsMultivalued)
            {
                MultiValuedPropertyBase multiValuedPropertyBase = (MultiValuedPropertyBase)value;
                using (IEnumerator enumerator = ((IEnumerable)multiValuedPropertyBase).GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        object value2 = enumerator.Current;
                        SyncValueConvertor.AddValueToResultCollection(property, result, value2);
                    }
                    return(result);
                }
            }
            SyncValueConvertor.AddValueToResultCollection(property, result, value);
            return(result);
        }
示例#26
0
 public override void ReadData(IConfigurationSession session)
 {
     RMSTrustedPublishingDomain[] array = session.Find <RMSTrustedPublishingDomain>(null, QueryScope.SubTree, null, null, 0);
     if (array == null || array.Length == 0)
     {
         return;
     }
     foreach (RMSTrustedPublishingDomain rmstrustedPublishingDomain in array)
     {
         if (rmstrustedPublishingDomain.Default && !MultiValuedPropertyBase.IsNullOrEmpty(rmstrustedPublishingDomain.RMSTemplates))
         {
             foreach (string encodedTemplate in rmstrustedPublishingDomain.RMSTemplates)
             {
                 string text = null;
                 try
                 {
                     RmsTemplateType rmsTemplateType;
                     text = RMUtil.DecompressTemplate(encodedTemplate, out rmsTemplateType);
                     if (rmsTemplateType == RmsTemplateType.Distributed)
                     {
                         RmsTemplate rmsTemplate = RmsTemplate.CreateServerTemplateFromTemplateDefinition(text, rmsTemplateType);
                         this.templates.Add(rmsTemplate.Id, rmsTemplate);
                         this.estimatedSize += rmsTemplate.ItemSize + 16L;
                     }
                 }
                 catch (FormatException arg)
                 {
                     RmsConfiguration.Tracer.TraceError <string, FormatException>((long)this.GetHashCode(), "Failed to read template {0}. Error {1}", text, arg);
                 }
                 catch (InvalidRpmsgFormatException arg2)
                 {
                     RmsConfiguration.Tracer.TraceError <string, InvalidRpmsgFormatException>((long)this.GetHashCode(), "Failed to read template {0}. Error {1}", text, arg2);
                 }
                 catch (RightsManagementException arg3)
                 {
                     RmsConfiguration.Tracer.TraceError <string, RightsManagementException>((long)this.GetHashCode(), "Failed to read template {0}. Error {1}", text, arg3);
                 }
             }
         }
     }
 }
示例#27
0
        private static string DumpMultiValuedPropertyWithChanges(MultiValuedPropertyBase mvp)
        {
            StringBuilder stringBuilder = new StringBuilder();

            object[] added   = mvp.Added;
            object[] removed = mvp.Removed;
            if (added.Length > 0)
            {
                stringBuilder.Append(MultiValuedProperty <string> .AddKeys[0]);
                stringBuilder.Append("=");
                stringBuilder.Append(RoleGroupCommon.NamesFromObjects(added));
                stringBuilder.Append(";");
            }
            if (removed.Length > 0)
            {
                stringBuilder.Append(MultiValuedProperty <string> .RemoveKeys[0]);
                stringBuilder.Append("=");
                stringBuilder.Append(RoleGroupCommon.NamesFromObjects(removed));
            }
            return(stringBuilder.ToString());
        }
 protected override void PrepareRecipientObject(TDataObject recipient)
 {
     TaskLogger.LogEnter();
     base.PrepareRecipientObject(recipient);
     if (base.Fields.Contains(ADRecipientSchema.ModeratedBy))
     {
         MultiValuedProperty <ModeratorIDParameter> multiValuedProperty = (MultiValuedProperty <ModeratorIDParameter>)base.Fields[ADRecipientSchema.ModeratedBy];
         int num = VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled ? 10 : 25;
         if (multiValuedProperty != null && multiValuedProperty.Count > num)
         {
             base.WriteError(new RecipientTaskException(Strings.ErrorTooManyModerators(num)), ExchangeErrorCategory.Client, null);
         }
         recipient.ModeratedBy = RecipientTaskHelper.GetModeratedByAdObjectIdFromParameterID(base.TenantGlobalCatalogSession, this.ModeratedBy, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADRecipient>), recipient, new Task.ErrorLoggerDelegate(base.WriteError));
     }
     if (base.Fields.IsModified(ADRecipientSchema.ArbitrationMailbox))
     {
         if (this.ArbitrationMailbox != null)
         {
             ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(this.ArbitrationMailbox, (IRecipientSession)base.DataSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.ArbitrationMailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.ArbitrationMailbox.ToString())), ExchangeErrorCategory.Client);
             if (adrecipient.RecipientTypeDetails != RecipientTypeDetails.ArbitrationMailbox)
             {
                 base.WriteError(new RecipientTaskException(Strings.ErrorInvalidArbitrationMbxType(adrecipient.Identity.ToString())), ExchangeErrorCategory.Client, recipient.Identity);
             }
             if (MultiValuedPropertyBase.IsNullOrEmpty((ADMultiValuedProperty <ADObjectId>)adrecipient[ADUserSchema.ApprovalApplications]))
             {
                 base.WriteError(new RecipientTaskException(Strings.ErrorInvalidArbitrationMbxTypeForModerationAndAutogroup(adrecipient.Identity.ToString())), ExchangeErrorCategory.Client, recipient.Identity);
             }
             if (!recipient.OrganizationId.Equals(adrecipient.OrganizationId))
             {
                 base.WriteError(new RecipientTaskException(Strings.ErrorArbitrationMbxCrossOrg(adrecipient.Identity.ToString())), ExchangeErrorCategory.Client, recipient.Identity);
             }
             recipient.ArbitrationMailbox = adrecipient.Id;
         }
         else
         {
             recipient.ArbitrationMailbox = null;
         }
     }
     TaskLogger.LogExit();
 }
示例#29
0
        internal static string NamesFromObjects(IEnumerable objects)
        {
            if (objects == null)
            {
                return(string.Empty);
            }
            StringBuilder           stringBuilder           = new StringBuilder();
            bool                    flag                    = false;
            MultiValuedPropertyBase multiValuedPropertyBase = objects as MultiValuedPropertyBase;

            if (multiValuedPropertyBase != null && multiValuedPropertyBase.Count == 0)
            {
                return(RoleGroupCommon.DumpMultiValuedPropertyWithChanges(multiValuedPropertyBase));
            }
            foreach (object obj in objects)
            {
                if (flag)
                {
                    stringBuilder.Append(", ");
                }
                flag = true;
                if (obj is ADObject)
                {
                    stringBuilder.Append(((ADObject)obj).Name);
                }
                else if (obj is ADObjectId)
                {
                    stringBuilder.Append(((ADObjectId)obj).Name);
                }
                else
                {
                    if (!(obj is SecurityPrincipalIdParameter))
                    {
                        throw new ArgumentException("objects");
                    }
                    stringBuilder.Append(((SecurityPrincipalIdParameter)obj).ToString());
                }
            }
            return(stringBuilder.ToString());
        }
示例#30
0
        public static string ConvertToString(object item, PropertyDefinition definition)
        {
            ProviderPropertyDefinition providerPropertyDefinition = (ProviderPropertyDefinition)definition;

            if (providerPropertyDefinition.IsMultivalued)
            {
                MultiValuedPropertyBase multiValuedPropertyBase = item as MultiValuedPropertyBase;
                if (multiValuedPropertyBase != null)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (object item2 in ((IEnumerable)multiValuedPropertyBase))
                    {
                        string text = SearchHelper.ConvertToString(item2, definition.Type);
                        stringBuilder.Append(text.Length);
                        stringBuilder.Append("|");
                        stringBuilder.Append(text);
                    }
                    return(stringBuilder.ToString());
                }
            }
            return(SearchHelper.ConvertToString(item, definition.Type));
        }