public UserLogonNameControl()
 {
     this.InitializeComponent();
     if (PSConnectionInfoSingleton.GetInstance().Type == OrganizationType.Cloud)
     {
         this.domainComboBoxPicker.Picker      = new AutomatedObjectPicker(new AcceptedDomainUPNSuffixesConfigurable());
         this.domainComboBoxPicker.ValueMember = "SmtpDomainToString";
     }
     else
     {
         this.domainComboBoxPicker.Picker      = new AutomatedObjectPicker(new UPNSuffixesConfigurable());
         this.domainComboBoxPicker.ValueMember = "CanonicalName";
     }
     this.domainComboBoxPicker.Picker.DataTableLoader.RefreshCompleted += this.DataTableLoader_RefreshCompleted;
     this.domainComboBoxPicker.ValueMemberConverter = new DomainNameConverter();
     this.userNameTextBox.Leave             += this.Focus_Leave;
     this.userNameTextBox.TextChanged       += this.userNameTextBox_TextChanged;
     this.userNameTextBox.FormatModeChanged += delegate(object param0, EventArgs param1)
     {
         this.OnFormatModeChanged(EventArgs.Empty);
     };
     this.domainComboBoxPicker.Leave += this.Focus_Leave;
     this.domainComboBoxPicker.SelectedValueChanged += this.domainComboBoxPicker_SelectedValueChanged;
     new TextBoxConstraintProvider(this, "UserLogonName", this.userNameTextBox);
 }
Exemplo n.º 2
0
        public static bool IsRemoteEnabled()
        {
            if (PSConnectionInfoSingleton.GetInstance().Type != OrganizationType.ToolOrEdge)
            {
                return(true);
            }
            if (EnvironmentAnalyzer.IsWorkGroup())
            {
                return(false);
            }
            string name   = "SOFTWARE\\Microsoft\\ExchangeServer\\v15\\AdminTools";
            bool   result = true;

            try
            {
                using (RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(name))
                {
                    if (registryKey != null)
                    {
                        object value = registryKey.GetValue("EMC.RemotePowerShellEnabled");
                        if (value != null && string.Equals("false", value.ToString(), StringComparison.OrdinalIgnoreCase))
                        {
                            result = false;
                        }
                    }
                }
            }
            catch (SecurityException)
            {
            }
            catch (UnauthorizedAccessException)
            {
            }
            return(result);
        }
Exemplo n.º 3
0
 internal override void OnSaveData(CommandInteractionHandler interactionHandler)
 {
     if (this.mockSettings.ObjectState == ObjectState.Changed)
     {
         PSConnectionInfoSingleton.GetInstance().UpdateRemotePSServer(this.mockSettings.AutomaticallySelect ? null : this.mockSettings.RemotePSServer);
     }
     base.OnSaveData(interactionHandler);
 }
Exemplo n.º 4
0
        public ValidationError[] Validate(object dataObject)
        {
            IConfigurable configurable = dataObject as IConfigurable;

            if (configurable != null && PSConnectionInfoSingleton.GetInstance().Type != OrganizationType.Cloud)
            {
                return(configurable.Validate());
            }
            return(new ValidationError[0]);
        }
Exemplo n.º 5
0
 internal override void OnReadData(CommandInteractionHandler interactionHandler, string pageName)
 {
     PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo();
     this.mockSettings                     = new PSRemoteServer();
     this.mockSettings.DisplayName         = this.displayName;
     this.mockSettings.UserAccount         = PSConnectionInfoSingleton.GetInstance().UserAccount;
     this.mockSettings.RemotePSServer      = PSConnectionInfoSingleton.GetInstance().RemotePSServer;
     this.mockSettings.AutomaticallySelect = (this.mockSettings.RemotePSServer == null);
     base.DataSource = this.mockSettings;
     base.OnReadData(interactionHandler, pageName);
 }
