protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         if (this.RunFromServerId == null)
         {
             this.RunFromServerId = new ServerIdParameter(new Fqdn(ComputerInformation.DnsPhysicalFullyQualifiedDomainName));
         }
         this.server = (Server)base.GetDataObject <Server>(this.RunFromServerId, base.DataSession, this.RootId, new LocalizedString?(Strings.ErrorServerNotFound(this.RunFromServerId.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(this.RunFromServerId.ToString())));
         this.WriteInfo(Strings.RunFromServer(this.RunFromServerId.ToString()));
         if (this.MailboxId != null)
         {
             this.mailboxAdUser = (ADUser)base.GetDataObject <ADUser>(this.MailboxId, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.MailboxId.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.MailboxId.ToString())));
         }
         this.WriteInfo((this.mailboxAdUser == null) ? Strings.UsingTargetMonitoringMailbox : Strings.UsingTargetMailbox(this.mailboxAdUser.PrimarySmtpAddress.ToString()));
         if (!TestOutlookConnectivity.IsMailboxCredentialEmpty(this.Credential))
         {
             if (this.MailboxId == null)
             {
                 base.WriteError(new ArgumentException(Strings.MissingMailboxId(this.Credential.UserName)), (ErrorCategory)1000, null);
             }
             this.authenticateAsUser = (ADUser)base.GetDataObject <ADUser>(new RecipientIdParameter(this.Credential.UserName), base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.OutlookConnectivityErrorUserNotFound(this.Credential.UserName.ToString())), new LocalizedString?(Strings.OutlookConnectivityErrorUserNotUnique(this.Credential.UserName.ToString())));
         }
         this.WriteInfo((this.Credential != null) ? Strings.UsingAuthenticationCredentials(this.Credential.UserName) : Strings.UsingMonitoringMailboxAuthenticationCredentials);
         string        probeIdentity  = this.ProbeIdentity;
         ProbeIdentity probeIdentity2 = null;
         try
         {
             probeIdentity2 = OutlookConnectivity.ResolveIdentity(probeIdentity, TestOutlookConnectivity.IsDcOrDedicated);
         }
         catch (ArgumentException exception)
         {
             base.WriteError(exception, (ErrorCategory)1000, null);
         }
         this.ProbeIdentity = probeIdentity2.GetIdentity(true);
         this.WriteInfo(Strings.UsingProbeIdentity(this.ProbeIdentity));
         if (!TestOutlookConnectivity.IsMailboxCredentialEmpty(this.Credential) && !this.IsProbePasswordAuthenticated)
         {
             this.WriteWarning(Strings.IgnoredAuthenticationWarning);
         }
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
        private Dictionary <string, string> CreatePropertyBag()
        {
            Dictionary <string, string> dictionary = null;

            try
            {
                dictionary = TestOutlookConnectivity.CreateTestOutlookConnectivityPropertyBag(this.mailboxAdUser, this.IsProbePasswordAuthenticated, this.IsCtpTest, this.Credential, this.authenticateAsUser, this.Hostname);
                TestOutlookConnectivity.AddToPropertyBag(dictionary, "TimeoutSeconds", this.TimeOutSeconds);
                TestOutlookConnectivity.AddToPropertyBag(dictionary, "ServiceName", MonitoringItemIdentity.MonitorIdentityId.GetHealthSet(this.ProbeIdentity));
                TestOutlookConnectivity.AddToPropertyBag(dictionary, "Name", MonitoringItemIdentity.MonitorIdentityId.GetMonitor(this.ProbeIdentity));
                TestOutlookConnectivity.AddToPropertyBag(dictionary, "TargetResource", MonitoringItemIdentity.MonitorIdentityId.GetTargetResource(this.ProbeIdentity));
            }
            catch (ArgumentException exception)
            {
                base.WriteError(exception, (ErrorCategory)1000, null);
            }
            return(dictionary);
        }
        internal static Dictionary <string, string> CreateTestOutlookConnectivityPropertyBag(ADUser mailboxAdUser, bool isPasswordAuthenticated, bool isCtpTest, PSCredential mailboxCredential, ADUser adUserCorrespondingToMailboxCredential, string endpoint)
        {
            Dictionary <string, string>    dictionary  = new Dictionary <string, string>();
            Dictionary <string, string>    dictionary2 = new Dictionary <string, string>(0);
            AutodiscoverCommonUserSettings autodiscoverCommonUserSettings = null;

            if (mailboxAdUser != null)
            {
                TestOutlookConnectivity.AddToPropertyBag(dictionary2, "MailboxLegacyDN", mailboxAdUser.LegacyExchangeDN);
                autodiscoverCommonUserSettings = AutodiscoverCommonUserSettings.GetSettingsFromRecipient(mailboxAdUser, mailboxAdUser.PrimarySmtpAddress.ToString());
                TestOutlookConnectivity.AddToPropertyBag(dictionary2, "PersonalizedServerName", string.Format("{0}@{1}", autodiscoverCommonUserSettings.MailboxGuid, autodiscoverCommonUserSettings.PrimarySmtpAddress.Domain));
                if (!TestOutlookConnectivity.IsMailboxCredentialEmpty(mailboxCredential))
                {
                    if (adUserCorrespondingToMailboxCredential == null)
                    {
                        throw new ArgumentException("This should never happen.  If mailboxCredential is passed in, then adUserCorrespondingToMailboxCredential should match.");
                    }
                    TestOutlookConnectivity.AddToPropertyBag(dictionary, "Account", TestOutlookConnectivity.GetAccountLoginName(adUserCorrespondingToMailboxCredential));
                    TestOutlookConnectivity.AddToPropertyBag(dictionary2, "AccountLegacyDN", adUserCorrespondingToMailboxCredential.LegacyExchangeDN);
                    if (isPasswordAuthenticated)
                    {
                        string value = TestOutlookConnectivity.ConvertSecureStringToPlainString(mailboxCredential.Password);
                        TestOutlookConnectivity.AddToPropertyBag(dictionary, "Password", value);
                    }
                }
            }
            TestOutlookConnectivity.AddToPropertyBag(dictionary, "Endpoint", endpoint);
            if (!isCtpTest)
            {
                TestOutlookConnectivity.AddToPropertyBag(dictionary, "SecondaryEndpoint", endpoint);
            }
            if (autodiscoverCommonUserSettings != null && !string.IsNullOrEmpty(autodiscoverCommonUserSettings.RpcServer) && isCtpTest)
            {
                TestOutlookConnectivity.AddToPropertyBag(dictionary, "SecondaryEndpoint", autodiscoverCommonUserSettings.RpcServer);
            }
            TestOutlookConnectivity.AddToPropertyBag(dictionary, "ItemTargetExtension", WorkDefinition.SerializeExtensionAttributes(dictionary2));
            return(dictionary);
        }