Пример #1
0
 public GroupMem(TheAdminToolBox parent)
 {
     InitializeComponent();
     frm1      = parent;
     this.Text = "Get Members of Groups";
     this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
 }
Пример #2
0
 public GetSCCMByModelForm(TheAdminToolBox f)
 {
     InitializeComponent();
     m_form    = f;
     this.Text = "Get Computer Info By Model";
     this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
 }
Пример #3
0
        public void bw_Run(object source, EventArgs e)
        {
            TheAdminToolBox adm      = new TheAdminToolBox();
            string          strange  = ipStartRangetextBox.Text;
            string          endrange = endRangetextBox.Text;

            foreach (var ip in IPAddressRange.Parse(strange + "-" + endrange))
            {
                if (ipListView.InvokeRequired)
                {
                    ipListView.Invoke(new MethodInvoker(delegate
                    {
                        ipListView.Items.Add(ip.ToString());
                        Application.DoEvents();
                        foreach (ListViewItem i in ipListView.Items)
                        {
                            adm.controlDataService("install", ip.ToString());
                            i.SubItems.Add("Finished installing");
                            Action oo = () => ipListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
                            ipListView.Invoke(oo);
                        }
                    }));
                }
            }
            Action oo2 = () => ipListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);

            ipListView.Invoke(oo2);
        }
Пример #4
0
 public Find(TheAdminToolBox f)
 {
     InitializeComponent();
     m_form           = f;
     this.FormClosed += new FormClosedEventHandler(FindForm_FormClosing);
     this.Text        = "Find";
     this.Icon        = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
 }
Пример #5
0
 public MapNetDrives(Form callingform)
 {
     InitializeComponent();
     mainForm   = callingform as TheAdminToolBox;
     bw.DoWork += initNetDr;
     bw.WorkerSupportsCancellation = true;
     bw.RunWorkerCompleted        += RunWorkerCompletedHandler;
     bw.RunWorkerAsync();
     this.mainForm.ControlMapNetDrIsVisible = false;
     MapNetDrives.ActiveForm.Text           = "Please wait...";
 }
Пример #6
0
        public ADFunc(TheAdminToolBox f)
        {
            InitializeComponent();
            m_form = f;
            TextBoxWatermarkExtensionMethod.SetWatermark(textBoxDomainUserName, "admin_username@domain");
            TextBoxWatermarkExtensionMethod.SetWatermark(textBoxLocalUserName, "RemoteComputerName\\Administrator");
            TextBoxWatermarkExtensionMethod.SetWatermark(textBoxNewName, "Optional field for when renaming");
            textBoxLocalUserName.Text  = "Administrator";
            textBoxDomainUserName.Text = Environment.UserName + "@" + domain;
            this.Text = "Active Directory Domain Functions";
            this.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
            comboBoxOUs.Items.Clear();
            if (Admin.getCurrentDomain() == "domain")
            {
                DirectoryEntry    entry    = new DirectoryEntry("LDAP://");
                DirectorySearcher searcher = new DirectorySearcher(entry);
                searcher.Filter      = "(objectCategory=organizationalUnit)";
                searcher.SearchScope = SearchScope.Subtree;
                foreach (SearchResult res in searcher.FindAll())
                {
                    if (res.Path.Contains(".Computer"))
                    {
                        comboBoxOUs.Items.Add(res.Path.Remove(0, 7));
                    }
                }
            }
            else
            {
                DirectoryEntry    entry    = new DirectoryEntry("LDAP://OU=Computers,OU=US,DC=global,DC=gg,DC=group");
                DirectorySearcher searcher = new DirectorySearcher(entry);
                searcher.Filter      = "(objectCategory=organizationalUnit)";
                searcher.SearchScope = SearchScope.Subtree;
                foreach (SearchResult res in searcher.FindAll())
                {
                    comboBoxOUs.Items.Add(res.Path.Remove(0, 7));
                }

                comboBoxOUs.Items.RemoveAt(0);
            }
        }
Пример #7
0
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            //Create a shortcut to the appropriate Windows domain
            PrincipalContext domainContext = new PrincipalContext(ContextType.Domain,
                                                                  addomain);

            //Create a "user object" in the context
            UserPrincipal user = new UserPrincipal(domainContext);

            //Specify the search parameters
            bool fHasSpace = adtext.Contains(" ");

            if (fHasSpace)
            {
                string[] ssize = adtext.Split(new char[0], StringSplitOptions.RemoveEmptyEntries);
                string   first = ssize[0];
                string   last  = ssize[1];
                user.GivenName = first;
                user.Surname   = last;
            }
            else
            {
                user.SamAccountName = adtext;
            }

            //Create the searcher
            //pass (our) user object
            PrincipalSearcher pS = new PrincipalSearcher();

            pS.QueryFilter = user;

            //Perform the search
            PrincipalSearchResult <Principal> results = pS.FindAll();

            //If necessary, request more details


            //Output first result of the test
            try
            {
                Principal      pc = results.ToList()[0];
                DirectoryEntry de = (DirectoryEntry)pc.GetUnderlyingObject();
                //Gets SamAcctName
                string sam = pc.SamAccountName.ToString();
                //Finds account using sam
                UserPrincipal usr = UserPrincipal.FindByIdentity(domainContext, sam);
                //Test to see if account is locked, if it is unlocks account
                string password = this.textBoxPass.Text;

                if (usr.IsAccountLockedOut())
                {
                    usr.UnlockAccount();
                    usr.SetPassword(password);
                    pc.Dispose();
                    //ResetPass.ActiveForm.Close();
                    long     filetime = TheAdminToolBox.ConvertADSLargeIntegerToInt64(de.Properties["pwdLastSet"].Value);
                    DateTime pwdSet   = DateTime.FromFileTime(filetime);
                    System.Windows.Forms.MessageBox.Show("Account is now unlocked" + "\r\nPassword has been changed.", "Password set", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    usr.SetPassword(password);
                    de.CommitChanges();
                    long     filetime = TheAdminToolBox.ConvertADSLargeIntegerToInt64(de.Properties["pwdLastSet"].Value);
                    DateTime pwdSet   = DateTime.FromFileTime(filetime);
                    System.Windows.Forms.MessageBox.Show("Password has been changed.", "Password set", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    de.Close();
                    pc.Dispose();
                    this.Close();
                }

                pS.Dispose();
            }
            catch (SystemException err)
            {
                System.Windows.Forms.MessageBox.Show(err.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error,
                                                     MessageBoxDefaultButton.Button1,
                                                     MessageBoxOptions.DefaultDesktopOnly);
                this.Close();
            }
        }