Esempio n. 1
0
        private void UserHelperMain_Load(object sender, EventArgs e)
        {
            //add teams to comboboxes and listbox in team management
            lbExistingTeams.DisplayMember      = "Name";
            cbTeam.DisplayMember               = "Name";
            cbTeam.ValueMember                 = "TeamId";
            cbTeamMany.DisplayMember           = "Name";
            cbTeamMany.ValueMember             = "TeamId";
            comboCredentialsTeam.DisplayMember = "Name";
            comboCredentialsTeam.ValueMember   = "TeamId";
            comboCredentialsTeam.Items.Add("Alle");
            lbStudentList.DisplayMember = "Name";
            lbStudentList.ValueMember   = "StudentId";

            Team[]    teams       = db.Teams.ToArray();
            Student[] studentObjs = db.Students.Include("Team").Include("Credentials").ToArray();
            lbExistingTeams.Items.AddRange(teams);
            cbTeam.Items.AddRange(teams);
            cbTeamMany.Items.AddRange(teams);
            comboCredentialsTeam.Items.AddRange(teams);
            lbStudentList.Items.AddRange(studentObjs);



            GroupPrincipal    group = new GroupPrincipal(_userInteraction.GetPrincipalContext());
            PrincipalSearcher src   = new PrincipalSearcher(group);

            PrincipalSearchResult <Principal> groups = src.FindAll();

            //Add windows usergroups to listboxes
            lbUserGroup.Items.AddRange(groups.ToArray());
            lbUserGroupMany.Items.AddRange(groups.ToArray());
            int defaultPort = 0;

            if (db.Credentials.Any())
            {
                defaultPort = db.Credentials.Max(x => x.WebsitePort) + 1;
            }


            txtPort.Text     = defaultPort + "";
            txtPortMany.Text = defaultPort + "";
        }
Esempio n. 2
0
        public GroupPrincipal GetGroup(string SamAccountName)
        {
            PrincipalSearchResult <Principal> ps = SearchGroups(new object[] { SamAccountName }, new int[] { (int)UserFilter.SamAccountName });

            if (ps.Count() == 1)
            {
                return((GroupPrincipal)ps.ToArray()[0]);
            }

            else
            {
                MessageBox.Show("Keine Gruppe gefunden");
                return(null);
            }
        }