Esempio n. 1
0
        private static ADUser GetOrganizationMailbox(IRecipientSession recipientSession, OrganizationCapability capability, string anchorMailboxKey)
        {
            if (recipientSession == null)
            {
                throw new ArgumentNullException("recipientSession");
            }
            List <ADUser> organizationMailboxesByCapability = OrganizationMailbox.GetOrganizationMailboxesByCapability(recipientSession, capability);

            if (organizationMailboxesByCapability == null || organizationMailboxesByCapability.Count == 0)
            {
                ExTraceGlobals.CafeTracer.TraceError <OrganizationCapability, OrganizationId>(0L, "[HttpProxyBackEndHelper.GetOrganizationMailbox] Unable to find organization mailbox with capability {0} for organization {1}.", capability, recipientSession.SessionSettings.CurrentOrganizationId);
                return(null);
            }
            ADUser aduser;

            if (!string.IsNullOrEmpty(anchorMailboxKey) && organizationMailboxesByCapability.Count > 1)
            {
                aduser = organizationMailboxesByCapability[HttpProxyBackEndHelper.ComputeIndex(anchorMailboxKey, organizationMailboxesByCapability.Count)];
            }
            else
            {
                aduser = organizationMailboxesByCapability[0];
            }
            ExTraceGlobals.CafeTracer.TraceDebug <ObjectId, OrganizationCapability, OrganizationId>(0L, "[HttpProxyBackEndHelper.GetOrganizationMailbox] Find organization mailbox {0} with capability {1} for organization {2}.", aduser.Identity, capability, recipientSession.SessionSettings.CurrentOrganizationId);
            return(aduser);
        }
        private static ADUser GetOrgMailbox(string domain)
        {
            ADSessionSettings sessionSettings = null;

            try
            {
                sessionSettings = ADSessionSettings.FromTenantAcceptedDomain(domain);
            }
            catch (CannotResolveTenantNameException arg)
            {
                EncryptionConfigurationTable.Tracer.TraceInformation <CannotResolveTenantNameException>(0, 0L, "Can't resolve tenant name. Exception: {0}", arg);
                EncryptionConfigurationTable.logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_E4EOrganizationMailboxRetrievalFailed, domain, new object[]
                {
                    "ProcessEncryptionConfiguration",
                    domain
                });
                return(null);
            }
            IRecipientSession tenantOrRootOrgRecipientSession   = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 334, "GetOrgMailbox", "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\E4E\\EncryptionConfigurationTable.cs");
            List <ADUser>     organizationMailboxesByCapability = OrganizationMailbox.GetOrganizationMailboxesByCapability(tenantOrRootOrgRecipientSession, OrganizationCapability.OfficeMessageEncryption);

            if (organizationMailboxesByCapability == null || 1 != organizationMailboxesByCapability.Count)
            {
                EncryptionConfigurationTable.Tracer.TraceInformation(0, 0L, "Org mailbox is not configured.");
                EncryptionConfigurationTable.logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_E4EOrganizationMailboxRetrievalFailed, domain, new object[]
                {
                    "ProcessEncryptionConfiguration",
                    domain
                });
                return(null);
            }
            return(organizationMailboxesByCapability[0]);
        }
        protected override IConfigurable ResolveDataObject()
        {
            ADUser result = null;

            try
            {
                result = CommonUtil.ValidateAndReturnUMDataStorageOrgMbx(OrganizationMailbox.GetOrganizationMailboxesByCapability((IRecipientSession)base.DataSession, OrganizationCapability.UMDataStorage));
            }
            catch (ObjectNotFoundException exception)
            {
                base.WriteError(exception, ErrorCategory.ReadError, null);
            }
            catch (NonUniqueRecipientException exception2)
            {
                base.WriteError(exception2, ErrorCategory.ReadError, null);
            }
            return(result);
        }
