public static void GetOrganizationMailboxesByCapability(IRecipientSession session, OrganizationCapability capability, ADObjectId siteId, out List <ADUser> filteredList, out List <ADUser> completeList) { ExAssert.RetailAssert(!OrganizationMailbox.IsMultiTenantEnvironment(), "GetOrganizationMailboxesByCapability (site-based) should not be used in Datacenter Multitenant environment"); ExTraceGlobals.StorageTracer.TraceDebug <OrganizationCapability>(0L, "Entering GetOrganizationMailboxByCapability capability='{0}'", capability); if (siteId == null) { throw new ArgumentNullException("siteId"); } completeList = OrganizationMailbox.GetOrganizationMailboxesByCapability(session, capability); ExTraceGlobals.StorageTracer.TraceDebug <int, OrganizationCapability>(0L, "GetOrganizationMailboxByCapability -completeList of mailbox, count='{0}', capability='{1}'", completeList.Count, capability); filteredList = new List <ADUser>(); if (completeList.Count > 0) { ExTraceGlobals.StorageTracer.TraceDebug <OrganizationCapability>(0L, "GetOrganizationMailboxByCapability -GetCurrentServiceTopology capability='{0}'", capability); ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\OrganizationMailbox\\OrganizationMailbox.cs", "GetOrganizationMailboxesByCapability", 137); foreach (ADUser aduser in completeList) { ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(session.SessionSettings, aduser, RemotingOptions.AllowCrossSite); string serverFqdn = exchangePrincipal.MailboxInfo.Location.ServerFqdn; ExTraceGlobals.StorageTracer.TraceDebug <string, OrganizationCapability>(0L, "GetOrganizationMailboxByCapability calling GetSite with Prinicipal.ServerFQDN='{0}', capability='{1}'", serverFqdn, capability); Site site = currentServiceTopology.GetSite(serverFqdn, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\OrganizationMailbox\\OrganizationMailbox.cs", "GetOrganizationMailboxesByCapability", 151); Guid objectGuid = site.Id.ObjectGuid; ExTraceGlobals.StorageTracer.TraceDebug <string, Guid, OrganizationCapability>(0L, "GetOrganizationMailboxByCapability GetSite called with Prinicipal.ServerFQDN='{0}', Site='{1}'capability='{2}'", serverFqdn, objectGuid, capability); if (siteId.ObjectGuid.Equals(objectGuid)) { filteredList.Add(aduser); } } } }
private void AddEmailTransportServiceToDictionaries(string localServerFqdn, Dictionary <ServiceType, List <Service> > serviceLists, TopologyServerInfo serverInfo, MiniEmailTransport emailTransport, ClientAccessType clientAccessType, AuthenticationMethod authenticationMethod) { Service service = ServiceTypeInfo.CreateEmailTransportService(emailTransport, serverInfo, clientAccessType, authenticationMethod); ServiceTopology.AddServiceToServiceListDictionary(serviceLists, service); ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug <Service, string, Site>((long)this.GetHashCode(), "ServiceTopology::AddServiceToDictionaries. Found Service. Service = {0}. ServerFqdn = {1}. Site = {2}.", service, serverInfo.ServerFullyQualifiedDomainName, serverInfo.Site); }
public static int ServicesOnCurrentServerFirst(Service left, Service right, ServiceTopology serviceTopology, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0) { ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine); int num = serviceTopology.IsServiceOnCurrentServer <Service>(left, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceTopology.cs", "ServicesOnCurrentServerFirst", 705) ? 1 : 0; int num2 = serviceTopology.IsServiceOnCurrentServer <Service>(right, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceTopology.cs", "ServicesOnCurrentServerFirst", 706) ? 1 : 0; return(num2 - num); }
private void AddSmtpServiceToDictionaries(string localServerFqdn, Dictionary <ServiceType, List <Service> > serviceLists, TopologyServerInfo serverInfo, MiniReceiveConnector smtpReceiveConnector, ClientAccessType clientAccessType) { Service service = ServiceTypeInfo.CreateSmtpService(smtpReceiveConnector, serverInfo, clientAccessType); if (service != null) { ServiceTopology.AddServiceToServiceListDictionary(serviceLists, service); ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug <Service, string, Site>((long)this.GetHashCode(), "ServiceTopology::AddServiceToDictionaries. Found Service. Service = {0}. ServerFqdn = {1}. Site = {2}.", service, serverInfo.ServerFullyQualifiedDomainName, serverInfo.Site); } }
internal static ServiceTopology GetCurrentLegacyServiceTopology(TimeSpan getServiceTopologyTimeout) { ServiceTopology currentServiceTopology = ServiceCache.GetCurrentServiceTopology(getServiceTopologyTimeout); ServiceTopology serviceTopology = ServiceCache.Instance.legacyServiceTopologyInstance; if (serviceTopology == null) { serviceTopology = currentServiceTopology.ToLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceCache.cs", "GetCurrentLegacyServiceTopology", 144); ServiceCache.Instance.legacyServiceTopologyInstance = serviceTopology; } return(serviceTopology); }
public IList <T> FindAll <T>(IExchangePrincipal mailboxUser, ClientAccessType clientAccessType, Predicate <T> serviceFilter, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0) where T : Service { ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine); if (mailboxUser == null) { throw new ArgumentNullException("mailboxUser"); } if (serviceFilter == null) { throw new ArgumentNullException("serviceFilter"); } EnumValidator.ThrowIfInvalid <ClientAccessType>(clientAccessType, "clientAccessType"); ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug((long)this.GetHashCode(), "ServiceTopology::FindAll<{0}>. Finding services. CurrentFQDN = {1}. UserFQDN = {2}. ClientAccessType = {3}.", new object[] { typeof(T).ToString(), this.localServerInfo.ServerFullyQualifiedDomainName, mailboxUser.MailboxInfo.Location.ServerFqdn, clientAccessType }); Site mailboxSite = this.GetSite(mailboxUser.MailboxInfo.Location.ServerFqdn, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceTopology.cs", "FindAll", 1488); ServiceTopology.ServiceComparer <T> comparer = new ServiceTopology.ServiceComparer <T>(this, mailboxUser.MailboxInfo.Location.ServerFqdn); SortedDictionary <T, List <T> > serviceLists = new SortedDictionary <T, List <T> >(comparer); List <T> list = new List <T>(); this.ForEach <T>(delegate(T service) { if (ServiceTopology.IsOnSite(service, mailboxSite, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceTopology.cs", "FindAll", 1496) && service.ClientAccessType == clientAccessType && serviceFilter(service)) { if (!serviceLists.ContainsKey(service)) { serviceLists.Add(service, new List <T>()); } int num = ServiceTopology.Random.Next(serviceLists[service].Count + 1); ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug((long)this.GetHashCode(), "ServiceTopology::FindAll<{0}>. Inserting a service into {1} of {2}. FQDN = {3}.", new object[] { typeof(T).ToString(), num, serviceLists[service].Count, service.ServerFullyQualifiedDomainName }); serviceLists[service].Insert(num, service); } }, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceTopology.cs", "FindAll", 1492); foreach (KeyValuePair <T, List <T> > keyValuePair in serviceLists) { list.AddRange(keyValuePair.Value); } return(list.AsReadOnly()); }
internal static ServiceTopology GetCurrentServiceTopology(TimeSpan getServiceTopologyTimeout) { ServiceCache instance = ServiceCache.Instance; instance.DropCacheIfNeeded(); instance.TriggerCacheRefreshIfNeeded(); ServiceTopology serviceTopology = instance.serviceTopologyInstance; if (serviceTopology == null) { if (!instance.cachePresentEvent.WaitOne(getServiceTopologyTimeout, false)) { throw new ReadTopologyTimeoutException(ServerStrings.ExReadTopologyTimeout); } serviceTopology = instance.serviceTopologyInstance; } serviceTopology.IncrementRequestCount("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceCache.cs", "GetCurrentServiceTopology", 188); return(serviceTopology); }
private string GetEnterpriseOrE14SharingUrl(ExchangePrincipal exchangePrincipal) { SharedFolderDataEncryption.Tracer.TraceDebug <ExchangePrincipal, bool>((long)this.GetHashCode(), "Entering GetEnterpriseOrE14SharingUrl - mailbox {0}, isMultitenancyEnabled={1}", exchangePrincipal, this.IsMultitenancyEnabled); ServiceTopology serviceTopology = this.IsMultitenancyEnabled ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\SharedFolderDataEncryption.cs", "GetEnterpriseOrE14SharingUrl", 655) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\SharedFolderDataEncryption.cs", "GetEnterpriseOrE14SharingUrl", 655); IList <WebServicesService> list = serviceTopology.FindAll <WebServicesService>(exchangePrincipal, ClientAccessType.External, SharedFolderDataEncryption.serviceVersionFilter, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\SharedFolderDataEncryption.cs", "GetEnterpriseOrE14SharingUrl", 658); if (list.Count != 0) { return(EwsWsSecurityUrl.Fix(list[0].Url.ToString())); } SharedFolderDataEncryption.Tracer.TraceDebug <ExchangePrincipal>((long)this.GetHashCode(), "Unable to find a CAS with external access in same site of user {0}. Trying other sites.", exchangePrincipal); WebServicesService webServicesService = serviceTopology.FindAny <WebServicesService>(ClientAccessType.External, SharedFolderDataEncryption.serviceVersionFilter, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\SharedFolderDataEncryption.cs", "GetEnterpriseOrE14SharingUrl", 671); if (webServicesService == null) { throw new NoExternalEwsAvailableException(); } return(EwsWsSecurityUrl.Fix(webServicesService.Url.ToString())); }
private ServiceTopology(ServiceTopology completeTopology) { this.siteToServersDictionary = new Dictionary <Site, List <TopologyServerInfo> >(completeTopology.siteToServersDictionary.Count); this.serverToSiteDictionary = new Dictionary <string, Site>(completeTopology.serverToSiteDictionary.Count, StringComparer.OrdinalIgnoreCase); this.serverFqdnDictionary = new Dictionary <string, TopologyServerInfo>(completeTopology.serverFqdnDictionary.Count, StringComparer.OrdinalIgnoreCase); foreach (TopologyServerInfo topologyServerInfo in completeTopology.serverFqdnDictionary.Values) { if (topologyServerInfo.VersionNumber < Server.E15MinVersion) { this.serverFqdnDictionary.Add(topologyServerInfo.ServerFullyQualifiedDomainName, topologyServerInfo); Site site = topologyServerInfo.Site; this.serverToSiteDictionary.Add(topologyServerInfo.ServerFullyQualifiedDomainName, site); List <TopologyServerInfo> list; if (!this.siteToServersDictionary.TryGetValue(site, out list)) { list = new List <TopologyServerInfo>(); this.siteToServersDictionary.Add(site, list); } list.Add(topologyServerInfo); } } this.services = new Dictionary <ServiceType, List <Service> >(completeTopology.services.Count); foreach (KeyValuePair <ServiceType, List <Service> > keyValuePair in completeTopology.services) { List <Service> list2 = new List <Service>(); foreach (Service service in keyValuePair.Value) { if (service.ServerVersionNumber <= Server.E15MinVersion) { list2.Add(service); } } this.services.Add(keyValuePair.Key, list2); } this.cafeServices = null; this.serversWithoutSite = completeTopology.serversWithoutSite; this.localServerInfo = completeTopology.localServerInfo; this.discoveryStarted = completeTopology.DiscoveryStarted; this.siteDictionary = completeTopology.siteDictionary; this.creationTime = completeTopology.creationTime; this.connectionCostCalculator = new ConnectionCostCalculator(this.siteDictionary.Count); }
private static Uri GetEcpServiceUrl(ExchangePrincipal principal, ClientAccessType type) { bool enabled = VariantConfiguration.InvariantNoFlightingSnapshot.Global.MultiTenancy.Enabled; if (principal.MailboxInfo.Location.ServerVersion >= Server.E15MinVersion && enabled) { return(TextMessagingHelper.GetE15MultitenancyEcpServiceUrl(principal, type)); } ServiceTopology serviceTopology = enabled ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\sms\\TextMessagingHelper.cs", "GetEcpServiceUrl", 371) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\sms\\TextMessagingHelper.cs", "GetEcpServiceUrl", 371); if (serviceTopology != null) { IList <EcpService> list = serviceTopology.FindAll <EcpService>(principal, type, "f:\\15.00.1497\\sources\\dev\\data\\src\\ApplicationLogic\\sms\\TextMessagingHelper.cs", "GetEcpServiceUrl", 374); if (list != null && 0 < list.Count) { return(list[0].Url); } } return(null); }
private void DropCacheIfNeeded() { ServiceTopology serviceTopology = this.serviceTopologyInstance; ServiceTopology serviceTopology2 = this.legacyServiceTopologyInstance; ExDateTime utcNow = ExDateTime.UtcNow; ExDateTime exDateTime = ExDateTime.MaxValue; if (serviceTopology != null) { exDateTime = serviceTopology.CreationTime; } if (serviceTopology2 != null && serviceTopology2.CreationTime < exDateTime) { exDateTime = serviceTopology2.CreationTime; } if (exDateTime != ExDateTime.MaxValue && utcNow - exDateTime > ServiceDiscovery.ExchangeTopologyBridge.CacheExpirationTimeout) { this.DropCache(); } }
private Uri GetEnterpriseOrE14OwaServiceUrl(IExchangePrincipal exchangePrincipal) { ServiceTopology serviceTopology = this.IsMultitenancyEnabled ? ServiceTopology.GetCurrentLegacyServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\OwaAnonymousVdirLocater.cs", "GetEnterpriseOrE14OwaServiceUrl", 230) : ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\OwaAnonymousVdirLocater.cs", "GetEnterpriseOrE14OwaServiceUrl", 230); Predicate <OwaService> serviceFilter = (OwaService service) => service.AnonymousFeaturesEnabled; IList <OwaService> list = serviceTopology.FindAll <OwaService>(exchangePrincipal, ClientAccessType.External, serviceFilter, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\OwaAnonymousVdirLocater.cs", "GetEnterpriseOrE14OwaServiceUrl", 235); OwaService owaService; if (list.Count > 0) { owaService = list[0]; } else { owaService = serviceTopology.FindAny <OwaService>(ClientAccessType.External, serviceFilter, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\OwaAnonymousVdirLocater.cs", "GetEnterpriseOrE14OwaServiceUrl", 247); if (owaService == null) { throw new NoExternalOwaAvailableException(); } } return(owaService.Url); }
public int Compare(T x, T y) { if (object.ReferenceEquals(x, y)) { return(0); } if (x == null) { return(-1); } if (y == null) { return(1); } int num = ServiceTopology.ServicesOnCurrentServerFirst(x, y, this.serviceTopology, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceTopology.cs", "Compare", 1889); if (num == 0) { num = ServiceTopology.CasMbxServicesFirst(x, y, this.serverFQDN, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\ServiceDiscovery\\ServiceTopology.cs", "Compare", 1893); } return(num); }
private void TriggerCacheRefresh(ServiceCache.CachePopulateReason reason, ServiceTopology requestingTopology) { if (requestingTopology != null) { ServiceTopology serviceTopology = this.serviceTopologyInstance; if (requestingTopology != serviceTopology) { return; } if (serviceTopology != null && serviceTopology.CreationTime + ServiceDiscovery.ExchangeTopologyBridge.MinExpirationTimeForCacheDueToCacheMiss > ExDateTime.UtcNow) { return; } } bool flag = false; bool flag2 = this.semaphore.WaitOne(0, false); try { if (flag2 && (requestingTopology == null || requestingTopology == this.serviceTopologyInstance)) { this.StopCacheRefreshTimer(); this.DropCacheIfNeeded(); using (ActivityContext.SuppressThreadScope()) { flag = ThreadPool.QueueUserWorkItem(new WaitCallback(this.PopulateServiceCache), reason); } } } finally { if (flag2 && !flag) { this.semaphore.Release(); } } }
internal static void TriggerCacheRefreshDueToCacheMiss(ServiceTopology requestingTopology) { Util.ThrowOnNullArgument(requestingTopology, "requestingTopology"); ServiceCache.Instance.TriggerCacheRefresh(ServiceCache.CachePopulateReason.CacheMissDetected, requestingTopology); }
internal ServiceTopology(ExchangeTopology topology, [CallerFilePath] string callerFilePath = null, [CallerMemberName] string memberName = null, [CallerLineNumber] int callerFileLine = 0) { ServiceTopologyLog.Instance.Append(callerFilePath, memberName, callerFileLine); ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug((long)this.GetHashCode(), "ServiceTopology::Constructor. Creating a ServiceTopology object..."); if (topology.LocalServer == null) { ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug((long)this.GetHashCode(), "ServiceTopology::ServiceTopology.ctor. Cannot find the local server from ExchangeTopology. topology.LocalServer == null."); throw new ServerNotFoundException(ServerStrings.ExServerNotFound("localhost"), "localhost"); } string fqdn = topology.LocalServer.Fqdn; this.discoveryStarted = topology.DiscoveryStarted; Dictionary <string, TopologyServerInfo> dictionary = new Dictionary <string, TopologyServerInfo>(topology.AllTopologyServers.Count, StringComparer.OrdinalIgnoreCase); Dictionary <string, Site> dictionary2 = new Dictionary <string, Site>(topology.AllTopologyServers.Count, StringComparer.OrdinalIgnoreCase); List <string> list = new List <string>(); Dictionary <Site, List <TopologyServerInfo> > dictionary3 = new Dictionary <Site, List <TopologyServerInfo> >(topology.AllTopologySites.Count); ServiceTopology.All all = new ServiceTopology.All(topology); foreach (TopologyServer topologyServer in topology.AllTopologyServers) { if (topologyServer.TopologySite != null) { if (!dictionary2.ContainsKey(topologyServer.Fqdn)) { TopologyServerInfo topologyServerInfo = TopologyServerInfo.Get(topologyServer, all); Site site = topologyServerInfo.Site; dictionary.Add(topologyServer.Fqdn, topologyServerInfo); dictionary2.Add(topologyServer.Fqdn, site); List <TopologyServerInfo> list2; if (!dictionary3.TryGetValue(site, out list2)) { list2 = new List <TopologyServerInfo>(); dictionary3.Add(site, list2); } list2.Add(topologyServerInfo); ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug <string, string, Site>((long)this.GetHashCode(), "ServiceTopology::Constructor. Found Server in topology. ServerDn = {0}. Server Fqdn = {1}. Site = {2}.", topologyServer.DistinguishedName, topologyServer.Fqdn, site); } else { string arg = string.Empty; foreach (KeyValuePair <string, TopologyServerInfo> keyValuePair in all.Servers) { if (keyValuePair.Value.ServerFullyQualifiedDomainName.Equals(topologyServer.Fqdn)) { arg = keyValuePair.Key; break; } } ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "ServiceTopology::Constructor. There are two servers with the same fqdn in the topology. The second server was ignored. Fqdn = {0}. Server1Dn = {1}. Server2Dn = {2}.", topologyServer.Fqdn, arg, topologyServer.DistinguishedName); } } else { ExTraceGlobals.ServiceDiscoveryTracer.TraceDebug <string>((long)this.GetHashCode(), "ServiceTopology::Constructor. Found a Server in the topology without a defined Site. Server = {0}.", topologyServer.DistinguishedName); if (fqdn.Equals(topologyServer.Fqdn)) { throw new ServerNotInSiteException(ServerStrings.ExCurrentServerNotInSite(fqdn), fqdn); } if (!list.Contains(topologyServer.Fqdn)) { list.Add(topologyServer.Fqdn); } } } Dictionary <ServiceType, List <Service> > serviceLists = new Dictionary <ServiceType, List <Service> >(); Dictionary <ServiceType, List <Service> > serviceLists2 = new Dictionary <ServiceType, List <Service> >(); ReadOnlyCollection <MiniVirtualDirectory> allVirtualDirectories = topology.AllVirtualDirectories; if (allVirtualDirectories != null) { foreach (MiniVirtualDirectory miniVirtualDirectory in allVirtualDirectories) { TopologyServerInfo serverInfo; if (all.Servers.TryGetValue(miniVirtualDirectory.Server.DistinguishedName, out serverInfo)) { if (HttpService.IsFrontEndRole(miniVirtualDirectory, serverInfo)) { this.AddHttpServiceToDictionaries(fqdn, serviceLists2, serverInfo, miniVirtualDirectory, ClientAccessType.Unknown, null, AuthenticationMethod.None); } if (miniVirtualDirectory.InternalUrl != null) { AuthenticationMethod authenticationMethod = ServiceTopology.GetAuthenticationMethod(miniVirtualDirectory[MiniVirtualDirectorySchema.InternalAuthenticationMethodFlags]); this.AddHttpServiceToDictionaries(fqdn, serviceLists, serverInfo, miniVirtualDirectory, ClientAccessType.Internal, miniVirtualDirectory.InternalUrl, authenticationMethod); } if (miniVirtualDirectory.IsWebServices && miniVirtualDirectory.InternalNLBBypassUrl != null) { AuthenticationMethod authenticationMethod2 = ServiceTopology.GetAuthenticationMethod(miniVirtualDirectory[MiniVirtualDirectorySchema.InternalAuthenticationMethodFlags]); this.AddHttpServiceToDictionaries(fqdn, serviceLists, serverInfo, miniVirtualDirectory, ClientAccessType.InternalNLBBypass, miniVirtualDirectory.InternalNLBBypassUrl, authenticationMethod2); } if (miniVirtualDirectory.ExternalUrl != null) { AuthenticationMethod authenticationMethod3 = ServiceTopology.GetAuthenticationMethod(miniVirtualDirectory[MiniVirtualDirectorySchema.ExternalAuthenticationMethodFlags]); this.AddHttpServiceToDictionaries(fqdn, serviceLists, serverInfo, miniVirtualDirectory, ClientAccessType.External, miniVirtualDirectory.ExternalUrl, authenticationMethod3); } } } } ReadOnlyCollection <MiniEmailTransport> allEmailTransports = topology.AllEmailTransports; if (allEmailTransports != null) { foreach (MiniEmailTransport miniEmailTransport in allEmailTransports) { if (miniEmailTransport.IsPop3 || miniEmailTransport.IsImap4) { MiniEmailTransport miniEmailTransport2 = miniEmailTransport; TopologyServerInfo topologyServerInfo2; if (all.Servers.TryGetValue(miniEmailTransport2.Server.DistinguishedName, out topologyServerInfo2)) { bool flag = miniEmailTransport2.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2010); ServerVersion serverVersion = new ServerVersion(topologyServerInfo2.VersionNumber); flag |= (VariantConfiguration.InvariantNoFlightingSnapshot.DataStorage.CheckR3Coexistence.Enabled && serverVersion.Major == Server.Exchange2009MajorVersion && serverVersion.Build == 482); if ((miniEmailTransport2.InternalConnectionSettings != null && miniEmailTransport2.InternalConnectionSettings.Count > 0) || flag) { this.AddEmailTransportServiceToDictionaries(fqdn, serviceLists, topologyServerInfo2, miniEmailTransport2, ClientAccessType.Internal, AuthenticationMethod.None); } if ((miniEmailTransport2.ExternalConnectionSettings != null && miniEmailTransport2.ExternalConnectionSettings.Count > 0) || flag) { this.AddEmailTransportServiceToDictionaries(fqdn, serviceLists, topologyServerInfo2, miniEmailTransport2, ClientAccessType.External, AuthenticationMethod.None); } } } } } ReadOnlyCollection <MiniReceiveConnector> allSmtpReceiveConnectors = topology.AllSmtpReceiveConnectors; if (allSmtpReceiveConnectors != null) { foreach (MiniReceiveConnector miniReceiveConnector in allSmtpReceiveConnectors) { TopologyServerInfo serverInfo2; if (all.Servers.TryGetValue(miniReceiveConnector.Server.DistinguishedName, out serverInfo2)) { this.AddSmtpServiceToDictionaries(fqdn, serviceLists, serverInfo2, miniReceiveConnector, ClientAccessType.External); this.AddSmtpServiceToDictionaries(fqdn, serviceLists, serverInfo2, miniReceiveConnector, ClientAccessType.Internal); } } } Dictionary <string, Site> dictionary4 = new Dictionary <string, Site>(topology.AllTopologySites.Count, StringComparer.OrdinalIgnoreCase); foreach (TopologySite topologySite in topology.AllTopologySites) { dictionary4[topologySite.DistinguishedName] = Site.Get(topologySite, all); } this.localServerInfo = TopologyServerInfo.Get(topology.LocalServer, all); this.serverToSiteDictionary = dictionary2; this.services = serviceLists; this.cafeServices = serviceLists2; this.serversWithoutSite = list; this.siteToServersDictionary = dictionary3; this.siteDictionary = dictionary4; this.serverFqdnDictionary = dictionary; this.connectionCostCalculator = new ConnectionCostCalculator(topology.AllTopologySites.Count); }
private static void SyncInternal(MailboxSession mailboxSession, ExDateTime lastSyncTime, StoreId folderId, string folderDisplayname, SecurityAccessToken securityAccessToken) { RefreshSharingFolderClient.Tracer.TraceDebug <string, IExchangePrincipal>(0L, "Sync sharing folder {0} from mailbox {1}", folderDisplayname, mailboxSession.MailboxOwner); if (!RefreshSharingFolderClient.CanSyncNow(lastSyncTime)) { return; } NetworkServiceImpersonator.Initialize(); if (NetworkServiceImpersonator.Exception != null) { RefreshSharingFolderClient.Tracer.TraceError <LocalizedException>(0L, "Unable to impersonate network service to call EWS due exception {0}", NetworkServiceImpersonator.Exception); return; } string id = StoreId.StoreIdToEwsId(mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, folderId); IList <WebServicesService> list; try { ClientAccessType clientAccessType = RefreshSharingFolderClient.ClientAccessType; RefreshSharingFolderClient.Tracer.TraceDebug <ClientAccessType>(0L, "Will try to discover the URL for EWS with the following client access type: {0}", clientAccessType); ServiceTopology currentServiceTopology = ServiceTopology.GetCurrentServiceTopology("f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\RefreshSharingFolderClient.cs", "SyncInternal", 153); list = currentServiceTopology.FindAll <WebServicesService>(mailboxSession.MailboxOwner, clientAccessType, "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Sharing\\RefreshSharingFolderClient.cs", "SyncInternal", 154); } catch (LocalizedException arg) { RefreshSharingFolderClient.Tracer.TraceError <IExchangePrincipal, LocalizedException>(0L, "Unable to discover internal URL for EWS for mailbox {0} due exception {1}", mailboxSession.MailboxOwner, arg); return; } if (list.Count != 0) { string text = list[0].Url.ToString(); RefreshSharingFolderClient.Tracer.TraceDebug <string>(0L, "Using {0} to call BeginRefreshSharingFolder", text); ExchangeServiceBinding exchangeServiceBinding = new ExchangeServiceBinding("RefreshSharingFolder", new RemoteCertificateValidationCallback(RefreshSharingFolderClient.CertificateErrorHandler)); exchangeServiceBinding.Url = text; exchangeServiceBinding.RequestServerVersionValue = new RequestServerVersion(); exchangeServiceBinding.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2010; exchangeServiceBinding.UserAgent = WellKnownUserAgent.GetEwsNegoAuthUserAgent("RefreshSharingFolder"); exchangeServiceBinding.Authenticator = SoapHttpClientAuthenticator.CreateNetworkService(); exchangeServiceBinding.Authenticator.AdditionalSoapHeaders.Add(new SerializedSecurityContextType { UserSid = securityAccessToken.UserSid, GroupSids = RefreshSharingFolderClient.SidStringAndAttributesConverter(securityAccessToken.GroupSids), RestrictedGroupSids = RefreshSharingFolderClient.SidStringAndAttributesConverter(securityAccessToken.RestrictedGroupSids), PrimarySmtpAddress = mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString() }); Exception ex = null; try { exchangeServiceBinding.BeginRefreshSharingFolder(new RefreshSharingFolderType { SharingFolderId = new FolderIdType { Id = id } }, new AsyncCallback(RefreshSharingFolderClient.TraceResponse), exchangeServiceBinding); } catch (SoapException ex2) { ex = ex2; } catch (WebException ex3) { ex = ex3; } catch (IOException ex4) { ex = ex4; } catch (InvalidOperationException ex5) { ex = ex5; } catch (LocalizedException ex6) { ex = ex6; } if (ex != null) { RefreshSharingFolderClient.Tracer.TraceError <StoreId, IExchangePrincipal, Exception>(0L, "Unable to sync sharing folder {0} in mailbox {1}. Exception {2}", folderId, mailboxSession.MailboxOwner, ex); } return; } RefreshSharingFolderClient.Tracer.TraceError <IExchangePrincipal>(0L, "Unable to find internal URL for EWS for mailbox {0}", mailboxSession.MailboxOwner); }
public ServiceComparer(ServiceTopology serviceTopology, string fqdn) { this.serviceTopology = serviceTopology; this.serverFQDN = fqdn; }