Exemplo n.º 6
0
 public override void Open(IUIService service, WorkUnitCollection workUnits, bool enforceViewEntireForest, ResultsLoaderProfile profile)
 {
     this.isResultPane = !enforceViewEntireForest;
     this.workUnits = workUnits;
     this.commandInteractionHandler = ((service != null) ? new WinFormsCommandInteractionHandler(service) : new CommandInteractionHandler());
     RunspaceServerSettingsPresentationObject runspaceServerSettingsPresentationObject = ADServerSettingsSingleton.GetInstance().CreateRunspaceServerSettingsObject();
     if (enforceViewEntireForest && runspaceServerSettingsPresentationObject != null)
     {
         runspaceServerSettingsPresentationObject.ViewEntireForest = true;
     }
     this.connection = new MonadConnection(PSConnectionInfoSingleton.GetInstance().GetConnectionStringForScript(), this.commandInteractionHandler, runspaceServerSettingsPresentationObject, PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo(profile.SerializationLevel));
     this.connection.Open();
 }
Exemplo n.º 7
0
        internal static string GetCurrentConnectedServerName()
        {
            string result = string.Empty;

            if (WinformsHelper.IsRemoteEnabled())
            {
                result = PSConnectionInfoSingleton.GetInstance().ServerName;
            }
            else
            {
                result = EnvironmentAnalyzer.GetLocalServerName();
            }
            return(result);
        }
        public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values)
        {
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <ExchangeSettingsProvider>(0L, "-->ExchangeSettingsProvider.SetPropertyValues: {0}", this);
            IDictionary dictionary = new Hashtable();

            foreach (object obj in values)
            {
                SettingsPropertyValue settingsPropertyValue = (SettingsPropertyValue)obj;
                ExTraceGlobals.DataFlowTracer.Information <string, object, Type>(0L, "ExchangeSettingsProvider.SetPropertyValues: {0} = {1} as {2}", settingsPropertyValue.Name, settingsPropertyValue.PropertyValue, settingsPropertyValue.Property.PropertyType);
                dictionary.Add(settingsPropertyValue.Name, settingsPropertyValue.PropertyValue);
            }
            string text = (string)context["SettingsKey"];

            this.settingsStore[text] = (PSConnectionInfoSingleton.GetInstance().Enabled ? dictionary : new Hashtable());
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <ExchangeSettingsProvider, string>(0L, "<--ExchangeSettingsProvider.SetPropertyValues: {0}. settingsKey: {1}", this, text);
        }
Exemplo n.º 9
0
 internal string GetEcpUrl(EcpUrlKey key)
 {
     if (this.EcpRootUrl == null)
     {
         return(null);
     }
     if (PSConnectionInfoSingleton.GetInstance().Type == OrganizationType.Cloud && !string.IsNullOrEmpty(EMCRunspaceConfigurationSingleton.GetInstance().TenantDomain))
     {
         return(string.Concat(new string[]
         {
             this.EcpRootUrl,
             "/?Realm=",
             EMCRunspaceConfigurationSingleton.GetInstance().TenantDomain,
             "&ftr=",
             key.ToString()
         }));
     }
     return(this.EcpRootUrl + "/?ftr=" + key.ToString());
 }
Exemplo n.º 10
0
 private void DataTableLoader_RefreshCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         DataTable table = (sender as DataTableLoader).Table;
         if (PSConnectionInfoSingleton.GetInstance().Type == OrganizationType.Cloud)
         {
             DataRow dataRow = table.Rows.OfType <DataRow>().First((DataRow row) => (bool)row["Default"]);
             if (dataRow != null)
             {
                 this.DefaultDomain = dataRow["SmtpDomainToString"].ToString();
             }
         }
         else if (table.Rows.Count > 0)
         {
             this.DefaultDomain = table.Rows[0]["CanonicalName"].ToString();
         }
         if (this.domainComboBoxPicker.SelectedValue == null)
         {
             this.domainComboBoxPicker.SelectedValue = this.DefaultDomain;
         }
     }
 }
Exemplo n.º 11
0
        public object Clone()
        {
            DataObjectProfile dataObjectProfile = new DataObjectProfile(this.Name, this.Type, this.Retriever, this.Validator);

            if (PSConnectionInfoSingleton.GetInstance().Type != OrganizationType.Cloud)
            {
                dataObjectProfile.DataObject = ((this.DataObject is ICloneable) ? ((ICloneable)this.DataObject).Clone() : this.DataObject);
            }
            else if (this.DataObject != null)
            {
                ConfigurableObject configurableObject = this.DataObject as ConfigurableObject;
                if (configurableObject != null)
                {
                    ConfigurableObject configurableObject2 = MockObjectInformation.CreateDummyObject(configurableObject.GetType()) as ConfigurableObject;
                    configurableObject2.propertyBag = (configurableObject.propertyBag.Clone() as PropertyBag);
                    dataObjectProfile.DataObject    = configurableObject2;
                }
                else
                {
                    dataObjectProfile.DataObject = this.DataObject;
                }
            }
            return(dataObjectProfile);
        }
