Exemple #1
0
 public ExchangeDynamicServerSnapIn()
 {
     PSConnectionInfoSingleton.GetInstance().RemotePSServerChanged += delegate(object param0, EventArgs param1)
     {
         this.UpdateRemotePSServerSettings();
     };
 }
 private MonadConnectionInfo DiscoverOrganizationConnectionInfo()
 {
     if (!WinformsHelper.IsRemoteEnabled())
     {
         return(null);
     }
     if (this.Type == OrganizationType.RemoteOnPremise || this.Type == OrganizationType.Cloud)
     {
         this.ReportConnectToSpecifiedServerProgress(0);
         return(this.DiscoverConnectionInfo());
     }
     if (this.Uri != null)
     {
         try
         {
             this.ReportConnectToSpecifiedServerProgress(0);
             return(this.DiscoverConnectionInfo());
         }
         catch (PSRemotingDataStructureException)
         {
         }
         catch (PSRemotingTransportException)
         {
         }
     }
     this.ReportDiscoverServerProgress(15);
     this.Uri = PSConnectionInfoSingleton.GetRemotePowerShellUri(PSConnectionInfoSingleton.DiscoverExchangeServer());
     this.ReportConnectToServerProgress(40);
     return(this.DiscoverConnectionInfo());
 }
 private Fqdn GetAutoDiscoveredServer()
 {
     if (string.IsNullOrEmpty(this.autoDiscoveredServer))
     {
         this.autoDiscoveredServer = PSConnectionInfoSingleton.DiscoverExchangeServer();
     }
     return(this.autoDiscoveredServer);
 }
 private static Uri ExtractValidUri(MonadConnectionInfo connectionInfo)
 {
     if (connectionInfo.ServerUri.ToString().StartsWith(PSConnectionInfoSingleton.GetExchangeOnlineUri().ToString()))
     {
         return(PSConnectionInfoSingleton.GetExchangeOnlineUri());
     }
     return(new Uri(connectionInfo.ServerUri.GetLeftPart(UriPartial.Path)));
 }
Exemple #5
0
 public override void Initialize(IProgressProvider progressProvider)
 {
     PSConnectionInfoSingleton.GetInstance().DisplayName = this.RootNodeDisplayName;
     PSConnectionInfoSingleton.GetInstance().Type        = OrganizationType.ToolOrEdge;
     PSConnectionInfoSingleton.GetInstance().Uri         = PSConnectionInfoSingleton.GetRemotePowerShellUri(this.Settings.RemotePSServer);
     PSConnectionInfoSingleton.GetInstance().LogonWithDefaultCredential = true;
     PSConnectionInfoSingleton.GetInstance().Enabled = true;
     base.Initialize(progressProvider);
 }
        public MonadConnectionInfo GetMonadConnectionInfo(ExchangeRunspaceConfigurationSettings.SerializationLevel serializationLevel)
        {
            MonadConnectionInfo monadConnectionInfo = this.GenerateMonadConnectionInfo();

            if (serializationLevel != ExchangeRunspaceConfigurationSettings.SerializationLevel.Full && monadConnectionInfo != null)
            {
                monadConnectionInfo = new MonadConnectionInfo(PSConnectionInfoSingleton.ExtractValidUri(monadConnectionInfo), monadConnectionInfo.Credentials, monadConnectionInfo.ShellUri, monadConnectionInfo.FileTypesXml, monadConnectionInfo.AuthenticationMechanism, serializationLevel, monadConnectionInfo.ClientApplication, monadConnectionInfo.ClientVersion, monadConnectionInfo.MaximumConnectionRedirectionCount, monadConnectionInfo.SkipServerCertificateCheck);
            }
            return(monadConnectionInfo);
        }
Exemple #7
0
        private void UpdateRemotePSServerSettings()
        {
            bool cancelAutoRefresh = true;

            try
            {
                this.Settings.DoBeginInit();
                this.Settings.RemotePSServer = PSConnectionInfoSingleton.GetInstance().RemotePSServer;
                cancelAutoRefresh            = false;
            }
            finally
            {
                this.Settings.DoEndInit(cancelAutoRefresh);
            }
        }
 public RunspaceServerSettingsPresentationObject CreateRunspaceServerSettingsObject()
 {
     if (EnvironmentAnalyzer.IsWorkGroup() || OrganizationType.Cloud == PSConnectionInfoSingleton.GetInstance().Type || this.ADServerSettings == null)
     {
         return(null);
     }
     if (this.ADServerSettings != null)
     {
         lock (this.syncRoot)
         {
             return(this.ADServerSettings.Clone() as RunspaceServerSettingsPresentationObject);
         }
     }
     return(null);
 }
