private static void Autodiscover(string userName, string domain) { NetworkCredential credential = new NetworkCredential(userName, domain); HP.ScalableTest.TraceFactory.Logger.Debug("Autodiscovering..."); HP.ScalableTest.TraceFactory.Logger.Debug("User:"******"Domain: " + domain); MailAddress address = ExchangeEmailController.GetLdapEmailAddress(credential); var uri = ExchangeEmailController.AutodiscoverExchangeUrl(address); HP.ScalableTest.TraceFactory.Logger.Debug("Autodiscovered URL:" + uri.ToString()); _emailController = new ExchangeEmailController(credential, uri); }
/// <summary> /// Initializes the Exchange version and the URL so we don't have to use autodiscover for all the subscribers. /// </summary> /// <param name="credential"></param> private static void Initialize(NetworkCredential credential) { ExchangeConnectionSettings settings = new ExchangeConnectionSettings(_exchangeServerSettings); if (settings.AutodiscoverEnabled) { Action action = new Action(() => { TraceFactory.Logger.Debug("Autodiscover lock acquired. Autodiscovering the Exchange Server."); MailAddress autodiscoverAddress = ExchangeEmailController.GetLdapEmailAddress(credential); _exchangeUrl = ExchangeEmailController.AutodiscoverExchangeUrl(autodiscoverAddress); }); TraceFactory.Logger.Debug("Attempting to autodiscover against Exchange"); CriticalSection criticalSection = new CriticalSection(new DistributedLockManager(GlobalSettings.WcfHosts["Lock"])); criticalSection.Run(new LocalLockToken("ExchangeAutodiscover", new TimeSpan(0, 5, 0), new TimeSpan(0, 5, 0)), action); } else { TraceFactory.Logger.Debug("Configuring exchange service using Exchange Web Services URL."); _exchangeUrl = settings.EwsUrl; } }