Exemplo n.º 12
0
        protected override void OnExecute()
        {
            string commandDisplayName             = this.CommandDisplayName;
            WorkUnitCollectionEventArgs inputArgs = new WorkUnitCollectionEventArgs(new WorkUnitCollection());

            this.OnInputRequested(inputArgs);
            IUIService uiService = (IUIService)this.GetService(typeof(IUIService));

            if (uiService == null)
            {
                throw new InvalidOperationException("TaskCommand must be sited and needs to be able to find an IUIService.");
            }
            Control      controlToRestoreFocus = uiService.GetDialogOwnerWindow() as Control;
            IRefreshable singleRefreshOnFinish = this.RefreshOnFinish;

            IRefreshable[] multiRefreshOnFinish = (this.MultiRefreshOnFinish == null) ? null : ((IRefreshable[])this.MultiRefreshOnFinish.Clone());
            if (this.ConfirmOperation(inputArgs))
            {
                WorkUnitCollection workUnits = inputArgs.WorkUnits;
                if (workUnits.Count == 0)
                {
                    WorkUnit workUnit = new WorkUnit();
                    workUnit.Text   = commandDisplayName;
                    workUnit.Target = null;
                    workUnits.Add(workUnit);
                }
                IProgress    progress = this.CreateProgress(new LocalizedString(commandDisplayName));
                MonadCommand command  = new LoggableMonadCommand();
                command.CommandText = this.CommandText;
                foreach (object obj in this.Parameters)
                {
                    MonadParameter value = (MonadParameter)obj;
                    command.Parameters.Add(value);
                }
                command.ProgressReport += delegate(object sender, ProgressReportEventArgs progressReportEventArgs)
                {
                    progress.ReportProgress(workUnits.ProgressValue, workUnits.MaxProgressValue, progressReportEventArgs.ProgressRecord.StatusDescription);
                };
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += delegate(object param0, DoWorkEventArgs param1)
                {
                    MonadConnection connection = new MonadConnection("timeout=30", new WinFormsCommandInteractionHandler(this.TestUIService ?? uiService), ADServerSettingsSingleton.GetInstance().CreateRunspaceServerSettingsObject(), PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo());
                    command.Connection = connection;
                    using (new OpenConnection(connection))
                    {
                        command.Execute(workUnits.ToArray());
                    }
                };
                worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs runWorkerCompletedEventArgs)
                {
                    command.Connection.Close();
                    if (runWorkerCompletedEventArgs.Error != null)
                    {
                        progress.ReportProgress(0, 0, "");
                        uiService.ShowError(runWorkerCompletedEventArgs.Error);
                    }
                    else
                    {
                        int num = workUnits.HasFailures ? 0 : 100;
                        progress.ReportProgress(num, num, "");
                        List <WorkUnit> list = new List <WorkUnit>(workUnits.FindByErrorOrWarning());
                        if (workUnits.Cancelled)
                        {
                            WorkUnit workUnit2 = list[list.Count - 1];
                            for (int i = 0; i < workUnit2.Errors.Count; i++)
                            {
                                if (workUnit2.Errors[i].Exception is PipelineStoppedException)
                                {
                                    workUnit2.Errors.Remove(workUnit2.Errors[i]);
                                    break;
                                }
                            }
                            if (workUnit2.Errors.Count == 0)
                            {
                                list.Remove(workUnit2);
                            }
                        }
                        if (list.Count > 0)
                        {
                            string errorMessage   = null;
                            string warningMessage = null;
                            if (list.Count == 1)
                            {
                                if (this.SingleSelectionError != null)
                                {
                                    errorMessage = this.SingleSelectionError(list[0].Text);
                                }
                                else
                                {
                                    errorMessage = Strings.SingleSelectionError(commandDisplayName, list[0].Text);
                                }
                                if (this.SingleSelectionWarning != null)
                                {
                                    warningMessage = this.SingleSelectionWarning(list[0].Text);
                                }
                                else
                                {
                                    warningMessage = Strings.SingleSelectionWarning(commandDisplayName, list[0].Text);
                                }
                            }
                            else if (list.Count > 1)
                            {
                                if (this.MultipleSelectionError != null)
                                {
                                    errorMessage = this.MultipleSelectionError(list.Count);
                                }
                                else
                                {
                                    errorMessage = Strings.MultipleSelectionError(commandDisplayName, list.Count);
                                }
                                if (this.MultipleSelectionWarning != null)
                                {
                                    warningMessage = this.MultipleSelectionWarning(list.Count);
                                }
                                else
                                {
                                    warningMessage = Strings.MultipleSelectionWarning(commandDisplayName, list.Count);
                                }
                            }
                            UIService.ShowError(errorMessage, warningMessage, list, uiService);
                        }
                    }
                    this.PerformRefreshOnFinish(workUnits, singleRefreshOnFinish, multiRefreshOnFinish);
                    this.OnCompleted(inputArgs);
                };
                bool           flag = workUnits.Count > 1;
                ProgressDialog pd   = null;
                if (flag)
                {
                    pd              = new ProgressDialog();
                    pd.OkEnabled    = false;
                    pd.Text         = Strings.TaskProgressDialogTitle(commandDisplayName);
                    pd.UseMarquee   = true;
                    pd.StatusText   = workUnits.Description;
                    pd.FormClosing += delegate(object sender, FormClosingEventArgs formClosingEventArgs)
                    {
                        if (worker.IsBusy)
                        {
                            if (pd.CancelEnabled)
                            {
                                pd.CancelEnabled = false;
                                WinformsHelper.InvokeAsync(delegate
                                {
                                    command.Cancel();
                                }, pd);
                            }
                            formClosingEventArgs.Cancel = worker.IsBusy;
                        }
                    };
                    pd.FormClosed += delegate(object param0, FormClosedEventArgs param1)
                    {
                        if (controlToRestoreFocus != null)
                        {
                            controlToRestoreFocus.Focus();
                        }
                    };
                    worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs runWorkerCompletedEventArgs)
                    {
                        pd.UseMarquee = false;
                        pd.Maximum    = 100;
                        pd.Value      = 100;
                        pd.Close();
                    };
                    command.ProgressReport += delegate(object sender, ProgressReportEventArgs progressReportEventArgs)
                    {
                        if ((progressReportEventArgs.ProgressRecord.RecordType == ProgressRecordType.Processing && progressReportEventArgs.ProgressRecord.PercentComplete > 0 && progressReportEventArgs.ProgressRecord.PercentComplete < 100) || workUnits[0].Status == WorkUnitStatus.Completed)
                        {
                            pd.UseMarquee = false;
                        }
                        pd.Maximum    = workUnits.MaxProgressValue;
                        pd.Value      = workUnits.ProgressValue;
                        pd.StatusText = workUnits.Description;
                    };
                    pd.ShowModeless(uiService.GetDialogOwnerWindow() as IServiceProvider);
                    uiService = pd.ShellUI;
                }
                SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());
                worker.RunWorkerAsync();
                base.OnExecute();
            }
        }