Exemple #9
0
 protected override void OnDoRefreshWork(RefreshRequestEventArgs e)
 {
     this.progress = new RefreshRequestEventArgsToIProgressAdapter(e);
     try
     {
         this.ResetStatus();
         PSConnectionInfoSingleton.GetInstance().ReportProgress = this.progress;
         PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo();
         this.progress.ReportProgress(50, 100, Strings.ProgressReportInitializeHelpService, Strings.ProgressReportInitializeHelpServiceErrorText);
         ExchangeHelpService.Initialize();
         this.erc          = CmdletBasedRunspaceConfiguration.Create(PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo(), PSConnectionInfoSingleton.GetInstance().UserAccount, this.progress);
         this.TenantDomain = ((this.erc.LogonUserLiveID == SmtpAddress.Empty) ? null : this.erc.LogonUserLiveID.Domain);
     }
     finally
     {
         this.progress.ReportProgress(100, 100, Strings.ProgressReportEnd, string.Empty);
         PSConnectionInfoSingleton.GetInstance().ReportProgress = null;
     }
     base.OnDoRefreshWork(e);
 }
        public void UpdateRemotePSServer(Fqdn server)
        {
            if (this.Type != OrganizationType.LocalOnPremise && this.Type != OrganizationType.ToolOrEdge)
            {
                throw new NotSupportedException();
            }
            Uri  uri = this.Uri;
            Uri  remotePowerShellUri = PSConnectionInfoSingleton.GetRemotePowerShellUri(server);
            bool flag = true;

            try
            {
                this.Uri = remotePowerShellUri;
                this.DefaultConnectionInfo = this.DiscoverOrganizationConnectionInfo();
                flag = false;
            }
            finally
            {
                if (flag)
                {
                    this.Uri = uri;
                }
            }
        }
Exemple #11
0
 public static void Initialize()
 {
     Microsoft.Exchange.CommonHelpProvider.HelpProvider.InitializeViaCmdlet(Microsoft.Exchange.CommonHelpProvider.HelpProvider.HelpAppName.Toolbox, null, PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo());
 }
 public ExchangeSnapIn()
 {
     this.helper = new ExchangeSnapInHelper(this, this);
     this.helper.InitializeSettingProvider();
     PSConnectionInfoSingleton.GetInstance().Enabled = true;
 }
        private MonadConnectionInfo DiscoverForestConnectionInfo(IUIService uiService, OrganizationSetting forestInfo)
        {
            SupportedVersionList supportedVersionList = null;

            switch (forestInfo.Type)
            {
            case OrganizationType.LocalOnPremise:
                return(new ConnectionRetryDiscoverer(uiService, OrganizationType.LocalOnPremise, Strings.MicrosoftExchangeOnPremise, PSConnectionInfoSingleton.GetRemotePowerShellUri(this.GetAutoDiscoveredServer()), true).DiscoverConnectionInfo(out supportedVersionList, string.Empty));

            case OrganizationType.RemoteOnPremise:
            case OrganizationType.Cloud:
                return(new ConnectionRetryDiscoverer(forestInfo, uiService).DiscoverConnectionInfo(out supportedVersionList, string.Empty));

            default:
                return(null);
            }
        }
 public ConnectionRetryDiscoverer(PSConnectionInfoSingleton connInfoSingleton) : this((connInfoSingleton.UISyncContext == null) ? null : new SyncContextUIInteractionHandler(connInfoSingleton.UISyncContext), connInfoSingleton.Type, connInfoSingleton.DisplayName, connInfoSingleton.Uri, connInfoSingleton.LogonWithDefaultCredential, connInfoSingleton.CredentialKey, connInfoSingleton.ProposedCredential)
 {
 }
        internal void EnforceADSettings()
        {
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <ExchangeADServerSettings>(0L, "-->ExchangeSystemManagerSettings.EnforceAdSettings: {0}", this);
            if (this["ADServerSettings"] == null && !EnvironmentAnalyzer.IsWorkGroup() && OrganizationType.Cloud != PSConnectionInfoSingleton.GetInstance().Type)
            {
                try
                {
                    try
                    {
                        using (MonadConnection monadConnection = new MonadConnection("timeout=30", new CommandInteractionHandler(), null, PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo()))
                        {
                            monadConnection.Open();
                            LoggableMonadCommand loggableMonadCommand = new LoggableMonadCommand("Get-ADServerSettingsForLogonUser", monadConnection);
                            object[]             array = loggableMonadCommand.Execute();
                            if (array != null && array.Length > 0)
                            {
                                RunspaceServerSettingsPresentationObject runspaceServerSettingsPresentationObject = array[0] as RunspaceServerSettingsPresentationObject;
                                this.ADServerSettings              = runspaceServerSettingsPresentationObject;
                                this.OrganizationalUnit            = runspaceServerSettingsPresentationObject.RecipientViewRoot;
                                this.ForestViewEnabled             = runspaceServerSettingsPresentationObject.ViewEntireForest;
                                this.GlobalCatalog                 = runspaceServerSettingsPresentationObject.UserPreferredGlobalCatalog;
                                this.ConfigurationDomainController = runspaceServerSettingsPresentationObject.UserPreferredConfigurationDomainController;
                                if (runspaceServerSettingsPresentationObject.UserPreferredDomainControllers != null && runspaceServerSettingsPresentationObject.UserPreferredDomainControllers.Count != 0)
                                {
                                    this.DomainController = runspaceServerSettingsPresentationObject.UserPreferredDomainControllers[0];
                                }
                            }
                            else
                            {
                                this.SetDefaultSettings();
                            }
                        }
                    }
                    catch (Exception)
                    {
                        this.SetDefaultSettings();
                    }
                    goto IL_11A;
                }
                finally
                {
                    this.waitHandle.Set();
                }
            }
            this.waitHandle.Set();
IL_11A:
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <ExchangeADServerSettings>(0L, "<--ExchangeSystemManagerSettings.EnforceAdSettings: {0}", this);
        }