protected sealed override List <CasTransactionOutcome> ExecuteTests(TestCasConnectivity.TestCasConnectivityRunInstance instance) { TaskLogger.LogEnter(); try { VirtualDirectoryUriScope virtualDirectoryUriScope; Uri testUri = this.GetTestUri(instance, out virtualDirectoryUriScope); base.WriteVerbose(Strings.CasHealthWebAppStartTest(testUri)); IRequestAdapter requestAdapter = this.CreateRequestAdapter(virtualDirectoryUriScope); IExceptionAnalyzer exceptionAnalyzer = this.CreateExceptionAnalyzer(testUri); IResponseTracker responseTracker = this.CreateResponseTracker(); IHttpSession session = this.CreateHttpSession(requestAdapter, exceptionAnalyzer, responseTracker, instance); this.HookupEventHandlers(session); CasTransactionOutcome casTransactionOutcome = this.CreateOutcome(instance, testUri, responseTracker); string userName; string domain; SecureString secureString; this.GetUserParameters(instance, out userName, out domain, out secureString); ITestStep testStep = this.CreateScenario(instance, testUri, userName, domain, secureString, virtualDirectoryUriScope, instance.CasFqdn); testStep.BeginExecute(session, new AsyncCallback(this.ScenarioExecutionFinished), new object[] { testStep, instance, responseTracker, casTransactionOutcome, secureString }); } finally { TaskLogger.LogExit(); } return(null); }
private void ScenarioExecutionFinished(IAsyncResult result) { TaskLogger.LogEnter(); object[] array = result.AsyncState as object[]; ITestStep testStep = array[0] as ITestStep; TestCasConnectivity.TestCasConnectivityRunInstance testCasConnectivityRunInstance = array[1] as TestCasConnectivity.TestCasConnectivityRunInstance; IResponseTracker responseTracker = array[2] as IResponseTracker; CasTransactionOutcome casTransactionOutcome = array[3] as CasTransactionOutcome; SecureString secureString = array[4] as SecureString; try { testStep.EndExecute(result); this.CompleteSuccessfulOutcome(casTransactionOutcome, testCasConnectivityRunInstance, responseTracker); } catch (Exception ex) { testCasConnectivityRunInstance.Outcomes.Enqueue(TestWebApplicationConnectivity2.GenerateVerboseMessage(ex.ToString())); this.CompleteFailedOutcome(casTransactionOutcome, testCasConnectivityRunInstance, responseTracker, ex); } finally { TaskLogger.LogExit(); if (secureString != null) { secureString.Dispose(); } if (testCasConnectivityRunInstance != null) { testCasConnectivityRunInstance.Outcomes.Enqueue(casTransactionOutcome); testCasConnectivityRunInstance.Result.Complete(); } } }
private WebApplication GetWebApplication(TestCasConnectivity.TestCasConnectivityRunInstance instance) { CasTransactionOutcome casTransactionOutcome = base.CreateLogonOutcome(instance); WebApplication result = null; try { WebApplication webApplication = this.CreateWebApplication(instance); if (webApplication.ValidateLogin()) { casTransactionOutcome.Update(CasTransactionResultEnum.Success, LocalizedString.Empty); result = webApplication; } else { casTransactionOutcome.Update(CasTransactionResultEnum.Failure, Strings.CasHealthOwaNoLogonCookieReturned); } } catch (AuthenticationException ex) { casTransactionOutcome.Update(CasTransactionResultEnum.Failure, Strings.CasHealthWebAppNoSession(instance.CasFqdn, ex.LocalizedString, (ex.InnerException != null) ? ex.GetBaseException().Message : "")); } catch (WebException ex2) { casTransactionOutcome.Update(CasTransactionResultEnum.Failure, Strings.CasHealthWebAppNoSession(instance.CasFqdn, ex2.Message, (ex2.InnerException != null) ? ex2.GetBaseException().Message : "")); } instance.Outcomes.Enqueue(casTransactionOutcome); instance.Result.Outcomes.Add(casTransactionOutcome); return(result); }
protected string BuildVdirIdentityString(CasTransactionOutcome outcome) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Environment.NewLine); stringBuilder.Append(Strings.CasHealthOwaVdirColon(outcome.VirtualDirectoryName)); return(stringBuilder.ToString()); }
private void TestFailedUrlPropertyNotSet(CasTransactionOutcome outcome) { string text = (outcome.UrlType == VirtualDirectoryUriScope.Internal) ? Strings.CasHealthOwaNoInternalUrl : Strings.CasHealthOwaNoExternalUrl; if (base.MonitoringContext) { text += this.BuildVdirIdentityString(outcome); } base.SetTestOutcome(outcome, EventTypeEnumeration.Warning, text, null); }
private void TestFailedBadVdirConfig(CasTransactionOutcome outcome) { string text = Strings.CasHealthWebAppBadVdirConfig(this.ApplicationShortName); if (base.MonitoringContext) { text += this.BuildVdirIdentityString(outcome); } base.SetTestOutcome(outcome, EventTypeEnumeration.Warning, text, null); }
protected override void ExecuteTestConnectivity(TestCasConnectivity.TestCasConnectivityRunInstance instance) { int perConnectionTimeout = base.PerConnectionTimeout; CasTransactionOutcome casTransactionOutcome = new CasTransactionOutcome(base.CasFqdn, Strings.TestProtocolConnectivity("POP3"), Strings.ProtocolConnectivityScenario("POP3"), "POPConnectivity-Latency", base.LocalSiteName, false, instance.credentials.UserName); if (base.PortClientAccessServer == 0) { switch (base.ConnectionType) { case ProtocolConnectionType.Plaintext: case ProtocolConnectionType.Tls: base.PortClientAccessServer = 110; break; case ProtocolConnectionType.Ssl: base.PortClientAccessServer = 995; break; } } else { switch (base.ConnectionType) { case ProtocolConnectionType.Plaintext: case ProtocolConnectionType.Tls: if (110 != base.PortClientAccessServer) { instance.Outcomes.Enqueue(new Warning(Strings.PopImapTransactionWarning(base.PortClientAccessServer, base.ConnectionType.ToString(), 995, 110))); } break; case ProtocolConnectionType.Ssl: if (995 != base.PortClientAccessServer) { instance.Outcomes.Enqueue(new Warning(Strings.PopImapTransactionWarning(base.PortClientAccessServer, base.ConnectionType.ToString(), 995, 110))); } break; } } casTransactionOutcome.Port = base.PortClientAccessServer; casTransactionOutcome.ConnectionType = base.ConnectionType; instance.Port = base.PortClientAccessServer; instance.ConnectionType = base.ConnectionType; LocalizedString localizedString = Strings.ProtocolTransactionsDetails(base.CasFqdn, string.IsNullOrEmpty(base.MailboxFqdn) ? base.User.ServerName : base.MailboxFqdn, base.User.Database.Name, base.User.PrimarySmtpAddress.ToString(), base.PortClientAccessServer.ToString(CultureInfo.InvariantCulture), base.ConnectionType.ToString(), this.trustAllCertificates); instance.Outcomes.Enqueue(localizedString); this.transactionTarget = new PopTransaction(base.User, this.casToTest.Name, instance.credentials.Password, base.PortClientAccessServer); this.transactionTarget.ConnectionType = base.ConnectionType; this.transactionTarget.TrustAnySslCertificate = instance.trustAllCertificates; this.transactionTarget.MailSubject = base.MailSubject; this.transactionTarget.TransactionResult = casTransactionOutcome; this.transactionTarget.Instance = instance; this.transactionTarget.Execute(); }
private bool SetUpConnectivityTests(TestCasConnectivity.TestCasConnectivityRunInstance instance, out CasTransactionOutcome outcome) { MailboxSession mailboxSession = null; outcome = new CasTransactionOutcome(base.CasFqdn, Strings.ValidatingTestCasConnectivityRunInstance, Strings.ValidatingTestCasConnectivityRunInstance, this.MonitoringLatencyPerformanceCounter(), base.LocalSiteName, true, string.Empty); if (instance == null) { base.WriteMonitoringEvent(2020, this.CmdletMonitoringEventSource, EventTypeEnumeration.Error, base.ShortErrorMsgFromException(new ArgumentNullException("instance"))); outcome.Update(CasTransactionResultEnum.Failure); return(false); } this.userName = instance.credentials.UserName; if (!this.SetUpConnTestValidateAndMakeADUser(instance, out outcome)) { return(false); } if (!this.SetUpConnTestSetExchangePrincipal(instance, out outcome)) { return(false); } if (instance.credentials.Password == null) { base.WriteMonitoringEvent(2020, this.CmdletMonitoringEventSource, EventTypeEnumeration.Error, base.ShortErrorMsgFromException(new ArgumentNullException("password"))); outcome.Update(CasTransactionResultEnum.Failure); return(false); } if (instance.LightMode) { return(true); } try { if (!this.SetUpConnTestSetCreateMailboxSession(instance, out mailboxSession, out outcome)) { return(false); } if (!this.SetUpConnTestSendTestMessage(instance, mailboxSession, out outcome)) { return(false); } } finally { if (mailboxSession != null) { mailboxSession.Dispose(); mailboxSession = null; } } return(true); }
protected override List <CasTransactionOutcome> ExecuteTests(TestCasConnectivity.TestCasConnectivityRunInstance instance) { CasTransactionOutcome casTransactionOutcome = null; if (!this.SetUpConnectivityTests(instance, out casTransactionOutcome)) { instance.Outcomes.Enqueue(casTransactionOutcome); instance.Result.Outcomes.Add(casTransactionOutcome); instance.Result.Complete(); return(null); } this.ExecuteTestConnectivity(instance); return(null); }
internal override void CompleteFailedOutcome(CasTransactionOutcome outcome, TestCasConnectivity.TestCasConnectivityRunInstance instance, IResponseTracker responseTracker, Exception e) { TestEcpConnectivityOutcome testEcpConnectivityOutcome = outcome as TestEcpConnectivityOutcome; ScenarioException scenarioException = e.GetScenarioException(); if (scenarioException != null) { testEcpConnectivityOutcome.FailureSource = scenarioException.FailureSource.ToString(); testEcpConnectivityOutcome.FailureReason = scenarioException.FailureReason.ToString(); testEcpConnectivityOutcome.FailingComponent = scenarioException.FailingComponent.ToString(); } testEcpConnectivityOutcome.Update(CasTransactionResultEnum.Failure, (scenarioException != null) ? scenarioException.Message.ToString() : e.Message.ToString(), EventTypeEnumeration.Error); base.WriteMonitoringEvent(1001, this.MonitoringEventSource, EventTypeEnumeration.Error, Strings.CasHealthTransactionFailures((scenarioException != null) ? scenarioException.Message.ToString() : e.Message.ToString())); }
private void ExecuteWebServiceTest(TestCasConnectivity.TestCasConnectivityRunInstance instance, WebApplication webApplication) { StringBody stringBody = new StringBody("{\"filter\":{\"SearchText\":\"\"},\"sort\":{\"Direction\":0,\"PropertyName\":\"Name\"}}"); stringBody.ContentType = new System.Net.Mime.ContentType("application/json"); string text = "RulesEditor/InboxRules.svc/GetList"; string relativeUrl = "default.aspx"; CasTransactionOutcome casTransactionOutcome = this.BuildOutcome(Strings.CasHealthEcpScenarioTestWebService, Strings.CasHealthEcpTestWebService(new Uri(webApplication.BaseUri, text).ToString()), "ECP Web Sevice Logon Latency", instance); bool flag = false; string additionalInformation = ""; try { TextResponse textResponse = webApplication.Get <TextResponse>(relativeUrl); flag = (textResponse.StatusCode == HttpStatusCode.OK); additionalInformation = (flag ? "" : Strings.CasHealthEcpServiceRequestResult(textResponse.StatusCode.ToString())); base.WriteVerbose(Strings.CasHealthEcpServiceResponse(textResponse.Text)); if (flag) { textResponse = webApplication.Post <TextResponse>(text, stringBody); flag = (textResponse.StatusCode == HttpStatusCode.OK); additionalInformation = (flag ? "" : Strings.CasHealthEcpServiceRequestResult(textResponse.StatusCode.ToString())); base.WriteVerbose(Strings.CasHealthEcpServiceResponse(textResponse.Text)); } } catch (WebException ex) { string casServer = string.Empty; string fullResponse = string.Empty; if (ex.Response != null) { casServer = ex.Response.Headers["X-DiagInfo"]; try { fullResponse = this.GetResponseHtml(ex.Response); } catch (Exception ex2) { if (!(ex2 is ProtocolViolationException) && !(ex2 is IOException) && !(ex2 is NotSupportedException)) { throw; } } } additionalInformation = Strings.CasHealthEcpServiceRequestException(ex.Message, casServer, fullResponse); } casTransactionOutcome.Update(flag ? CasTransactionResultEnum.Success : CasTransactionResultEnum.Failure, additionalInformation); instance.Outcomes.Enqueue(casTransactionOutcome); instance.Result.Outcomes.Add(casTransactionOutcome); }
private bool SetUpConnTestSetExchangePrincipal(TestCasConnectivity.TestCasConnectivityRunInstance instance, out CasTransactionOutcome outcome) { outcome = null; if (instance.exchangePrincipal == null) { outcome = new CasTransactionOutcome(base.CasFqdn, Strings.CreateExchangePrincipalObject, Strings.CreateExchangePrincipalObject, this.MonitoringLatencyPerformanceCounter(), base.LocalSiteName, false, this.userName); LocalizedException ex = ProtocolConnectivity.SetExchangePrincipalInformation(instance, this.User); if (ex != null) { base.WriteMonitoringEvent(2021, this.CmdletMonitoringEventSource, EventTypeEnumeration.Error, base.ShortErrorMsgFromException(ex)); outcome.Update(CasTransactionResultEnum.Failure); return(false); } outcome.Update(CasTransactionResultEnum.Success); } return(true); }
private bool SetUpConnTestValidateAndMakeADUser(TestCasConnectivity.TestCasConnectivityRunInstance instance, out CasTransactionOutcome outcome) { outcome = new CasTransactionOutcome(base.CasFqdn, Strings.ValidatingUserObject, Strings.ValidatingUserObjectDescription, this.MonitoringLatencyPerformanceCounter(), base.LocalSiteName, false, this.userName); LocalizedException ex = ProtocolConnectivity.SetUserInformation(instance, this.recipientSession, ref this.user); if (ex != null) { base.WriteMonitoringEvent(2001, this.CmdletMonitoringEventSource, EventTypeEnumeration.Error, base.ShortErrorMsgFromException(ex)); outcome.Update(CasTransactionResultEnum.Failure); return(false); } if (this.user != null && !this.user.IsMailboxEnabled) { UserIsNotMailBoxEnabledException exception = new UserIsNotMailBoxEnabledException(instance.credentials.UserName); base.WriteMonitoringEvent(2003, this.CmdletMonitoringEventSource, EventTypeEnumeration.Error, base.ShortErrorMsgFromException(exception)); outcome.Update(CasTransactionResultEnum.Failure); return(false); } outcome.Update(CasTransactionResultEnum.Success); return(true); }
private bool ShouldTestVirtualDirectory(TestCasConnectivity.TestCasConnectivityRunInstance clientAccessServerInstance, List <CasTransactionOutcome> outcomeList, ExchangeVirtualDirectory virtualDirectory) { if (this.IsOrphanVdir(virtualDirectory)) { this.WriteWarning(Strings.CasHealthWebAppOrphanVirtualDirectory(this.ApplicationShortName, virtualDirectory.Name)); CasTransactionOutcome casTransactionOutcome = this.CreateVirtualDirectoryConfigErrorOutcome(clientAccessServerInstance, virtualDirectory); this.TestFailedBadVdirConfig(casTransactionOutcome); base.WriteObject(casTransactionOutcome); outcomeList.Add(casTransactionOutcome); return(false); } if ((this.UseInternalUrl && (virtualDirectory.InternalUrl == null || string.IsNullOrEmpty(virtualDirectory.InternalUrl.AbsoluteUri))) || (!this.UseInternalUrl && (virtualDirectory.ExternalUrl == null || string.IsNullOrEmpty(virtualDirectory.ExternalUrl.AbsoluteUri)))) { CasTransactionOutcome casTransactionOutcome2 = this.CreateVirtualDirectoryConfigErrorOutcome(clientAccessServerInstance, virtualDirectory); this.TestFailedUrlPropertyNotSet(casTransactionOutcome2); base.WriteObject(casTransactionOutcome2); outcomeList.Add(casTransactionOutcome2); return(false); } return(true); }
protected override List <CasTransactionOutcome> ExecuteTests(TestCasConnectivity.TestCasConnectivityRunInstance instance) { TaskLogger.LogEnter(); try { instance.baseUri = new UriBuilder(new Uri(instance.baseUri, "calendar/")) { Scheme = Uri.UriSchemeHttp, Port = 80 }.Uri; CasTransactionOutcome casTransactionOutcome = this.BuildOutcome(base.ApplicationShortName, base.ApplicationName, instance); casTransactionOutcome.Update(CasTransactionResultEnum.Success); this.ExecuteCalendarVDirTests(instance, casTransactionOutcome); instance.Result.Outcomes.Add(casTransactionOutcome); } finally { instance.Result.Complete(); TaskLogger.LogExit(); } return(null); }
private bool SetUpConnTestSendTestMessage(TestCasConnectivity.TestCasConnectivityRunInstance instance, MailboxSession mailboxSession, out CasTransactionOutcome outcome) { outcome = null; if (this.SendTestMessage) { outcome = this.BuildOutcome(Strings.DatabaseStatus, Strings.CheckDatabaseStatus(this.user.Database.Name), instance); bool flag = false; Exception ex = this.CheckDatabaseStatus(this.user.Database.Name, this.MailboxFqdn, ref flag); if (!flag) { if (ex == null) { goto IL_16C; } } try { outcome = this.BuildOutcome(Strings.SendMessage, Strings.SendMessage, instance); using (MessageItem messageItem = MessageItem.Create(mailboxSession, mailboxSession.GetDefaultFolderId(DefaultFolderType.Inbox))) { this.mailSubject = this.MailSubjectPrefix + Guid.NewGuid().ToString(); messageItem.Subject = this.MailSubject; using (TextWriter textWriter = messageItem.Body.OpenTextWriter(BodyFormat.TextPlain)) { textWriter.Write("Body of -"); textWriter.Write(this.MailSubject); } messageItem.IsReadReceiptRequested = false; messageItem.Save(SaveMode.NoConflictResolution); instance.Outcomes.Enqueue(Strings.TestMessageSent(this.MailSubject, this.user.PrimarySmtpAddress.ToString())); } return(true); } catch (LocalizedException exception) { base.WriteMonitoringEvent(2008, this.CmdletMonitoringEventSource, EventTypeEnumeration.Error, base.ShortErrorMsgFromException(exception)); outcome.Update(CasTransactionResultEnum.Failure); return(false); } IL_16C: if (ex != null) { outcome.Update(CasTransactionResultEnum.Failure, ex.Message); } else { outcome.Update(CasTransactionResultEnum.Failure); } return(false); } return(true); }
internal override void CompleteSuccessfulOutcome(CasTransactionOutcome outcome, TestCasConnectivity.TestCasConnectivityRunInstance instance, IResponseTracker responseTracker) { outcome.Update(CasTransactionResultEnum.Success); base.WriteMonitoringEvent(1000, this.MonitoringEventSource, EventTypeEnumeration.Success, Strings.CasHealthAllTransactionsSucceeded); }
internal ActiveSyncState(HttpWebRequest request, CasTransactionOutcome outcome) { this.request = request; this.outcome = outcome; }
internal abstract void CompleteFailedOutcome(CasTransactionOutcome outcome, TestCasConnectivity.TestCasConnectivityRunInstance instance, IResponseTracker responseTracker, Exception e);
internal abstract void CompleteSuccessfulOutcome(CasTransactionOutcome outcome, TestCasConnectivity.TestCasConnectivityRunInstance instance, IResponseTracker responseTracker);
private bool TestCalendarUrlResponse(string relativePath, TestCasConnectivity.TestCasConnectivityRunInstance instance, TestCalendarConnectivity.CalendarContext context, out TimeSpan latency) { bool flag = false; string text = string.Empty; Uri uri = new Uri(instance.baseUri, relativePath); latency = TimeSpan.Zero; for (int i = 0; i < 3; i++) { if (i > 0) { Thread.Sleep(20000); } HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri); httpWebRequest.Method = "GET"; httpWebRequest.Accept = "*/*"; httpWebRequest.Credentials = null; httpWebRequest.AllowAutoRedirect = true; httpWebRequest.UserAgent = context.UserAgent; httpWebRequest.Timeout = 30000; base.WriteVerbose(Strings.CasHealthWebAppSendingRequest(uri)); ExDateTime now = ExDateTime.Now; try { string text2 = string.Empty; HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream())) { text2 = streamReader.ReadToEnd(); } base.WriteVerbose(Strings.CasHealthWebAppResponseReceived(uri, httpWebResponse.StatusCode, string.Empty, text2)); if (httpWebResponse.StatusCode != HttpStatusCode.OK) { text = Strings.CasHealthCalendarResponseError(httpWebResponse.StatusCode.ToString()); } else if (string.IsNullOrEmpty(text2) || !text2.Contains(context.CheckText)) { text = Strings.CasHealthCalendarResponseError(text2); } else { text = string.Empty; flag = true; } } catch (WebException ex) { base.WriteVerbose(Strings.CasHealthWebAppRequestException(uri, ex.Status, string.Empty, ex.Message)); text = Strings.CasHealthCalendarWebRequestException(ex.Message); } latency = base.ComputeLatency(now); if (flag) { break; } } CasTransactionOutcome casTransactionOutcome = this.BuildOutcome(context.ScenarioName, context.ScenarioDescription, instance); casTransactionOutcome.Update(flag ? CasTransactionResultEnum.Success : CasTransactionResultEnum.Failure, latency, text); instance.Outcomes.Enqueue(casTransactionOutcome); if (!flag) { base.WriteMonitoringEvent(context.EventIdError, this.MonitoringEventSource, EventTypeEnumeration.Error, Strings.CasHealthCalendarCheckError(context.ScenarioDescription, text)); } else { base.WriteMonitoringEvent(context.EventIdSuccess, this.MonitoringEventSource, EventTypeEnumeration.Success, Strings.CasHealthCalendarCheckSuccess(context.ScenarioDescription)); } return(flag); }
private void ExecuteCalendarVDirTests(TestCasConnectivity.TestCasConnectivityRunInstance instance, CasTransactionOutcome outcome) { string text = string.Format("{0}/Calendar/calendar.html", instance.exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString()); string text2 = string.Format("{0}/Calendar/calendar.ics", instance.exchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString()); ADSessionSettings adsessionSettings = instance.exchangePrincipal.MailboxInfo.OrganizationId.ToADSessionSettings(); IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, true, ConsistencyMode.IgnoreInvalid, null, adsessionSettings, 293, "ExecuteCalendarVDirTests", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Monitoring\\Tasks\\TestCalendarConnectivity.cs"); using (MailboxCalendarFolderDataProvider mailboxCalendarFolderDataProvider = new MailboxCalendarFolderDataProvider(adsessionSettings, DirectoryHelper.ReadADRecipient(instance.exchangePrincipal.MailboxInfo.MailboxGuid, instance.exchangePrincipal.MailboxInfo.IsArchive, tenantOrRootOrgRecipientSession) as ADUser, "Test-CalendarConnectivity")) { StoreObjectId defaultFolderId = mailboxCalendarFolderDataProvider.MailboxSession.GetDefaultFolderId(DefaultFolderType.Calendar); Microsoft.Exchange.Data.Storage.Management.MailboxFolderId identity = new Microsoft.Exchange.Data.Storage.Management.MailboxFolderId(instance.exchangePrincipal.ObjectId, defaultFolderId, null); MailboxCalendarFolder mailboxCalendarFolder = (MailboxCalendarFolder)mailboxCalendarFolderDataProvider.Read <MailboxCalendarFolder>(identity); if (!mailboxCalendarFolder.PublishEnabled) { mailboxCalendarFolder.SearchableUrlEnabled = true; mailboxCalendarFolder.PublishEnabled = true; mailboxCalendarFolder.PublishedCalendarUrl = new Uri(instance.baseUri, text).ToString(); mailboxCalendarFolder.PublishedICalUrl = new Uri(instance.baseUri, text2).ToString(); try { mailboxCalendarFolderDataProvider.Save(mailboxCalendarFolder); } catch (NotAllowedPublishingByPolicyException ex) { instance.Outcomes.Enqueue(new Warning(ex.LocalizedString)); return; } } } ADOwaVirtualDirectory adowaVirtualDirectory = instance.VirtualDirectory as ADOwaVirtualDirectory; if (adowaVirtualDirectory != null && !(adowaVirtualDirectory.AnonymousFeaturesEnabled != true)) { base.WriteMonitoringEvent(1104, this.MonitoringEventSource, EventTypeEnumeration.Success, Strings.CasHealthCalendarVDirSuccess); TimeSpan latency; if (!this.TestCalendarUrlResponse(text2, instance, TestCalendarConnectivity.CalendarContext.ICalContext, out latency)) { outcome.Update(CasTransactionResultEnum.Failure); } else { outcome.UpdateLatency(latency); } if (!this.TestCalendarUrlResponse(text, instance, TestCalendarConnectivity.CalendarContext.ViewCalendarContext, out latency)) { outcome.Update(CasTransactionResultEnum.Failure); } return; } instance.Outcomes.Enqueue(new Warning(Strings.CasHealthCalendarVDirWarning(instance.VirtualDirectoryName, instance.CasFqdn))); outcome.Update(CasTransactionResultEnum.Skipped); base.WriteMonitoringEvent(1105, this.MonitoringEventSource, EventTypeEnumeration.Warning, Strings.CasHealthCalendarVDirWarning(instance.VirtualDirectoryName, instance.CasFqdn)); }
protected override List <CasTransactionOutcome> ExecuteTests(TestCasConnectivity.TestCasConnectivityRunInstance instance) { ExDateTime now = ExDateTime.Now; TaskLogger.LogEnter(); base.WriteVerbose(Strings.CasHealthScenarioLogon); if (base.TestType == OwaConnectivityTestType.External && !this.ValidateExternalTest(instance)) { instance.Result.Complete(); return(null); } LocalizedString localizedString = LocalizedString.Empty; Uri uri; if (base.Fields.IsModified("ConnectionUri")) { uri = this.ConnectionUri; localizedString = Strings.CasHealthPowerShellConnectionUri(uri.ToString(), "user supplied Uri"); } else if (base.TestType == OwaConnectivityTestType.External) { uri = instance.VirtualDirectory.ExternalUrl; localizedString = Strings.CasHealthPowerShellConnectionUri(uri.ToString(), "Virtual Directory External Uri"); } else { uri = instance.VirtualDirectory.InternalUrl; localizedString = Strings.CasHealthPowerShellConnectionUri(uri.ToString(), "Virtual Directory Internal Uri"); } base.TraceInfo(localizedString); base.WriteVerbose(localizedString); ADPowerShellVirtualDirectory adpowerShellVirtualDirectory = instance.VirtualDirectory as ADPowerShellVirtualDirectory; if (adpowerShellVirtualDirectory != null) { base.TraceInfo(Strings.CasHealthPowerShellConnectionVirtualDirectory(adpowerShellVirtualDirectory.Name)); base.WriteVerbose(Strings.CasHealthPowerShellConnectionVirtualDirectory(adpowerShellVirtualDirectory.Name)); } if (uri == null) { CasTransactionOutcome casTransactionOutcome = this.BuildOutcome(Strings.CasHealthOwaLogonScenarioName, null, instance); base.TraceInfo("No External or Internal Url found for testing"); casTransactionOutcome.Update(CasTransactionResultEnum.Failure, (base.TestType == OwaConnectivityTestType.External) ? Strings.CasHealthOwaNoExternalUrl : Strings.CasHealthOwaNoInternalUrl); instance.Outcomes.Enqueue(casTransactionOutcome); instance.Result.Outcomes.Add(casTransactionOutcome); base.WriteErrorAndMonitoringEvent(new LocalizedException((base.TestType == OwaConnectivityTestType.External) ? Strings.CasHealthOwaNoExternalUrl : Strings.CasHealthOwaNoInternalUrl), (ErrorCategory)1001, null, 1010, (base.TestType == OwaConnectivityTestType.External) ? "MSExchange Monitoring PowerShellConnectivity External" : "MSExchange Monitoring PowerShellConnectivity Internal", false); base.WriteObject(casTransactionOutcome); } else { CasTransactionOutcome casTransactionOutcome2 = this.BuildOutcome(Strings.CasHealthScenarioLogon, Strings.CasHealthPowerShellRemoteConnectionScenario(uri.ToString(), this.Authentication.ToString()), instance); PSCredential credential; if (base.ParameterSetName == "URL") { credential = this.TestCredential; localizedString = Strings.CasHealthPowerShellConnectionUserCredential(this.TestCredential.UserName, "user supplied"); } else { credential = new PSCredential(instance.credentials.UserName, instance.credentials.Password.ConvertToSecureString()); localizedString = Strings.CasHealthPowerShellConnectionUserCredential(instance.credentials.UserName, "default for test user"); } base.TraceInfo(localizedString); base.WriteVerbose(localizedString); WSManConnectionInfo wsmanConnectionInfo; if (base.TestType == OwaConnectivityTestType.External) { wsmanConnectionInfo = new WSManConnectionInfo(uri, "http://schemas.microsoft.com/powershell/Microsoft.Exchange", this.certThumbprint); } else { wsmanConnectionInfo = new WSManConnectionInfo(uri, "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential); } if (base.Fields.IsModified("Authentication")) { wsmanConnectionInfo.AuthenticationMechanism = this.Authentication; } else if (adpowerShellVirtualDirectory != null && adpowerShellVirtualDirectory.LiveIdBasicAuthentication != null && adpowerShellVirtualDirectory.LiveIdBasicAuthentication.Value) { wsmanConnectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic; } base.TraceInfo(Strings.CasHealthPowerShellConnectionAuthenticationType(wsmanConnectionInfo.AuthenticationMechanism.ToString())); base.WriteVerbose(Strings.CasHealthPowerShellConnectionAuthenticationType(wsmanConnectionInfo.AuthenticationMechanism.ToString())); if (base.TrustAnySSLCertificate) { wsmanConnectionInfo.SkipCACheck = true; wsmanConnectionInfo.SkipCNCheck = true; wsmanConnectionInfo.SkipRevocationCheck = true; } using (Runspace runspace = RunspaceFactory.CreateRunspace(TestRemotePowerShellConnectivity.psHost, wsmanConnectionInfo)) { try { runspace.Open(); base.WriteVerbose(Strings.CasHealtRemotePowerShellOpenRunspaceSucceeded); base.TraceInfo(Strings.CasHealtRemotePowerShellOpenRunspaceSucceeded); runspace.Close(); base.TraceInfo(Strings.CasHealtRemotePowerShellCloseRunspaceSucceeded); base.WriteVerbose(Strings.CasHealtRemotePowerShellCloseRunspaceSucceeded); casTransactionOutcome2.Update(CasTransactionResultEnum.Success, base.ComputeLatency(now), null); } catch (Exception ex) { casTransactionOutcome2.Update(CasTransactionResultEnum.Failure, base.ComputeLatency(now), ex.Message); instance.Outcomes.Enqueue(casTransactionOutcome2); instance.Result.Outcomes.Add(casTransactionOutcome2); try { string hostName = Dns.GetHostName(); if (adpowerShellVirtualDirectory != null && string.Compare(this.casToTest.Fqdn, Dns.GetHostEntry(hostName).HostName, true) == 0) { this.CheckRequiredServicesAndAppPool(adpowerShellVirtualDirectory); } } catch (Exception) { } base.WriteErrorAndMonitoringEvent(new LocalizedException(Strings.CasHealthPowerShellLogonFailed((adpowerShellVirtualDirectory != null) ? adpowerShellVirtualDirectory.Name : this.ConnectionUri.ToString(), ex.Message)), (ErrorCategory)1001, null, 1001, (base.TestType == OwaConnectivityTestType.External) ? "MSExchange Monitoring PowerShellConnectivity External" : "MSExchange Monitoring PowerShellConnectivity Internal", false); } finally { base.WriteObject(casTransactionOutcome2); } } instance.Result.Complete(); } return(null); }
private bool SetUpConnTestSetCreateMailboxSession(TestCasConnectivity.TestCasConnectivityRunInstance instance, out MailboxSession mailboxSession, out CasTransactionOutcome outcome) { this.mailboxFqdn = instance.exchangePrincipal.MailboxInfo.Location.ServerFqdn; string text = string.Empty; mailboxSession = null; outcome = null; try { outcome = this.BuildOutcome(Strings.CreateMailboxSession, Strings.CreateMailboxSessionDetail(this.User.PrimarySmtpAddress.ToString()), instance); mailboxSession = MailboxSession.OpenAsAdmin(instance.exchangePrincipal, CultureInfo.InvariantCulture, "Client=Monitoring;Action=System Management"); } catch (StorageTransientException exception) { text = ProtocolConnectivity.ShortErrorMessageFromException(exception); new MailboxCreationException(this.User.PrimarySmtpAddress.ToString(), text); outcome.Update(CasTransactionResultEnum.Failure, Strings.ErrorMailboxCreationFailure(this.User.PrimarySmtpAddress.ToString(), text)); return(false); } catch (StoragePermanentException exception2) { text = ProtocolConnectivity.ShortErrorMessageFromException(exception2); new MailboxCreationException(this.User.PrimarySmtpAddress.ToString(), text); outcome.Update(CasTransactionResultEnum.Failure, Strings.ErrorMailboxCreationFailure(this.User.PrimarySmtpAddress.ToString(), text)); return(false); } catch (ArgumentException exception3) { text = ProtocolConnectivity.ShortErrorMessageFromException(exception3); LocalizedException exception4 = new LocalizedException(new LocalizedString(text)); base.WriteMonitoringEvent(2013, this.CmdletMonitoringEventSource, EventTypeEnumeration.Error, base.ShortErrorMsgFromException(exception4)); outcome.Update(CasTransactionResultEnum.Failure); return(false); } outcome.Update(CasTransactionResultEnum.Success); return(true); }