예제 #1
0
        private ActiveDirectoryConnectivityOutcome RunSearchOperationWithTimeCheck(Func <int> operation)
        {
            ActiveDirectoryConnectivityOutcome activeDirectoryConnectivityOutcome = base.CreateOutcome(TestActiveDirectoryConnectivityTask.ScenarioId.Search, Strings.ActiveDirectorySearchScenario, Strings.ActiveDirectorySearchScenario, base.Context.CurrentDomainController);

            if (!base.CanContinue)
            {
                base.WriteVerbose(Strings.CannotContinue(Strings.ActiveDirectorySearchScenario));
                activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Skipped);
                return(activeDirectoryConnectivityOutcome);
            }
            try
            {
                operation();
                activeDirectoryConnectivityOutcome.UpdateTarget(base.Context.CurrentDomainController);
                TimeSpan timeSpan = ExDateTime.Now - activeDirectoryConnectivityOutcome.StartTime;
                if (timeSpan.TotalMilliseconds > (double)base.Context.Instance.SearchLatencyThresholdInMilliseconds)
                {
                    activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Success, string.Format("Over Threshold. Threshold :{0} Actual {1}", base.Context.Instance.SearchLatencyThresholdInMilliseconds, timeSpan.TotalMilliseconds));
                    base.Context.Instance.WriteVerbose(string.Format("Over Threshold. Threshold :{0} Actual {1}", base.Context.Instance.SearchLatencyThresholdInMilliseconds, timeSpan.TotalMilliseconds));
                    base.AddMonitoringEvent(TestActiveDirectoryConnectivityTask.ScenarioId.SearchOverLatency, EventTypeEnumeration.Error, base.GenerateErrorMessage(TestActiveDirectoryConnectivityTask.ScenarioId.SearchLatency, 0, string.Format("Over Threshold. Threshold :{0} Actual {1}", base.Context.Instance.SearchLatencyThresholdInMilliseconds, timeSpan.TotalMilliseconds), null));
                }
                else
                {
                    base.AddMonitoringEvent(TestActiveDirectoryConnectivityTask.ScenarioId.SearchLatency, EventTypeEnumeration.Success, base.GenerateErrorMessage(TestActiveDirectoryConnectivityTask.ScenarioId.SearchLatency, 0, string.Empty, null));
                    activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Success);
                }
            }
            catch (Exception ex)
            {
                ActiveDirectorySearchError errorCode;
                if (ex is ADTransientException)
                {
                    errorCode = ActiveDirectorySearchError.ADTransientException;
                }
                else
                {
                    errorCode = ActiveDirectorySearchError.OtherException;
                }
                TimeSpan timeSpan = ExDateTime.Now - activeDirectoryConnectivityOutcome.StartTime;
                activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Failure);
                base.AddMonitoringEvent(TestActiveDirectoryConnectivityTask.ScenarioId.SearchFailed, EventTypeEnumeration.Error, base.GenerateErrorMessage(TestActiveDirectoryConnectivityTask.ScenarioId.Search, (int)errorCode, ex.ToString(), null));
            }
            return(activeDirectoryConnectivityOutcome);
        }
예제 #2
0
        private ActiveDirectoryConnectivityOutcome IsNetlogonRunning()
        {
            ActiveDirectoryConnectivityOutcome activeDirectoryConnectivityOutcome = base.CreateOutcome(TestActiveDirectoryConnectivityTask.ScenarioId.IsNetlogonRunning, Strings.IsNetlogonRunningScenario, Strings.IsNetlogonRunningScenario, base.Context.CurrentDomainController);

            if (!base.CanContinue)
            {
                base.WriteVerbose(Strings.CannotContinue(Strings.IsNetlogonRunningScenario));
                activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Skipped);
                return(activeDirectoryConnectivityOutcome);
            }
            return(this.IsServiceRunning("Netlogon", activeDirectoryConnectivityOutcome, TestActiveDirectoryConnectivityTask.ScenarioId.NetLogonNotRunning));
        }
예제 #3
0
        private ActiveDirectoryConnectivityOutcome MachinePing()
        {
            ActiveDirectoryConnectivityOutcome activeDirectoryConnectivityOutcome = base.CreateOutcome(TestActiveDirectoryConnectivityTask.ScenarioId.MachinePing, Strings.MachinePingScenario, Strings.MachinePingScenario, base.Context.CurrentDomainController);

            if (!base.CanContinue)
            {
                base.WriteVerbose(Strings.CannotContinue(Strings.MachinePingScenario));
                activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Skipped);
                return(activeDirectoryConnectivityOutcome);
            }
            try
            {
                Dns.GetHostEntry(base.Context.CurrentDomainController);
                activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Success);
            }
            catch (SocketException ex)
            {
                base.Context.Instance.SkipRemainingTests = true;
                activeDirectoryConnectivityOutcome.Update(CasTransactionResultEnum.Failure);
                base.AddMonitoringEvent(TestActiveDirectoryConnectivityTask.ScenarioId.MachinePingFailed, EventTypeEnumeration.Error, base.GenerateErrorMessage(TestActiveDirectoryConnectivityTask.ScenarioId.MachinePing, 0, ex.Message, null));
            }
            return(activeDirectoryConnectivityOutcome);
        }
예제 #4
0
 private ActiveDirectoryConnectivityOutcome IsServiceRunning(string serviceName, ActiveDirectoryConnectivityOutcome outcome, TestActiveDirectoryConnectivityTask.ScenarioId failureId)
 {
     try
     {
         using (ServiceController serviceController = new ServiceController(serviceName, base.Context.CurrentDomainController))
         {
             if (serviceController.Status != ServiceControllerStatus.Running)
             {
                 outcome.Update(CasTransactionResultEnum.Failure, TimeSpan.Zero, Strings.ServiceNotRunning(serviceName));
                 base.AddMonitoringEvent(failureId, EventTypeEnumeration.Error, base.GenerateErrorMessage(outcome.Id, 0, Strings.ServiceNotRunning(serviceName), null));
                 return(outcome);
             }
         }
     }
     catch (InvalidOperationException ex)
     {
         outcome.Update(CasTransactionResultEnum.Failure, TimeSpan.Zero, ex.ToString());
         base.AddMonitoringEvent(failureId, EventTypeEnumeration.Error, base.GenerateErrorMessage(outcome.Id, 0, ex.ToString(), null));
         return(outcome);
     }
     outcome.Update(CasTransactionResultEnum.Success);
     return(outcome);
 }