示例#1
0
        public Task AddTask(IPAddress ip, string computername, clsConfig.SecurityCredential credentials, string command)
        {
            // Has a valid PSExec path been supplied?
            if (cfg.PSExecPath == "")
            {
                // No - throw exception
                throw new ConfigurationException("No valid path to PSExec has been set in Preferences.  Please set a path to PSExec in Helper Preferences.", "PSExec path not valid");
            }

            // Did we get valid credentials?
            if (credentials == null)
            {
                // No - do we run with the current credentials?
                if (!cfg.RunWithLocalCreds)
                {
                    // No - throw exception
                    throw new ConfigurationException("No credentials found for IP address " + ip.ToString() + " and running with local credentials disabled.  To run with local credentials, check \"Supply current credentials if no other security credentials found for IP address\" in General Preferences.",
                                                     "No local credentials found for remote PC");
                }
            }

            // Build the task details
            Task t = new Task();

            t.TaskID      = ++_taskidcounter;
            t.IP          = ip;
            t.Credentials = credentials;
            t.Computer    = computername;
            t.AddCommand(command);

            // Add the task to the list and return it
            this.Tasks.Add(t);
            return(t);
        }
示例#2
0
        private clsConfig.CredentialCollection CollateForm()
        {
            clsConfig.CredentialCollection cc = new clsConfig.CredentialCollection();

            // Loop through each row and (if it's valid) add it to the collection
            foreach (DataGridViewRow r in grdCredentials.Rows)
            {
                if (!r.IsNewRow && ValidateRow(r))
                {
                    clsConfig.SecurityCredential c = new clsConfig.SecurityCredential();

                    c.ip          = IPAddress.Parse(r.Cells[crNetwork.Index].Value.ToString()).ToString();
                    c.netmask     = byte.Parse(r.Cells[crNetmask.Index].Value.ToString());
                    c.description = r.Cells[crDescription.Index].Value.ToString();

                    if (r.Cells[crDomain.Index].Value == null)
                    {
                        c.domain = "";
                    }
                    else
                    {
                        c.domain = r.Cells[crDomain.Index].Value.ToString();
                    }

                    c.username = r.Cells[crUser.Index].Value.ToString();
                    c.password = r.Cells[crPassword.Index].Value.ToString();

                    cc.Add(c);
                }
            }

            return(cc);
        }
        private clsConfig.CredentialCollection CollateForm()
        {
            clsConfig.CredentialCollection cc = new clsConfig.CredentialCollection();

            // Loop through each row and (if it's valid) add it to the collection
            foreach (DataGridViewRow r in grdCredentials.Rows)
            {
                if (!r.IsNewRow && ValidateRow(r))
                {
                    clsConfig.SecurityCredential c = new clsConfig.SecurityCredential();

                    c.ip = IPAddress.Parse(r.Cells[crNetwork.Index].Value.ToString()).ToString();
                    c.netmask = byte.Parse(r.Cells[crNetmask.Index].Value.ToString());
                    c.description = r.Cells[crDescription.Index].Value.ToString();

                    if (r.Cells[crDomain.Index].Value == null)
                        c.domain = "";
                    else
                        c.domain = r.Cells[crDomain.Index].Value.ToString();

                    c.username = r.Cells[crUser.Index].Value.ToString();
                    c.password = r.Cells[crPassword.Index].Value.ToString();

                    cc.Add(c);
                }
            }

            return cc;
        }
示例#4
0
        private void grdEndpoints_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            // Was this a right-click?
            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                // Yes - save cell context, select cell and show pop-up menu
                epcmRow = grdEndpoints.Rows[e.RowIndex];
                epcmIPAddress = IPAddress.Parse(epcmRow.Cells[epIP.Index].Value.ToString());
                epcmFullName = epcmRow.Cells[epName.Index].Value.ToString();
                grdEndpoints.CurrentCell = grdEndpoints.Rows[e.RowIndex].Cells[e.ColumnIndex];

                // Look for credentials for this PC
                clsConfig.CredentialCollection cc = cfg.CredentialList;
                epcmCreds = cc[epcmIPAddress];

                // Update menu to show details of the selected PC
                epDetails.Text = epcmRow.Cells[epName.Index].Value.ToString() + " at " + epcmIPAddress.ToString();

                // Show pop-up menu
                cmEndpoint.Show(Cursor.Position);
            }
        }