Пример #1
0
 public bool TryFindMatchingDomain(SmtpDomain inputDomain, out SmtpDomain bestMatch, out bool isExactMatch)
 {
     if (inputDomain == null)
     {
         throw new ArgumentNullException("inputDomain");
     }
     return(GlobalConfigSession.TryFindMatchingDomainInternal(inputDomain, this.BloomFilterProvider, out bestMatch, out isExactMatch));
 }
Пример #2
0
 internal void FindEnabledInboundConnectorsByIPAddressOrCertificate(string ipAddress, IEnumerable <string> certificateFqdns, out IEnumerable <TenantInboundConnector> certConnectors, out IEnumerable <TenantInboundConnector> ipConnectors)
 {
     if (string.IsNullOrEmpty(ipAddress) && (certificateFqdns == null || !certificateFqdns.Any <string>()))
     {
         throw new ArgumentException("Both ipAddress and certificateFqdns cannot be empty");
     }
     certConnectors = GlobalConfigSession.FindInboundConnectorsByCertificate(this.CompositeProvider, certificateFqdns, true);
     ipConnectors   = GlobalConfigSession.FindInboundConnectorsByOutboundIp(this.CompositeProvider, ipAddress, true);
 }
Пример #3
0
 internal static IEnumerable <TenantInboundConnector> FindInboundConnectorsByOutboundIp(IConfigDataProvider dataProvider, string ipAddress, bool enabledOnly)
 {
     if (string.IsNullOrEmpty(ipAddress))
     {
         return(GlobalConfigSession.emptyInboundConnectorArray);
     }
     return(GlobalConfigSession.GetInboundConnectors(dataProvider, TenantInboundConnectorSchema.RemoteIPRanges, new string[]
     {
         ipAddress
     }, enabledOnly).ToArray <TenantInboundConnector>());
 }
Пример #4
0
        internal override ADSessionSettings FromTenantCUName(string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            GlobalConfigSession globalConfigSession = new GlobalConfigSession();
            FfoTenant           tenantByName        = globalConfigSession.GetTenantByName(name);

            if (tenantByName == null)
            {
                throw new CannotResolveTenantNameException(DirectoryStrings.CannotResolveTenantName(name));
            }
            ExchangeConfigurationUnit exchangeConfigurationUnit = FfoConfigurationSession.GetExchangeConfigurationUnit(tenantByName);

            return(ADSessionSettings.SessionSettingsFactory.CreateADSessionSettings(ScopeSet.GetOrgWideDefaultScopeSet(OrganizationId.ForestWideOrgId), null, exchangeConfigurationUnit.OrganizationId, null, ConfigScopes.TenantLocal, PartitionId.LocalForest));
        }
Пример #5
0
        internal ADMiniUser GetUserByCertificate(string certificateSubjectName, string certificateIssuerName)
        {
            if (string.IsNullOrEmpty(certificateSubjectName))
            {
                throw new ArgumentNullException("certificateSubjectName");
            }
            if (string.IsNullOrEmpty(certificateIssuerName))
            {
                throw new ArgumentNullException("certificateIssuerName");
            }
            QueryFilter filter = QueryFilter.AndTogether(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.Equal, UserCertificate.CertificateSubjectNameProp, certificateSubjectName),
                new ComparisonFilter(ComparisonOperator.Equal, UserCertificate.CertificateIssuerNameProp, certificateIssuerName)
            });

            return(GlobalConfigSession.GetMiniUser(this.WebStoreDataProvider, filter));
        }
Пример #6
0
        protected ADObjectId ExtractTenantId(ADObjectId tenantDescendantId)
        {
            if (tenantDescendantId == null)
            {
                return(null);
            }
            int       num       = DalHelper.FfoRootDN.Depth + 1;
            FfoTenant ffoTenant = null;

            if (string.IsNullOrEmpty(tenantDescendantId.DistinguishedName) && tenantDescendantId.ObjectGuid != Guid.Empty)
            {
                ffoTenant = this.ReadAndHandleException <FfoTenant>(new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.OrganizationalUnitRoot, new ADObjectId(tenantDescendantId.ObjectGuid)));
                if (ffoTenant != null)
                {
                    string tenantDistinguishedName = DalHelper.GetTenantDistinguishedName(ffoTenant.Name);
                    return(new ADObjectId(tenantDistinguishedName, tenantDescendantId.ObjectGuid));
                }
            }
            if (tenantDescendantId.Depth <= num)
            {
                return(tenantDescendantId);
            }
            ADObjectId adobjectId = tenantDescendantId.AncestorDN(tenantDescendantId.Depth - num);
            string     name       = adobjectId.Name;
            Guid       guid;

            if (Guid.TryParse(name, out guid))
            {
                ffoTenant = this.ReadAndHandleException <FfoTenant>(new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.OrganizationalUnitRoot, new ADObjectId(guid)));
            }
            if (ffoTenant == null && tenantDescendantId.ObjectGuid == Guid.Empty)
            {
                GlobalConfigSession globalConfigSession = new GlobalConfigSession();
                ffoTenant = globalConfigSession.GetTenantByName(name);
            }
            if (ffoTenant == null)
            {
                return(tenantDescendantId);
            }
            return(ffoTenant.OrganizationalUnitRoot);
        }
Пример #7
0
        internal static IEnumerable <TenantInboundConnector> FindInboundConnectorsByCertificate(IConfigDataProvider dataProvider, IEnumerable <string> certificateFqdns, bool enabledOnly)
        {
            if (certificateFqdns == null || !certificateFqdns.Any <string>())
            {
                return(GlobalConfigSession.emptyInboundConnectorArray);
            }
            HashSet <string> hashSet = null;

            try
            {
                hashSet = GlobalConfigSession.GetSearchableCertificates(certificateFqdns);
            }
            catch (Exception ex)
            {
                if (RetryHelper.IsSystemFatal(ex))
                {
                    throw;
                }
            }
            return(GlobalConfigSession.GetInboundConnectors(dataProvider, TenantInboundConnectorSchema.TlsSenderCertificateName, (hashSet != null && hashSet.Any <string>()) ? hashSet : certificateFqdns, enabledOnly).ToArray <TenantInboundConnector>());
        }
Пример #8
0
        internal static bool TryFindMatchingDomainInternal(SmtpDomain inputDomain, IBloomFilterDataProvider dataProvider, out SmtpDomain bestMatch, out bool isExactMatch)
        {
            string text = inputDomain.Domain.ToLower();

            if (dataProvider.Check <AcceptedDomain>(new ComparisonFilter(ComparisonOperator.Equal, AcceptedDomainSchema.DomainName, text)))
            {
                bestMatch    = inputDomain;
                isExactMatch = true;
                return(true);
            }
            foreach (string text2 in GlobalConfigSession.ExpandSubdomains(text))
            {
                if (dataProvider.Check <AcceptedDomain>(new ComparisonFilter(ComparisonOperator.Equal, AcceptedDomainSchema.DomainName, "*." + text2)))
                {
                    bestMatch    = new SmtpDomain(text2);
                    isExactMatch = false;
                    return(true);
                }
            }
            bestMatch    = null;
            isExactMatch = false;
            return(false);
        }