示例#1
0
 private void btnRemove_Click(object sender, EventArgs e)
 {
     DialogResult = MessageBox.Show("Are you sure ?", "Warning!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
     if (DialogResult == DialogResult.OK)
     {
         if (lvUserGroups.SelectedItems.Count > 0)
         {
             updateProgress(true);
             foreach (ListViewItem item in lvUserGroups.SelectedItems)
             {
                 Thread thRemoveObjectsFromUser = new Thread(() =>
                 {
                     Thread.CurrentThread.Name     = "thRemoveObjectsFromUser";
                     dLibAd.adGroups selectedGroup = (item.Tag as dLibAd.adGroups);
                     dLibAd.RemoveMemberFromGroup(new PrincipalContext(ContextType.Domain, frmMain.domainAccountData[0], frmMain.domainAccountData[1], frmMain.domainAccountData[2]), selectedGroup.SammAccountName, usrToUpdate.Account);
                     try
                     {
                         this.Invoke((MethodInvoker) delegate { lvUserGroups.Items.Remove(item); });
                     }
                     catch { Thread.CurrentThread.Abort(); }
                 });
                 thRemoveObjectsFromUser.Start();
             }
             updateProgress(false);
             cachedGroups = false;
             queryUserGroups(false);
         }
     }
 }
示例#2
0
        private void queryGroup(string group)
        {
            groupResult          = dLibAd.adGrpDetailsFinder(new PrincipalContext(ContextType.Domain, frmMain.domainAccountData[0], frmMain.domainAccountData[1], frmMain.domainAccountData[2]), group);
            lblName.Text         = groupResult.Name;
            lblDescription.Text  = groupResult.Description;
            lblCreatedDate.Text  = groupResult.CreationDate.ToString();
            lblModifiedDate.Text = groupResult.ChangedDate.ToString();
            lblScope.Text        = groupResult.Scope;
            lblType.Text         = groupResult.Type;
            lblNotes.Text        = groupResult.Notes;
            this.Text            = groupResult.Name;

            if ((groupResult.DN != null) && (groupResult.DN != string.Empty))
            {
                //string userDN = groupResult.DN.Substring(groupResult.DN.IndexOf(',') + 1, groupResult.DN.Length - (groupResult.DN.IndexOf(',') + 1));
                //string userDN = groupResult.DN;
                //lblDn.Text = userDN.Replace("CN=", string.Empty).Replace("DC=", string.Empty).Replace("OU=", string.Empty).Replace(",", "/");
                lblDn.Text = groupResult.DN;
            }
        }
示例#3
0
        private void btnRemoveGroupGroups_Click(object sender, EventArgs e)
        {
            DialogResult = MessageBox.Show("Are you sure ?", "Warning!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
            if (DialogResult == DialogResult.OK)
            {
                if (lvlGroupGroups.SelectedItems.Count > 0)
                {
                    updateProgressGroupGroups(true);
                    StringBuilder objectsToRemove = new StringBuilder();
                    foreach (ListViewItem item in lvlGroupGroups.SelectedItems)
                    {
                        objectsToRemove.Append(item.Text);

                        Thread thRemoveObjectsFromGroup = new Thread(() =>
                        {
                            Thread.CurrentThread.Name    = "thRemoveObjectsFromGroup";
                            dLibAd.adGroups selectObject = (item.Tag as dLibAd.adGroups);
                            dLibAd.RemoveMemberFromGroup(new PrincipalContext(ContextType.Domain, frmMain.domainAccountData[0], frmMain.domainAccountData[1], frmMain.domainAccountData[2]), selectObject.SammAccountName, groupToQuery);
                            try
                            {
                                //  this.Invoke((MethodInvoker)delegate { lvMembers.Items.Remove(item); });
                            }
                            catch { Thread.CurrentThread.Abort(); }
                        });
                        thRemoveObjectsFromGroup.Start();
                    }

                    foreach (ListViewItem item in lvlGroupGroups.SelectedItems)
                    {
                        if (item.Text.Contains(objectsToRemove.ToString()))
                        {
                            lvlGroupGroups.Items.Remove(item);
                        }
                    }
                    updateProgressGroupGroups(false);
                    cachedGroupGroups = false;
                    queryGroupGroups(false);
                }
            }
        }