Exemplo n.º 13
0
        public TableDataHandler(string selectCommandText, string updateCommandText, string insertCommandText, string deleteCommandText)
        {
            this.DataTable   = new DataTable();
            this.dataAdapter = new MonadDataAdapter();
            this.dataAdapter.EnforceDataSetSchema = true;
            MonadConnection connection = new MonadConnection("timeout=30", new CommandInteractionHandler(), ADServerSettingsSingleton.GetInstance().CreateRunspaceServerSettingsObject(), PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo());

            this.dataAdapter.SelectCommand = new LoggableMonadCommand(selectCommandText, connection);
            this.dataAdapter.UpdateCommand = new LoggableMonadCommand(updateCommandText, connection);
            this.dataAdapter.UpdateCommand.UpdatedRowSource = UpdateRowSource.None;
            this.dataAdapter.DeleteCommand = new LoggableMonadCommand(deleteCommandText, connection);
            this.dataAdapter.InsertCommand = new LoggableMonadCommand(insertCommandText, connection);
            this.dataAdapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None;
            this.synchronizationContext = SynchronizationContext.Current;
        }
Exemplo n.º 14
0
 public SingleTaskDataHandler(string saveCommandText) : this(saveCommandText, new MonadConnection("timeout=30", new CommandInteractionHandler(), ADServerSettingsSingleton.GetInstance().CreateRunspaceServerSettingsObject(), PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo()))
 {
 }
