コード例 #1
0
ファイル: KellyTest.cs プロジェクト: ProjectAgri20/newrepo
        public void TestAutoDiscover()
        {
            // Prompt for inputs
            Console.WriteLine("Enter User Name:");
            string userName = Console.ReadLine();

            Console.WriteLine("Enter User Password:"******"Enter Domain:");
            string domain = Console.ReadLine();

            try
            {
                HP.ScalableTest.TraceFactory.Logger.Debug($"Autodiscovering Exchange Server: {userName}@{domain}");
                ExchangeEmailController controller = new ExchangeEmailController(new NetworkCredential(userName, userPassword), new MailAddress($"{userName}@{domain}"));

                //NetworkCredential credential = new NetworkCredential(userName, userPassword);
                //MailAddress address = new MailAddress($"{userName}@{domain}");
                //var uri = ExchangeEmailController.AutodiscoverExchangeUrl(address);
                //Console.WriteLine(uri.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: ProjectAgri20/newrepo
        private IEmailController ConfigureEmailController()
        {
            string           userName    = UserAccount;
            MailAddress      userAddress = new MailAddress(UserAccount);
            string           password    = GlobalSettings.Items[Setting.OfficeWorkerPassword];
            string           domain      = GlobalSettings.Items[Setting.Domain];
            var              credential  = new NetworkCredential(userName, password, domain);
            IEmailController result      = new ExchangeEmailController(credential, userAddress);

            return(result);
        }
コード例 #3
0
ファイル: KellyTest.cs プロジェクト: ProjectAgri20/newrepo
        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);
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="OutputEmailMonitor"/> class.
        /// </summary>
        /// <param name="monitorConfig">The monitor configuration.</param>
        public OutputEmailMonitor(MonitorConfig monitorConfig)
            : base(monitorConfig)
        {
            _timer = new Timer(new TimerCallback(TimerFire));

            // Set up the email controller for this domain
            string password = GlobalSettings.Items[Setting.OfficeWorkerPassword];
            string domain   = GlobalSettings.Items[Setting.Domain];

            _credential   = new NetworkCredential(base.Configuration.MonitorLocation, password, domain);
            _emailAddress = ExchangeEmailController.GetLdapEmailAddress(_credential);

            // Set up a temporary path and make sure it exists
            _tempPath = Path.Combine(Path.GetTempPath(), "EmailMonitor", base.Configuration.MonitorLocation);
            System.IO.Directory.CreateDirectory(_tempPath);
        }
コード例 #5
0
        /// <summary>
        /// Subscribes to Exchange-generated events that monitor new emails for the specified user.
        /// </summary>
        /// <param name="credential"></param>
        public static void Subscribe(NetworkCredential credential)
        {
            if (credential == null)
            {
                throw new ArgumentNullException("credential");
            }

            if (_exchangeUrl == null)
            {
                Initialize(credential);
            }

            if (!_controllers.ContainsKey(credential.UserName))
            {
                IEmailController controller = new ExchangeEmailController(credential, _exchangeUrl);
                _controllers.Add(credential.UserName, controller);

                //Start a background thread to clean out all folders for this user and subscribe to Exchange events.
                //ThreadPool.QueueUserWorkItem(Subscribe_CallBack, controller);
            }
        }
コード例 #6
0
        /// <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;
            }
        }