Beispiel #1
0
        private async void button5_Click(object sender, EventArgs e)
        {
            List <string> grupy = new List <string>
            {
                "jira-users",
                "jira-restricted-users",
                "confluence-users",
                "confluence-restricted-users",
                "stash-users"
            };

            timer.Start();
            using (Authentication a = new Authentication())
            {
                AuthenticatedToken token = a.Authenticate();
                try
                {
                    SecurityServer s = a.securityServer;

                    List <string> Allusers = await s.findAllPrincipalsAsync(token);

                    List <string> tempUsers = new List <string>();

                    foreach (string g in grupy)
                    {
                        SOAPGroup group = await s.findGroup(token, g);

                        foreach (var m in group.members)
                        {
                            Allusers.Remove(m);
                            this.Text = timer.Elapsed.ToString(@"mm\:ss\:ff");
                        }
                    }

                    tempUsers.AddRange(Allusers);

                    foreach (var u in tempUsers)
                    {
                        SOAPPrincipal SOAPuser = await s.findPrincipalAsync(token, u);

                        if (!SOAPuser.active)
                        {
                            Allusers.Remove(SOAPuser.name);
                            this.Text = timer.Elapsed.ToString(@"mm\:ss\:ff");
                        }
                    }

                    Allusers.Sort();

                    MessageBox.Show(string.Join(" ", Allusers), timer.Elapsed.ToString());
                    this.Text = "Form1";
                    timer.Reset();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Beispiel #2
0
        private async void button4_Click(object sender, EventArgs e)
        {
            timer.Start();
            using (Authentication a = new Authentication())
            {
                AuthenticatedToken token = a.Authenticate();
                try
                {
                    SecurityServer s = a.securityServer;

                    List <string> users = await s.findAllPrincipalsAsync(token);

                    Dictionary <string, int> UsersWithWrongPassword = new Dictionary <string, int>();

                    foreach (string user in users)
                    {
                        this.Text = timer.Elapsed.ToString(@"mm\:ss\:ff");
                        SOAPPrincipal SOAPuser = await s.findPrincipalAsync(token, user);

                        if (SOAPuser.active)
                        {
                            try
                            {
                                string zleHasla = SOAPuser.attributes.SingleOrDefault(x => x.name == "invalidPasswordAttempts")?.values[0];

                                int.TryParse(zleHasla, out int wrPass);
                                if (wrPass > 2)
                                {
                                    UsersWithWrongPassword.Add(SOAPuser.attributes.SingleOrDefault(x => x.name == "displayName")?.values[0], wrPass);
                                }
                            }
                            catch (Exception uex)
                            {
                                MessageBox.Show(uex.Message + '\n' + SOAPuser.name);
                            }
                        }
                    }

                    MessageBox.Show(string.Join("\n", UsersWithWrongPassword.OrderBy(x => x.Key)), timer.Elapsed.ToString());
                    this.Text = "Form1";
                    timer.Reset();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Beispiel #3
0
        //private Task<SOAPPrincipal> findPrincipal(SecurityServer s, AuthenticatedToken token, string user)
        //{
        //    return Task.Run(() =>
        //    {
        //        SOAPPrincipal u = new SOAPPrincipal();

        //        u = s.findPrincipalWithAttributesByName(token, user);
        //        return u;
        //    });
        //}
        #endregion

        private async void button3_Click(object sender, EventArgs e)
        {
            timer.Start();
            using (Authentication a = new Authentication())
            {
                AuthenticatedToken token = a.Authenticate();
                try
                {
                    SecurityServer s = a.securityServer;

                    List <string> users = await s.findAllPrincipalsAsync(token);

                    List <string> notOurUsers = new List <string>();

                    foreach (string user in users)
                    {
                        SOAPPrincipal SOAPuser = await s.findPrincipalAsync(token, user);

                        if (SOAPuser.active)
                        {
                            bool ourMember = SOAPuser.attributes.Select(x => x.name).Contains("lastAuthenticated");

                            if (!ourMember)
                            {
                                notOurUsers.Add(user);
                            }
                        }
                    }

                    notOurUsers.Sort();

                    MessageBox.Show(string.Join(" ", notOurUsers), timer.Elapsed.ToString());
                    timer.Reset();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }