Example #1
0
        internal FrmRebootCommand(List <ADComputer> targetComputers, string login, string password)
        {
            InitializeComponent();
            _wrongCrendentialsWatcher = new WrongCredentialsWatcher();
            _wrongCrendentialsWatcher.IsWrongCredentials            = false;
            _wrongCrendentialsWatcher.IsAbortRequested              = false;
            _wrongCrendentialsWatcher.ContinueWithFailedCredentials = false;

            _closing = false;

            _targetComputers = targetComputers;
            _login           = login;
            _password        = password;

            if (!String.IsNullOrEmpty(Properties.Settings.Default.PersonalizedRebootMessage))
            {
                txtBxMessage.Text = Properties.Settings.Default.PersonalizedRebootMessage;
            }

            localComputerName = Environment.MachineName;
            string domaineName = ADHelper.GetDomainName();

            if (!string.IsNullOrEmpty(domaineName) && !localComputerName.EndsWith(domaineName))
            {
                localComputerName += "." + domaineName;
            }
        }
Example #2
0
 private void FrmAD_WSUSComparer_Load(object sender, EventArgs e)
 {
     Logger.EnteringMethod();
     txtBxDomainName.Text = ADHelper.GetDomainName();
     Logger.Write(txtBxDomainName);
     lblCredentials.Text = (Credentials.GetInstance()).CredentialNotice;
     Logger.Write(lblCredentials);
 }
Example #3
0
 private void SearchAllOU()
 {
     lock (ouSearcherLocker)
     {
         rootNode.Text = ADHelper.GetDomainName();
         rootNode.Tag  = "LDAP://" + ADHelper.GetDomainName();
         rootNode      = ADHelper.GetOUList(rootNode);
     }
 }
 private void dGVComputer_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right && e.RowIndex != -1)
     {
         bool IsInDomain = !string.IsNullOrEmpty(ADHelper.GetDomainName());
         AdjustSelection(e.RowIndex);
         ctxMnuComputer.Items["ShowPendingUpdates"].Enabled              = (dGVComputer.SelectedRows.Count == 1 && IsInDomain && System.IO.File.Exists("ShowPendingUpdates.exe"));
         ctxMnuComputer.Items["ShowWindowsUpdateLog"].Enabled            = (dGVComputer.SelectedRows.Count == 1 && IsInDomain);
         ctxMnuComputer.Items["InstallPendingUpdates"].Enabled           = IsInDomain && System.IO.File.Exists("InstallPendingUpdates.exe") && System.IO.File.Exists("Interop.WUApiLib.dll");
         ctxMnuComputer.Items["CleanSoftwareDistributionFolder"].Enabled = IsInDomain;
         ctxMnuComputer.Items["ShowCurrentLogonUser"].Enabled            = IsInDomain && (dGVComputer.SelectedRows.Count == 1);
         ctxMnuComputer.Show(dGVComputer, dGVComputer.PointToClient(Cursor.Position));
     }
 }
        private void ctxMnuComputer_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            Logger.EnteringMethod(e.ClickedItem.Name);
            List <ADComputer>  targetComputers = new List <ADComputer>();
            FrmRemoteExecution remoteExecution = new FrmRemoteExecution();

            foreach (DataGridViewRow row in dGVComputer.SelectedRows)
            {
                if (row.Visible)
                {
                    targetComputers.Add((ADComputer)row.Cells["ComputerName"].Value);
                }
            }
            ctxMnuComputer.Hide();
            Credentials cred = Credentials.GetInstance();

            if (targetComputers.Count != 0)
            {
                if (cred.InitializeCredential() == false)
                {
                    return;
                }
            }
            lblCredentialNotice.Text = cred.CredentialNotice;
            Logger.Write(lblCredentialNotice);

            switch (e.ClickedItem.Name)
            {
            case "DetectNow":
                remoteExecution.Show(this);
                remoteExecution.SendDetectNow(targetComputers, cred.Login, cred.Password);
                break;

            case "ReportNow":
                remoteExecution.Show(this);
                remoteExecution.SendReportNow(targetComputers, cred.Login, cred.Password);
                break;

            case "RebootNow":
                FrmRebootCommand rebootCommand = new FrmRebootCommand(targetComputers, cred.Login, cred.Password);
                rebootCommand.Show();
                break;

            case "ShowPendingUpdates":
                System.Diagnostics.ProcessStartInfo startInfo      = new System.Diagnostics.ProcessStartInfo();
                System.Security.SecureString        securePassword = new System.Security.SecureString();

                startInfo.FileName = Environment.CurrentDirectory + @"\ShowPendingUpdates.exe";
                if (!System.IO.File.Exists(startInfo.FileName))
                {
                    Logger.Write("Unable to find : " + startInfo.FileName);
                    MessageBox.Show(resMan.GetString("UnableToFindShowPendingUpdates"));
                }
                else
                {
                    startInfo.Arguments = targetComputers[0].Name;
                    if (!string.IsNullOrEmpty(cred.Login) && !string.IsNullOrEmpty(cred.Password))
                    {
                        foreach (Char letter in cred.Password)
                        {
                            securePassword.AppendChar(letter);
                        }
                        startInfo.UserName = cred.Login;
                        startInfo.Password = securePassword;
                        startInfo.Domain   = ADHelper.GetDomainName();
                    }
                    startInfo.UseShellExecute  = false;
                    startInfo.WorkingDirectory = Environment.CurrentDirectory;
                    try
                    {
                        System.Diagnostics.Process.Start(startInfo);
                    }
                    catch (Exception ex)
                    {
                        Logger.Write("**** " + ex.Message);
                        MessageBox.Show(ex.Message);
                    }
                }
                break;

            case "InstallPendingUpdates":
                FrmInstallPendingUpdatesNow installPendingUpdates = new FrmInstallPendingUpdatesNow();
                installPendingUpdates.Username  = cred.Login;
                installPendingUpdates.Password  = cred.Password;
                installPendingUpdates.Computers = targetComputers;
                installPendingUpdates.ShowDialog();
                break;

            case "ShowCurrentLogonUser":
                this.Cursor = Cursors.WaitCursor;
                ADComputer remoteComputer = new ADComputer(dGVComputer.SelectedRows[0].Cells["ComputerName"].Value.ToString());
                string     logonUser      = remoteComputer.GetCurrentLogonUser(cred.Login, cred.Password);
                if (!string.IsNullOrEmpty(logonUser))
                {
                    MessageBox.Show(resMan.GetString("CurrentLogonUserIs") + " : " + logonUser);
                }
                else
                {
                    MessageBox.Show(resMan.GetString("UnableToGetLogonUser"));
                }
                this.Cursor = Cursors.Default;
                break;

            case "ShowWindowsUpdateLog":
                this.Cursor = Cursors.WaitCursor;
                ADComputer computer = new ADComputer(dGVComputer.SelectedRows[0].Cells["ComputerName"].Value.ToString());
                if (!computer.Ping(100))
                {
                    MessageBox.Show(resMan.GetString("ComputerUnreachable"));
                }
                else
                {
                    computer.OpenWindowsUpdateLog(cred.Login, cred.Password);
                }
                this.Cursor = Cursors.Default;
                break;

            case "CleanSoftwareDistributionFolder":
                this.Cursor = Cursors.WaitCursor;
                FrmCleanSoftwareDistributionFolder frmCleanSoftwareDistributionFolder = new FrmCleanSoftwareDistributionFolder(targetComputers, cred.Login, cred.Password);
                frmCleanSoftwareDistributionFolder.ShowDialog();
                this.Cursor = Cursors.Default;
                break;

            default:
                break;
            }
        }