private static Fqdn DiscoverExchangeServer()
        {
            string fqdn = null;

            using (new OpenConnection(PSConnectionInfoSingleton.connection))
            {
                string str = Path.Combine(ConfigurationContext.Setup.BinPath, "ConnectFunctions.ps1");
                using (MonadCommand monadCommand = new LoggableMonadCommand(". '" + str + "'", PSConnectionInfoSingleton.connection))
                {
                    monadCommand.CommandType = CommandType.Text;
                    monadCommand.ExecuteNonQuery();
                }
                using (MonadCommand monadCommand2 = new LoggableMonadCommand("Discover-ExchangeServer", PSConnectionInfoSingleton.connection))
                {
                    monadCommand2.CommandType = CommandType.StoredProcedure;
                    monadCommand2.Parameters.Add(new MonadParameter("UseWIA", true));
                    monadCommand2.Parameters.Add(new MonadParameter("SuppressError", true));
                    monadCommand2.Parameters.Add(new MonadParameter("CurrentVersion", ServerVersion.InstalledVersion));
                    object[] array = monadCommand2.Execute();
                    if (array == null || array.Length <= 0)
                    {
                        throw new CmdletInvocationException(Strings.FailedToAutoDiscoverExchangeServer);
                    }
                    fqdn = (array[0] as string);
                }
            }
            return(new Fqdn(fqdn));
        }
示例#2
0
        internal string GetEcpRoot(bool useWIA, string targetServerFqdn)
        {
            MonadConnection connection = new MonadConnection("pooled=false");

            using (new OpenConnection(connection))
            {
                string str = Path.Combine(ConfigurationContext.Setup.BinPath, "ConnectFunctions.ps1");
                using (MonadCommand monadCommand = new LoggableMonadCommand(". '" + str + "'", connection))
                {
                    monadCommand.CommandType = CommandType.Text;
                    monadCommand.ExecuteNonQuery();
                }
                string cmdText = "Discover-EcpVirtualDirectoryForEmc";
                using (MonadCommand monadCommand2 = new LoggableMonadCommand(cmdText, connection))
                {
                    monadCommand2.CommandType = CommandType.StoredProcedure;
                    monadCommand2.Parameters.Add(new MonadParameter("CurrentVersion", new ServerVersion(ConfigurationContext.Setup.InstalledVersion.Major, ConfigurationContext.Setup.InstalledVersion.Minor, ConfigurationContext.Setup.InstalledVersion.Build, ConfigurationContext.Setup.InstalledVersion.Revision)));
                    monadCommand2.Parameters.Add(new MonadParameter("UseWIA", useWIA));
                    if (!string.IsNullOrEmpty(targetServerFqdn))
                    {
                        monadCommand2.Parameters.Add(new MonadParameter("TargetServerFqdn", targetServerFqdn));
                    }
                    object[] array = monadCommand2.Execute();
                    if (array.Length > 0)
                    {
                        return((string)array[0]);
                    }
                }
            }
            return(null);
        }
        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);
        }