protected override void WriteResult(IConfigurable dataObject) { TaskLogger.LogEnter(new object[] { dataObject.Identity, dataObject }); ClientAccessArray clientAccessArray = (ClientAccessArray)dataObject; if (clientAccessArray.IsPriorTo15ExchangeObjectVersion) { Server[] cachedServers = ExchangeRpcClientAccess.GetAllPossibleServers((ITopologyConfigurationSession)this.ConfigurationSession, this.siteId).ToArray <Server>(); ExchangeRpcClientAccess[] all = ExchangeRpcClientAccess.GetAll((ITopologyConfigurationSession)this.ConfigurationSession); clientAccessArray.CompleteAllCalculatedProperties(cachedServers, all); } base.WriteResult(dataObject); TaskLogger.LogExit(); }
internal string FindRpcClientAccessArrayOrServer(ITopologyConfigurationSession session, ADObjectId localServerId) { ADSite localSite = session.GetLocalSite(); if (localSite == null) { return(null); } ClientAccessArray[] array = session.Find <ClientAccessArray>(null, QueryScope.SubTree, QueryFilter.AndTogether(new QueryFilter[] { this.GetSiteFilter(localSite.Id), ClientAccessArray.PriorTo15ExchangeObjectVersionFilter }), null, 2); if (array.Length > 0) { return(array[0].ExchangeLegacyDN); } List <string> list = new List <string>(); foreach (KeyValuePair <Server, ExchangeRpcClientAccess> keyValuePair in ExchangeRpcClientAccess.GetServersWithRpcClientAccessEnabled(ExchangeRpcClientAccess.GetAllPossibleServers(session, localSite.Id), ExchangeRpcClientAccess.GetAll(session))) { if ((keyValuePair.Value.Responsibility & RpcClientAccessResponsibility.Mailboxes) != RpcClientAccessResponsibility.None) { if (localServerId.Equals(keyValuePair.Key.Id)) { return(keyValuePair.Key.ExchangeLegacyDN); } list.Add(keyValuePair.Key.ExchangeLegacyDN); } } if (list.Count == 0) { return(null); } return(NewRpcClientAccess.SelectServerWithEqualProbability(list)); }
private static ADObjectId FindServerIdWithClientAccess(ITopologyConfigurationSession adSession, ADObjectId mountedSiteId, ADObjectId preferredServerId) { ADObjectId adobjectId = null; List <ADObjectId> list = new List <ADObjectId>(8); foreach (KeyValuePair <Server, ExchangeRpcClientAccess> keyValuePair in ExchangeRpcClientAccess.GetServersWithRpcClientAccessEnabled(ExchangeRpcClientAccess.GetAllPossibleServers(adSession, mountedSiteId), ExchangeRpcClientAccess.GetAll(adSession))) { if ((keyValuePair.Value.Responsibility & RpcClientAccessResponsibility.Mailboxes) != RpcClientAccessResponsibility.None) { if (preferredServerId != null && preferredServerId.Equals(keyValuePair.Key.Id)) { adobjectId = keyValuePair.Key.Id; break; } list.Add(keyValuePair.Key.Id); } } if (adobjectId == null && list.Count > 0) { adobjectId = list[0]; if (list.Count > 1) { adobjectId = list[(Environment.TickCount & int.MaxValue) % list.Count]; } } return(adobjectId); }