Exemplo n.º 15
0
 private void ConnectTo(string targetForest)
 {
     this.connection = new MonadConnection("timeout=30", this.commandInteractionHandler, null, PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo(this.uiService, ConnectedForestsInfoSingleton.GetInstance().ForestInfoOf(targetForest)));
     this.connection.Open();
 }
Exemplo n.º 16
0
        private void Fill(RefreshRequestEventArgs e)
        {
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader>((long)this.GetHashCode(), "-->DataTableLoader.Fill: {0}", this);
            ResultsLoaderProfile profile = e.Argument as ResultsLoaderProfile;

            if (profile != null)
            {
                DataTable dataTable = e.Result as DataTable;
                dataTable.RowChanged += delegate(object sender, DataRowChangeEventArgs eventArgs)
                {
                    if (eventArgs.Action == DataRowAction.Add)
                    {
                        this.FillPrimaryKeysBasedOnLambdaExpression(eventArgs.Row, profile);
                    }
                };
                DataTable dataTable2 = dataTable.Clone();
                dataTable2.RowChanged += delegate(object sender, DataRowChangeEventArgs eventArgs)
                {
                    if (eventArgs.Action == DataRowAction.Add)
                    {
                        this.FillPrimaryKeysBasedOnLambdaExpression(eventArgs.Row, profile);
                    }
                };
                if (!this.EnforeViewEntireForest && !profile.HasPermission())
                {
                    goto IL_26F;
                }
                using (DataAdapterExecutionContext dataAdapterExecutionContext = this.executionContextFactory.CreateExecutionContext())
                {
                    dataAdapterExecutionContext.Open(base.UIService, this.WorkUnits, this.EnforeViewEntireForest, profile);
                    foreach (AbstractDataTableFiller filler in profile.TableFillers)
                    {
                        if (profile.IsRunnable(filler))
                        {
                            if (e.CancellationPending)
                            {
                                break;
                            }
                            profile.BuildCommand(filler);
                            if (profile.FillType == 1 || this.IsPreFillForResolving(filler))
                            {
                                dataAdapterExecutionContext.Execute(filler, dataTable2, profile);
                                this.MergeChanges(dataTable2, dataTable);
                                dataTable2.Clear();
                            }
                            else
                            {
                                dataAdapterExecutionContext.Execute(filler, dataTable, profile);
                            }
                        }
                    }
                    goto IL_26F;
                }
            }
            MonadCommand monadCommand = e.Argument as MonadCommand;

            if (monadCommand != null)
            {
                this.AttachCommandToMonitorWarnings(monadCommand);
                using (MonadConnection monadConnection = new MonadConnection(PSConnectionInfoSingleton.GetInstance().GetConnectionStringForScript(), new CommandInteractionHandler(), ADServerSettingsSingleton.GetInstance().CreateRunspaceServerSettingsObject(), PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo(ExchangeRunspaceConfigurationSettings.SerializationLevel.Full)))
                {
                    monadConnection.Open();
                    monadCommand.Connection = monadConnection;
                    using (MonadDataAdapter monadDataAdapter = new MonadDataAdapter(monadCommand))
                    {
                        DataTable dataTable3 = (DataTable)e.Result;
                        if (dataTable3.Columns.Count != 0)
                        {
                            monadDataAdapter.MissingSchemaAction  = MissingSchemaAction.Ignore;
                            monadDataAdapter.EnforceDataSetSchema = true;
                        }
                        ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader, MonadCommand>((long)this.GetHashCode(), "-->DataTableLoader.Fill: calling dataAdapter.Fill: {0}. Command:{1}", this, monadCommand);
                        monadDataAdapter.Fill(dataTable3);
                        ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader, MonadCommand>((long)this.GetHashCode(), "<--DataTableLoader.Fill: calling dataAdaptr.Fill: {0}. Command:{1}", this, monadCommand);
                    }
                }
                this.DetachCommandFromMonitorWarnings(monadCommand);
            }
IL_26F:
            this.OnFillTable(e);
            ExTraceGlobals.ProgramFlowTracer.TraceFunction <DataTableLoader>((long)this.GetHashCode(), "<--DataTableLoader.Fill: {0}", this);
        }
        protected override MonadConnection CreateMonadConnection(IUIService uiService, CommandInteractionHandler commandInteractionHandler)
        {
            MonadConnectionInfo monadConnectionInfo = PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo();

            return(new MonadConnection("timeout=30", commandInteractionHandler, null, new MonadConnectionInfo(PSConnectionInfoSingleton.GetRemotePowerShellUri(new Fqdn(this.ServerName)), monadConnectionInfo.Credentials, monadConnectionInfo.ShellUri, monadConnectionInfo.FileTypesXml, monadConnectionInfo.AuthenticationMechanism, monadConnectionInfo.SerializationLevel, monadConnectionInfo.ClientApplication, string.Empty, monadConnectionInfo.MaximumConnectionRedirectionCount, monadConnectionInfo.SkipServerCertificateCheck)));
        }