Esempio n. 4
0
        // Token: 0x06000B56 RID: 2902 RVA: 0x0002E044 File Offset: 0x0002C244
        internal static ADUser GetOrgMailbox(string domain)
        {
            ADSessionSettings adsessionSettings = null;

            if (OrgExtensionTable.IsDatacenter)
            {
                if (domain == null)
                {
                    return(null);
                }
                try
                {
                    adsessionSettings = ADSessionSettings.FromTenantAcceptedDomain(domain);
                }
                catch (CannotResolveTenantNameException arg)
                {
                    OrgExtensionTable.Tracer.TraceInformation <CannotResolveTenantNameException>(0, 0L, "Can't resolve tenant name. Exception: {0}", arg);
                    ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_OrganizationMailboxRetrievalFailed, domain, new object[]
                    {
                        "ProcessOrgExtensions",
                        domain
                    });
                    return(null);
                }
            }
            if (adsessionSettings == null)
            {
                adsessionSettings = ADSessionSettings.FromRootOrgScopeSet();
            }
            IRecipientSession tenantOrRootOrgRecipientSession   = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, adsessionSettings, 559, "GetOrgMailbox", "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\extension\\OrgExtensionTable.cs");
            List <ADUser>     organizationMailboxesByCapability = OrganizationMailbox.GetOrganizationMailboxesByCapability(tenantOrRootOrgRecipientSession, OrganizationCapability.ClientExtensions);

            if (organizationMailboxesByCapability == null || 1 != organizationMailboxesByCapability.Count)
            {
                OrgExtensionTable.Tracer.TraceInformation(0, 0L, "Org mailbox is not configured.");
                ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_OrganizationMailboxRetrievalFailed, domain, new object[]
                {
                    "ProcessOrgExtensions",
                    domain
                });
                return(null);
            }
            return(organizationMailboxesByCapability[0]);
        }
Esempio n. 5
0
        internal static ADUser ResolvePartitionMailbox(MailboxIdParameter partitionMailboxIdentity, IRecipientSession tenantGlobalCatalogSession, ADServerSettings serverSettings, DataAccessHelper.CategorizedGetDataObjectDelegate getDataObject, Task.ErrorLoggerDelegate writeError, bool datacenterFirstOrg)
        {
            ADUser aduser;

            if (partitionMailboxIdentity != null)
            {
                ADObjectId rootID = null;
                if (datacenterFirstOrg)
                {
                    rootID = ADSystemConfigurationSession.GetFirstOrgUsersContainerId();
                }
                aduser = (ADUser)getDataObject(partitionMailboxIdentity, tenantGlobalCatalogSession, rootID, null, new LocalizedString?(Strings.MigrationPartitionMailboxNotFound), new LocalizedString?(Strings.MigrationPartitionMailboxAmbiguous), ExchangeErrorCategory.Client);
                if (!aduser.PersistedCapabilities.Contains(Capability.OrganizationCapabilityMigration))
                {
                    writeError(new MigrationPartitionMailboxInvalidException(aduser.Alias), ExchangeErrorCategory.Client, partitionMailboxIdentity);
                }
            }
            else
            {
                List <ADUser> organizationMailboxesByCapability = OrganizationMailbox.GetOrganizationMailboxesByCapability(tenantGlobalCatalogSession, OrganizationCapability.Migration);
                if (organizationMailboxesByCapability == null || organizationMailboxesByCapability.Count == 0)
                {
                    organizationMailboxesByCapability = OrganizationMailbox.GetOrganizationMailboxesByCapability(tenantGlobalCatalogSession, OrganizationCapability.Management);
                }
                if (organizationMailboxesByCapability == null || organizationMailboxesByCapability.Count == 0)
                {
                    writeError(new MigrationPartitionMailboxNotFoundException(), ExchangeErrorCategory.Client, null);
                }
                else if (organizationMailboxesByCapability.Count > 1)
                {
                    writeError(new MigrationPartitionMailboxAmbiguousException(), ExchangeErrorCategory.Client, null);
                }
                aduser = organizationMailboxesByCapability[0];
            }
            if (aduser.RecipientTypeDetails != RecipientTypeDetails.ArbitrationMailbox || aduser.Database == null)
            {
                writeError(new MigrationPartitionMailboxInvalidException(aduser.Alias), ExchangeErrorCategory.Client, partitionMailboxIdentity);
            }
            return(aduser);
        }
        protected override SmtpAddress Create(string domain, ref bool shouldAdd)
        {
            IRecipientSession recipientSessionForDomain = this.GetRecipientSessionForDomain(domain);

            if (recipientSessionForDomain != null)
            {
                List <ADUser> organizationMailboxesByCapability = OrganizationMailbox.GetOrganizationMailboxesByCapability(recipientSessionForDomain, OrganizationCapability.MessageTracking);
                if (organizationMailboxesByCapability != null && organizationMailboxesByCapability.Count != 0)
                {
                    int    index  = DomainOrgMailboxCache.rand.Next(organizationMailboxesByCapability.Count);
                    ADUser aduser = organizationMailboxesByCapability.ElementAt(index);
                    TraceWrapper.SearchLibraryTracer.TraceDebug <ObjectId, OrganizationId>(this.GetHashCode(), "Found E15 Org mailbox {0} for organization {1}.", aduser.Identity, recipientSessionForDomain.SessionSettings.CurrentOrganizationId);
                    shouldAdd = true;
                    return(aduser.PrimarySmtpAddress);
                }
            }
            SmtpAddress result = new SmtpAddress(DomainOrgMailboxCache.E14EDiscoveryMailbox, domain);

            TraceWrapper.SearchLibraryTracer.TraceError <string, string>(this.GetHashCode(), "Unable to get org mailbox for domain {0}. Will try to use E14 Discovery mailbox {1} for request", domain, result.ToString());
            shouldAdd = false;
            return(result);
        }
