Пример #1
0
        public TrackingAuthority FindUserLocation(TrackedUser user)
        {
            TraceWrapper.SearchLibraryTracer.TraceDebug <SmtpAddress>(this.GetHashCode(), "Trying to get location for user: {0}", user.SmtpAddress);
            if (!user.IsMailbox)
            {
                bool flag = false;
                TrackingAuthority trackingAuthority = this.FindLocationByDomainAndServer(user.SmtpAddress.Domain, string.Empty, user.SmtpAddress, true, out flag);
                TraceWrapper.SearchLibraryTracer.TraceDebug <string>(this.GetHashCode(), "Looked up non-mailbox user via domain part. Authority for user is {0}", Names <TrackingAuthorityKind> .Map[(int)trackingAuthority.TrackingAuthorityKind]);
                return(trackingAuthority);
            }
            ServerInfo userServer = ServerCache.Instance.GetUserServer(user.ADUser);

            if (ServerStatus.LegacyExchangeServer == userServer.Status)
            {
                TraceWrapper.SearchLibraryTracer.TraceDebug <ADUser>(this.GetHashCode(), "Legacy server found for user: {0}", user.ADUser);
                return(LegacyExchangeServerTrackingAuthority.Instance);
            }
            if (ServerStatus.NotFound == userServer.Status)
            {
                TraceWrapper.SearchLibraryTracer.TraceError <ADUser>(this.GetHashCode(), "Server not found for user: {0}", user.ADUser);
                return(LegacyExchangeServerTrackingAuthority.Instance);
            }
            if (!userServer.IsSearchable)
            {
                TraceWrapper.SearchLibraryTracer.TraceError <ServerInfo>(this.GetHashCode(), "Server {0} is not searchable", userServer);
                return(LegacyExchangeServerTrackingAuthority.Instance);
            }
            if (userServer.ServerSiteId == null)
            {
                TraceWrapper.SearchLibraryTracer.TraceError <ADUser>(this.GetHashCode(), "Null siteId for user: {0}", user.ADUser);
                TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "Site attribute was missing for user's {0} server {1}", new object[]
                {
                    user.ADUser.Id,
                    userServer.Key
                });
            }
            if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MessageTracking.UseBackEndLocator.Enabled)
            {
                return(this.GetAuthorityForSiteUser(userServer.ServerSiteId, user.ADUser));
            }
            return(this.GetAuthorityForSite(userServer.ServerSiteId));
        }
Пример #2
0
        public IList <TrackingAuthority> GetAuthoritiesByPriority(TrackedUser user)
        {
            List <TrackingAuthority> list = new List <TrackingAuthority>(5);

            if (!user.IsMailbox)
            {
                TraceWrapper.SearchLibraryTracer.TraceDebug(this.GetHashCode(), "User not a mailbox, using regular FindUserLocation", new object[0]);
                TrackingAuthority item = this.FindUserLocation(user);
                list.Add(item);
                return(list);
            }
            ServerInfo userServer = ServerCache.Instance.GetUserServer(user.ADUser);

            if (!userServer.IsSearchable)
            {
                TraceWrapper.SearchLibraryTracer.TraceDebug(this.GetHashCode(), "User server is legacy, using regular FindUserLocation", new object[0]);
                TrackingAuthority item2 = this.FindUserLocation(user);
                list.Add(item2);
                return(list);
            }
            ADObjectId serverSiteId = userServer.ServerSiteId;
            Dictionary <ADObjectId, IList <ServerInfo> > userMailboxLocationsBySite = this.GetUserMailboxLocationsBySite(user.ADUser);
            IList <ServerInfo> list2 = null;

            if (!userMailboxLocationsBySite.TryGetValue(serverSiteId, out list2))
            {
                TraceWrapper.SearchLibraryTracer.TraceError <SmtpAddress>(this.GetHashCode(), "Unexpected: no authorities for user: {0}", user.SmtpAddress);
                return(list);
            }
            int num = user.IsArbitrationMailbox ? Constants.E14SP1ModerationReferralSupportVersion : Globals.E14Version;
            TrackingAuthority trackingAuthority;

            if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).MessageTracking.UseBackEndLocator.Enabled)
            {
                trackingAuthority = this.GetAuthorityForSiteUser(serverSiteId, user.ADUser);
            }
            else
            {
                trackingAuthority = this.GetAuthorityForSite(serverSiteId, num);
            }
            if (trackingAuthority == null)
            {
                TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId, int>(this.GetHashCode(), "No authority found for primary mailbox site {0} with minVersion {1}", serverSiteId, num);
            }
            else
            {
                list.Add(trackingAuthority);
            }
            userMailboxLocationsBySite.Remove(serverSiteId);
            foreach (KeyValuePair <ADObjectId, IList <ServerInfo> > keyValuePair in userMailboxLocationsBySite)
            {
                trackingAuthority = this.GetAuthorityForSite(keyValuePair.Key, num);
                if (trackingAuthority == null)
                {
                    TraceWrapper.SearchLibraryTracer.TraceError <ADObjectId, int>(this.GetHashCode(), "No authority found for DAG mailbox site {0} with minVersion {1}", serverSiteId, num);
                    break;
                }
                list.Add(trackingAuthority);
            }
            return(list);
        }