protected bool ValidateAutoDiscover(out string ewsUrl, out string oabUrl)
        {
            AutoDiscoverValidator autoDiscoverValidator = new AutoDiscoverValidator(this.AutoDiscoverUrl, this.TestAccount.Credential, this.TestAccount.User.PrimarySmtpAddress.ToString())
            {
                VerboseDelegate    = new Task.TaskVerboseLoggingDelegate(base.WriteVerbose),
                UserAgent          = this.UserAgentString,
                IgnoreSslCertError = (this.TrustAnySSLCertificate || this.MonitoringContext.IsPresent),
                Provider           = (this.IsOutlookProvider ? AutoDiscoverValidator.ProviderSchema.Outlook : AutoDiscoverValidator.ProviderSchema.Soap)
            };

            WebServicesTestOutcome.TestScenario scenario = this.IsOutlookProvider ? WebServicesTestOutcome.TestScenario.AutoDiscoverOutlookProvider : WebServicesTestOutcome.TestScenario.AutoDiscoverSoapProvider;
            bool flag = autoDiscoverValidator.Invoke();
            WebServicesTestOutcome outcome = new WebServicesTestOutcome
            {
                Scenario            = scenario,
                Source              = this.LocalServer.Fqdn,
                Result              = (flag ? CasTransactionResultEnum.Success : CasTransactionResultEnum.Failure),
                Error               = string.Format("{0}", autoDiscoverValidator.Error),
                ServiceEndpoint     = TestWebServicesTaskBase.FqdnFromUrl(this.AutoDiscoverUrl),
                Latency             = autoDiscoverValidator.Latency,
                ScenarioDescription = TestWebServicesTaskBase.GetScenarioDescription(scenario),
                Verbose             = autoDiscoverValidator.Verbose
            };

            this.Output(outcome);
            ewsUrl = autoDiscoverValidator.EwsUrl;
            oabUrl = autoDiscoverValidator.OabUrl;
            return(flag);
        }
 protected string GetSpecifiedEwsUrl()
 {
     if (this.MonitoringContext.IsPresent)
     {
         return(TestWebServicesTaskBase.FormatEwsUrl(this.LocalServer.Fqdn));
     }
     if (this.ClientAccessServerFqdn != null)
     {
         return(TestWebServicesTaskBase.FormatEwsUrl(this.ClientAccessServerFqdn));
     }
     return(null);
 }
        protected override void InternalProcessRecord()
        {
            string text;
            string text2;
            bool   flag  = base.ValidateAutoDiscover(out text, out text2);
            string text3 = null;

            WebServicesTestOutcome.TestScenario scenario = this.LightMode.IsPresent ? WebServicesTestOutcome.TestScenario.EwsConvertId : WebServicesTestOutcome.TestScenario.EwsGetFolder;
            if (base.IsFromAutoDiscover)
            {
                if (string.IsNullOrEmpty(text))
                {
                    base.OutputSkippedOutcome(scenario, Strings.InformationSkippedEws);
                }
                else
                {
                    text3 = text;
                    base.WriteVerbose(Strings.VerboseTestEwsFromAutoDiscover(text3));
                }
            }
            else
            {
                text3 = base.GetSpecifiedEwsUrl();
                base.WriteVerbose(Strings.VerboseTestEwsFromParameter(text3));
            }
            if (!string.IsNullOrEmpty(text3))
            {
                EwsValidator ewsValidator = new EwsValidator(text3, base.TestAccount.Credential, base.TestAccount.User.PrimarySmtpAddress.ToString())
                {
                    VerboseDelegate         = new Task.TaskVerboseLoggingDelegate(base.WriteVerbose),
                    UserAgent               = base.UserAgentString,
                    IgnoreSslCertError      = (base.TrustAnySSLCertificate || base.MonitoringContext.IsPresent),
                    Operation               = (this.LightMode.IsPresent ? EwsValidator.RequestOperation.ConvertId : EwsValidator.RequestOperation.GetFolder),
                    PublicFolderMailboxGuid = ((base.TestAccount.User.RecipientTypeDetails == RecipientTypeDetails.PublicFolderMailbox) ? base.TestAccount.User.ExchangeGuid : Guid.Empty)
                };
                flag = ewsValidator.Invoke();
                WebServicesTestOutcome outcome = new WebServicesTestOutcome
                {
                    Scenario            = scenario,
                    Source              = base.LocalServer.Fqdn,
                    Result              = (flag ? CasTransactionResultEnum.Success : CasTransactionResultEnum.Failure),
                    Error               = string.Format("{0}", ewsValidator.Error),
                    ServiceEndpoint     = TestWebServicesTaskBase.FqdnFromUrl(text3),
                    Latency             = ewsValidator.Latency,
                    ScenarioDescription = TestWebServicesTaskBase.GetScenarioDescription(scenario),
                    Verbose             = ewsValidator.Verbose
                };
                base.Output(outcome);
            }
            base.InternalProcessRecord();
        }
        protected void OutputSkippedOutcome(WebServicesTestOutcome.TestScenario scenario, LocalizedString message)
        {
            WebServicesTestOutcome outcome = new WebServicesTestOutcome
            {
                Scenario            = scenario,
                Source              = this.LocalServer.Fqdn,
                Result              = CasTransactionResultEnum.Skipped,
                Error               = message.ToString(),
                ServiceEndpoint     = string.Empty,
                Latency             = 0L,
                ScenarioDescription = TestWebServicesTaskBase.GetScenarioDescription(scenario)
            };

            this.Output(outcome);
        }
 protected void OutputMonitoringData()
 {
     if (this.MonitoringContext.IsPresent)
     {
         MonitoringData monitoringData = new MonitoringData();
         foreach (WebServicesTestOutcome webServicesTestOutcome in this.outcomes)
         {
             MonitoringEvent item = new MonitoringEvent("MSExchange Monitoring " + this.CmdletName, webServicesTestOutcome.MonitoringEventId, TestWebServicesTaskBase.EventTypeFromCasResultEnum(webServicesTestOutcome.Result), webServicesTestOutcome.ToString());
             monitoringData.Events.Add(item);
             if (Datacenter.IsMultiTenancyEnabled())
             {
                 EventLogEntryType entryType = EventLogEntryType.Information;
                 string            text;
                 if (webServicesTestOutcome.Result == CasTransactionResultEnum.Failure)
                 {
                     entryType = EventLogEntryType.Error;
                     text      = Strings.WebServicesTestErrorEventDetail(this.CmdletName, webServicesTestOutcome.Scenario.ToString(), webServicesTestOutcome.Result.ToString(), webServicesTestOutcome.Latency.ToString(), webServicesTestOutcome.Error, webServicesTestOutcome.Verbose);
                 }
                 else if (webServicesTestOutcome.Result == CasTransactionResultEnum.Skipped)
                 {
                     entryType = EventLogEntryType.Warning;
                     text      = Strings.WebServicesTestEventDetail(this.CmdletName, webServicesTestOutcome.Scenario.ToString(), webServicesTestOutcome.Result.ToString(), string.Empty);
                 }
                 else
                 {
                     text = Strings.WebServicesTestEventDetail(this.CmdletName, webServicesTestOutcome.Scenario.ToString(), webServicesTestOutcome.Result.ToString(), webServicesTestOutcome.Latency.ToString());
                 }
                 ExEventLog.EventTuple tuple = new ExEventLog.EventTuple((uint)webServicesTestOutcome.MonitoringEventId, 0, entryType, ExEventLog.EventLevel.Lowest, ExEventLog.EventPeriod.LogAlways);
                 TestWebServicesTaskBase.EventLog.LogEvent(tuple, string.Empty, new object[]
                 {
                     text
                 });
             }
         }
         base.WriteObject(monitoringData);
     }
 }
