예제 #1
0
        private void OUBox_SelectionChangeCommitted(object sender, EventArgs e)
        {
            startBox.Text = OUBox.Text;
            whoBox.Items.Clear();
            if (domainBox.Text.Length == 0 || OUBox.Text.Length == 0)
            {
                Console.WriteLine("Listing users aborted. domain/OU=" + domainBox.Text + "/" + OUBox.Text);

                return;
            }
            DirectoryEntry de = ((Domain)domainBox.SelectedItem).GetDirectoryEntry();

            foreach (DirectoryEntry de_ in de.Children)
            {
                if (de_.Properties["name"].Value.ToString().Equals(OUBox.Text))
                {
                    de = de_; break;
                }
            }
            Cursor.Current = Cursors.WaitCursor;
            Console.WriteLine("Listing users in " + de.Name + "...");
            USERS.Clear();
            USERS.FindAll(de);
            whoBox.Items.AddRange(USERS.getUsers());
            string me_user       = UserPrincipal.Current.SamAccountName.ToUpper();
            string me_domain     = UserPrincipal.Current.UserPrincipalName.Split(new [] { '@', '.' })[1].ToUpper();
            string me_domainuser = me_domain + "\\" + me_user;

            if (USERS.FindOneDomainUser(me_domainuser))
            {
                whoBox.Items.Add(USERS.getDisplaynameFromUsername(me_user));
                whoBox.Text = USERS.getDisplaynameFromUsername(me_user);
            }
            Cursor.Current = Cursors.Default;
        }
예제 #2
0
        private void OUBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Stop.Visible)
            {
                Stop.PerformClick();
            }
            dptBox.Items.Clear();
            dptBox.Text = "";
            dptBox.Items.Add("");
            usersInfo.Clear();
            if (domainBox.Text.Length == 0)
            {
                return;
            }

            setEnableGUI(false);
            statusLabel.Text = "Listing the Dpts and Workstations...";
            Cursor.Current   = Cursors.WaitCursor;
            try
            {
                DirectoryEntry de = ((Domain)domainBox.SelectedItem).GetDirectoryEntry(), ou = null;
                foreach (DirectoryEntry de_ in de.Children)
                {
                    if (de_.Properties["name"].Value.ToString().Equals(OUBox.Text))
                    {
                        ou = de = de_; break;
                    }
                }

                usersInfo.FindAll(de);

                statusLabel.Text = "Found " + usersInfo.getUsersCount() + " user" + (usersInfo.getUsersCount() > 1 ? "s" : "")
                                   + " in " + domainBox.Text + "/" + OUBox.Text + "/" + dptBox.Text + "    Click the Play button.";

                string speech = "Found " + usersInfo.getUsersCount() + " user" + (usersInfo.getUsersCount() > 1 ? "s" : "")
                                + " in " + Regex.Replace(Regex.Replace(domainBox.Text.ToUpper(), @"([^.]*)\..*", "$1"), "(.)", "$1.")
                                + " " + OUBox.Text.ToLower()
                                + " " + Regex.Replace(dptBox.Text.ToUpper(), "(.)", "$1.") + ".";

                if (firstOUBox_SelectedIndexChanged)
                {
                    AuditSec.Speak(speech, false, false, null);
                    firstOUBox_SelectedIndexChanged = false;
                }
                else
                {
                    speak(speech);
                }
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee.ToString());
            }
            Cursor.Current = Cursors.Default;
            setEnableGUI(true);
        }