Esempio n. 7
0
        private static ADUser GetOrganizationMailboxInClosestSite(IRecipientSession recipientSession, OrganizationCapability capability)
        {
            if (recipientSession == null)
            {
                throw new ArgumentNullException("recipientSession");
            }
            List <ADUser> organizationMailboxesByCapability = OrganizationMailbox.GetOrganizationMailboxesByCapability(recipientSession, capability);

            if (organizationMailboxesByCapability == null || organizationMailboxesByCapability.Count == 0)
            {
                ExTraceGlobals.CafeTracer.TraceError <OrganizationCapability, OrganizationId>(0L, "[HttpProxyBackEndHelper.GetOrganizationMailbox] Unable to find organization mailbox with capability {0} for organization {1}.", capability, recipientSession.SessionSettings.CurrentOrganizationId);
                return(null);
            }
            ADUser aduser;

            if (organizationMailboxesByCapability.Count == 1)
            {
                aduser = organizationMailboxesByCapability[0];
            }
            else
            {
                ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetOrganizationMailboxInClosestSite", 753);
                Site            site = currentServiceTopology.GetSite(LocalServerCache.LocalServerFqdn, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetOrganizationMailboxInClosestSite", 754);
                List <ADUser>   list = new List <ADUser>(5);
                int             num  = int.MaxValue;
                foreach (ADUser aduser2 in organizationMailboxesByCapability)
                {
                    ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(recipientSession.SessionSettings, aduser2, RemotingOptions.AllowCrossSite);
                    Site site2 = currentServiceTopology.GetSite(exchangePrincipal.MailboxInfo.Location.ServerFqdn, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetOrganizationMailboxInClosestSite", 761);
                    if (list.Count == 0)
                    {
                        list.Add(aduser2);
                        currentServiceTopology.TryGetConnectionCost(site, site2, out num, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetOrganizationMailboxInClosestSite", 768);
                    }
                    else
                    {
                        int maxValue = int.MaxValue;
                        currentServiceTopology.TryGetConnectionCost(site, site2, out maxValue, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\Cafe\\HttpProxyBackEndHelper.cs", "GetOrganizationMailboxInClosestSite", 773);
                        if (maxValue == num)
                        {
                            list.Add(aduser2);
                        }
                        else if (maxValue < num)
                        {
                            list.Clear();
                            list.Add(aduser2);
                            num = maxValue;
                        }
                    }
                }
                if (list.Count == 1)
                {
                    aduser = list[0];
                }
                else
                {
                    aduser = list[HttpProxyBackEndHelper.random.Next(list.Count)];
                }
            }
            ExTraceGlobals.CafeTracer.TraceDebug <ObjectId, OrganizationCapability, OrganizationId>(0L, "[HttpProxyBackEndHelper.GetOrganizationMailbox] Find organization mailbox {0} with capability {1} for organization {2}.", aduser.Identity, capability, recipientSession.SessionSettings.CurrentOrganizationId);
            return(aduser);
        }
 // Token: 0x06000036 RID: 54 RVA: 0x00002425 File Offset: 0x00000625
 public IEnumerable <ADUser> GetOrganizationMailboxesByCapability(OrganizationCapability capability)
 {
     return(OrganizationMailbox.GetOrganizationMailboxesByCapability(this.RecipientSession, capability));
 }