Пример #6
0
        protected override void InternalProcessRecord()
        {
            string text  = null;
            string text2 = null;
            bool   flag  = base.ValidateAutoDiscover(out text, out text2);

            if (!base.IsFromAutoDiscover)
            {
                text  = base.GetSpecifiedEwsUrl();
                text2 = this.GetSpecifiedOabUrl();
            }
            if (string.IsNullOrEmpty(text))
            {
                base.OutputSkippedOutcome(WebServicesTestOutcome.TestScenario.ExchangeWebServices, Strings.InformationSkippedEws);
                base.OutputSkippedOutcome(WebServicesTestOutcome.TestScenario.AvailabilityService, Strings.InformationSkippedAsForAutodiscover);
            }
            else
            {
                if (base.IsFromAutoDiscover)
                {
                    base.WriteVerbose(Strings.VerboseTestEwsFromAutoDiscover(text));
                }
                else
                {
                    base.WriteVerbose(Strings.VerboseTestEwsFromParameter(text));
                }
                EwsValidator ewsValidator = new EwsValidator(text, base.TestAccount.Credential)
                {
                    VerboseDelegate    = new Task.TaskVerboseLoggingDelegate(base.WriteVerbose),
                    UserAgent          = base.UserAgentString,
                    IgnoreSslCertError = (base.TrustAnySSLCertificate || base.MonitoringContext.IsPresent)
                };
                flag = ewsValidator.Invoke();
                WebServicesTestOutcome outcome = new WebServicesTestOutcome
                {
                    Scenario            = WebServicesTestOutcome.TestScenario.ExchangeWebServices,
                    Source              = base.LocalServer.Fqdn,
                    Result              = (flag ? CasTransactionResultEnum.Success : CasTransactionResultEnum.Failure),
                    Error               = string.Format("{0}", ewsValidator.Error),
                    ServiceEndpoint     = TestWebServicesTaskBase.FqdnFromUrl(text),
                    Latency             = ewsValidator.Latency,
                    ScenarioDescription = TestWebServicesTaskBase.GetScenarioDescription(WebServicesTestOutcome.TestScenario.ExchangeWebServices),
                    Verbose             = ewsValidator.Verbose
                };
                base.Output(outcome);
                if (flag)
                {
                    EwsValidator ewsValidator2 = new EwsValidator(text, base.TestAccount.Credential)
                    {
                        VerboseDelegate    = new Task.TaskVerboseLoggingDelegate(base.WriteVerbose),
                        UserAgent          = base.UserAgentString,
                        IgnoreSslCertError = (base.TrustAnySSLCertificate || base.MonitoringContext.IsPresent),
                        EmailAddress       = base.TestAccount.User.PrimarySmtpAddress.ToString(),
                        Operation          = EwsValidator.RequestOperation.GetUserAvailability
                    };
                    flag    = ewsValidator2.Invoke();
                    outcome = new WebServicesTestOutcome
                    {
                        Scenario            = WebServicesTestOutcome.TestScenario.AvailabilityService,
                        Source              = base.LocalServer.Fqdn,
                        Result              = (flag ? CasTransactionResultEnum.Success : CasTransactionResultEnum.Failure),
                        Error               = string.Format("{0}", ewsValidator2.Error),
                        ServiceEndpoint     = TestWebServicesTaskBase.FqdnFromUrl(text),
                        Latency             = ewsValidator2.Latency,
                        ScenarioDescription = TestWebServicesTaskBase.GetScenarioDescription(WebServicesTestOutcome.TestScenario.AvailabilityService),
                        Verbose             = ewsValidator2.Verbose
                    };
                    base.Output(outcome);
                }
                else
                {
                    base.OutputSkippedOutcome(WebServicesTestOutcome.TestScenario.AvailabilityService, Strings.InformationSkippedAsForEWS);
                }
            }
            if (string.IsNullOrEmpty(text2))
            {
                base.OutputSkippedOutcome(WebServicesTestOutcome.TestScenario.OfflineAddressBook, Strings.InformationSkippedOab);
            }
            else
            {
                if (base.IsFromAutoDiscover)
                {
                    base.WriteVerbose(Strings.VerboseTestOabFromAutoDiscover(text2));
                }
                else
                {
                    base.WriteVerbose(Strings.VerboseTestOabFromParameter(text2));
                }
                OabValidator oabValidator = new OabValidator(text2, base.TestAccount.Credential)
                {
                    VerboseDelegate    = new Task.TaskVerboseLoggingDelegate(base.WriteVerbose),
                    UserAgent          = base.UserAgentString,
                    IgnoreSslCertError = (base.TrustAnySSLCertificate || base.MonitoringContext.IsPresent)
                };
                flag = oabValidator.Invoke();
                WebServicesTestOutcome outcome2 = new WebServicesTestOutcome
                {
                    Scenario            = WebServicesTestOutcome.TestScenario.OfflineAddressBook,
                    Source              = base.LocalServer.Fqdn,
                    Result              = (flag ? CasTransactionResultEnum.Success : CasTransactionResultEnum.Failure),
                    Error               = string.Format("{0}", oabValidator.Error),
                    ServiceEndpoint     = TestWebServicesTaskBase.FqdnFromUrl(text2),
                    Latency             = oabValidator.Latency,
                    ScenarioDescription = TestWebServicesTaskBase.GetScenarioDescription(WebServicesTestOutcome.TestScenario.OfflineAddressBook),
                    Verbose             = oabValidator.Verbose
                };
                base.Output(outcome2);
            }
            base.InternalProcessRecord();
        }