Exemplo n.º 18
0
 public static bool IsCloudOrganization()
 {
     return(PSConnectionInfoSingleton.GetInstance().Type == OrganizationType.Cloud);
 }
Exemplo n.º 19
0
 public static bool IsCurrentOrganizationAllowed(IList <OrganizationType> organizationTypeList)
 {
     return(organizationTypeList == null || organizationTypeList.Count == 0 || organizationTypeList.Contains(PSConnectionInfoSingleton.GetInstance().Type));
 }
Exemplo n.º 20
0
        public virtual void Initialize()
        {
            if (!this.validTool)
            {
                return;
            }
            if (string.IsNullOrEmpty(this.name))
            {
                this.validTool = false;
                this.AddErrorMessage(Strings.NameError);
            }
            if (string.IsNullOrEmpty(this.type))
            {
                this.validTool = false;
                this.AddErrorMessage(Strings.TypeError);
            }
            else if (string.Compare(this.type, "SnapIn", true) != 0 && string.Compare(this.type, "Executable", true) != 0 && string.Compare(this.type, "MonadScript", true) != 0 && string.Compare(this.type, "DynamicURL", true) != 0 && string.Compare(this.type, "StaticURL", true) != 0)
            {
                this.validTool = false;
                this.AddErrorMessage(Strings.InvalidType(this.type));
            }
            if (string.IsNullOrEmpty(this.command) && string.Compare(this.type, "DynamicURL", true) != 0 && string.IsNullOrEmpty(this.command) && string.Compare(this.type, "StaticURL", true) != 0)
            {
                this.validTool = false;
                this.AddErrorMessage(Strings.CommandError);
            }
            SafeLibraryHandle safeLibraryHandle = new SafeLibraryHandle();

            if (string.IsNullOrEmpty(this.assembly))
            {
                this.validTool = false;
                this.AddErrorMessage(Strings.AssemblyError);
            }
            else
            {
                string text = this.assembly;
                if (!Path.IsPathRooted(this.assembly))
                {
                    if (PSConnectionInfoSingleton.GetInstance().Type == OrganizationType.Cloud)
                    {
                        text = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.GetFileName(text));
                    }
                    else
                    {
                        text = Path.Combine(this.workingFolder, this.assembly);
                    }
                }
                if (!File.Exists(text))
                {
                    this.validTool = false;
                    this.AddErrorMessage(Strings.AssemblyMissing(this.assembly));
                }
                else
                {
                    if (safeLibraryHandle != null)
                    {
                        safeLibraryHandle.Dispose();
                        safeLibraryHandle = null;
                    }
                    safeLibraryHandle = SafeLibraryHandle.LoadLibrary(text);
                }
            }
            if (string.Compare(this.type, "MonadScript", true) == 0 || string.Compare(this.type, "SnapIn", true) == 0)
            {
                if (string.IsNullOrEmpty(this.commandFile))
                {
                    this.validTool = false;
                    this.AddErrorMessage(Strings.CommandFileError(this.name));
                }
                else if (string.Compare(this.type, "SnapIn", true) == 0)
                {
                    if (string.Compare(Path.GetFileName(this.command), "mmc.exe", true) != 0)
                    {
                        this.validTool = false;
                        this.AddErrorMessage(Strings.InvalidSnapinTool(this.command));
                    }
                    else
                    {
                        string empty = string.Empty;
                        if (!Tool.safeToolsList.TryGetValue(this.name, out empty))
                        {
                            this.validTool = false;
                            this.AddErrorMessage(Strings.SnapInNotInSafeList(this.name));
                        }
                        else if (string.Compare(Path.GetFileName(this.commandFile.Replace("\"", "")), empty, true) != 0)
                        {
                            this.validTool = false;
                            this.AddErrorMessage(Strings.SnapInCommandFileNotInSafeList(this.commandFile, this.name));
                        }
                    }
                }
                else if (string.Compare(Path.GetFileName(this.command), "PowerShell.exe", true) != 0)
                {
                    this.validTool = false;
                    this.AddErrorMessage(Strings.InvalidCmdletTool(this.command));
                }
                else
                {
                    string empty2 = string.Empty;
                    if (!Tool.safeToolsList.TryGetValue(this.name, out empty2))
                    {
                        this.validTool = false;
                        this.AddErrorMessage(Strings.SnapInNotInSafeList(this.name));
                    }
                    else if (string.Compare(Path.GetFileName(this.commandFile.Replace("\"", "")), empty2, true) != 0)
                    {
                        this.validTool = false;
                        this.AddErrorMessage(Strings.SnapInCommandFileNotInSafeList(this.commandFile, this.name));
                    }
                }
            }
            else if (string.Compare(this.type, "Executable", true) == 0)
            {
                if (string.IsNullOrEmpty(this.command))
                {
                    this.validTool = false;
                    this.AddErrorMessage(Strings.CommandError);
                }
                else
                {
                    string empty3 = string.Empty;
                    if (!Tool.safeToolsList.TryGetValue(this.name, out empty3))
                    {
                        this.validTool = false;
                        this.AddErrorMessage(Strings.ExecutableNotInSafeList(this.name));
                    }
                    else if (string.Compare(Path.GetFileName(this.command), empty3, true) != 0)
                    {
                        this.validTool = false;
                        this.AddErrorMessage(Strings.ExecutableCommandNotInSafeList(this.command, this.name));
                    }
                }
            }
            try
            {
                this.nonEdgeTool = Tool.nonEdgeToolsList.Contains(this.Name);
                this.cloudAndRemoteOnPremiseTool = Tool.cloudAndRemoteOnPremiseToolsList.Contains(this.Name);
                if (!safeLibraryHandle.IsInvalid)
                {
                    if (this.localizedDescription != 0)
                    {
                        string @string = this.GetString(this.localizedDescription, safeLibraryHandle);
                        if (!string.IsNullOrEmpty(@string))
                        {
                            this.description = @string;
                        }
                    }
                    if (this.localizedGroupName != 0)
                    {
                        string @string = this.GetString(this.LocalizedGroupName, safeLibraryHandle);
                        if (!string.IsNullOrEmpty(@string))
                        {
                            this.groupName = @string;
                        }
                    }
                    if (this.localizedName != 0)
                    {
                        string @string = this.GetString(this.LocalizedName, safeLibraryHandle);
                        if (!string.IsNullOrEmpty(@string))
                        {
                            this.name = @string;
                        }
                    }
                }
                this.LoadIcon(safeLibraryHandle);
            }
            finally
            {
                safeLibraryHandle.Dispose();
            }
            this.UpdateGroup();
        }
 protected virtual MonadConnection CreateMonadConnection(IUIService uiService, CommandInteractionHandler commandInteractionHandler)
 {
     return(new MonadConnection("timeout=30", commandInteractionHandler, ADServerSettingsSingleton.GetInstance().CreateRunspaceServerSettingsObject(), PSConnectionInfoSingleton.GetInstance().GetMonadConnectionInfo()));
 }