protected void btnRemoveTask_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < this.dgTasks.Rows.Count; i++)
     {
         if (((System.Web.UI.WebControls.CheckBox) this.dgTasks.Rows[i].FindControl("chkSelect")).Checked)
         {
             string itemId = this.dgTasks.Rows[i].Cells[3].Text;
             foreach (ListViewItem lvi in this.lsvTasks.Items)
             {
                 if (lvi.SubItems[1].Text == itemId)
                 {
                     if ((lvi.Tag as IAzManItem) != null)
                     {
                         IAzManItem lviTag = (IAzManItem)(lvi.Tag);
                         this.MembersToRemove.Add(lviTag.Name);
                         this.modified = true;
                     }
                     else if ((lvi.Tag as GenericMember) != null)
                     {
                         GenericMember lviTag = (GenericMember)(lvi.Tag);
                         if (this.MembersToAdd.Contains(lviTag.Name))
                         {
                             this.MembersToAdd.Remove(lviTag.Name);
                             this.modified = true;
                         }
                     }
                 }
             }
         }
     }
     this.RefreshItems();
 }
        private void RemoveListViewItem(ref ListView lsv, GenericMember member)
        {
            List <ListViewItem> toRemove = new List <ListViewItem>();

            foreach (ListViewItem lvi in lsv.Items)
            {
                string objectSid = null;
                if ((lvi.Tag as GenericMember) != null)
                {
                    objectSid = ((GenericMember)lvi.Tag).sid.StringValue;
                }
                else if ((lvi.Tag as IAzManStoreGroup) != null)
                {
                    objectSid = ((IAzManStoreGroup)lvi.Tag).SID.StringValue;
                }
                else if ((lvi.Tag as IAzManStoreGroupMember) != null)
                {
                    objectSid = ((IAzManStoreGroupMember)lvi.Tag).SID.StringValue;
                }
                if (objectSid != null)
                {
                    if (member.sid.StringValue == objectSid)
                    {
                        toRemove.Add(lvi);
                        //lvi.Remove();
                        return;
                    }
                }
            }

            ListView.Remove(lsv, toRemove);
        }
 private void btnAddWindowsUsersAndGroups_Click(object sender, EventArgs e)
 {
     try
     {
         ADObject[] res = ((List <ADObject>) this.Session["selectedADObjects"]).ToArray();
         this.Session["selectedADObjects"] = null;
         if (res != null)
         {
             List <DataRow> rowsAdded = new List <DataRow>();
             foreach (ADObject o in res)
             {
                 WhereDefined wd = WhereDefined.LDAP;
                 if (!o.ADSPath.StartsWith("LDAP"))
                 {
                     wd = WhereDefined.Local;
                 }
                 string        displayName = String.Empty;
                 bool          isAGroup    = false;
                 bool          isLocal     = false;
                 GenericMember gm          = null;
                 DirectoryServicesWebUtils.GetMemberInfo(o.Sid, out displayName, out isAGroup, out isLocal);
                 gm      = new GenericMember(new SqlAzManSID(o.Sid), wd, AuthorizationType.Neutral, null, null);
                 gm.Name = displayName;
                 rowsAdded.Add(this.AddLDapDataRow(gm, isAGroup));
                 this.modified = true;
             }
         }
         this.saveSessionVariables();
         this.bindGridView();
     }
     catch (Exception ex)
     {
         this.ShowError(ex.Message);
     }
 }
Пример #4
0
 protected void btnNonMembersRemove_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < this.dgNonMembers.Rows.Count; i++)
     {
         if (((System.Web.UI.WebControls.CheckBox) this.dgNonMembers.Rows[i].FindControl("chkSelect")).Checked)
         {
             string sid = this.dgNonMembers.Rows[i].Cells[3].Text;
             foreach (ListViewItem lvi in this.lsvNonMembers.Items)
             {
                 if (lvi.SubItems[1].Text == sid)
                 {
                     lvi.Selected = true;
                     break;
                 }
             }
         }
     }
     foreach (ListViewItem lvi in this.lsvNonMembers.Items)
     {
         if (lvi.Selected)
         {
             if ((lvi.Tag as IAzManStoreGroup) != null)
             {
                 IAzManStoreGroup lviTag = (IAzManStoreGroup)lvi.Tag;
                 this.NonMembersToRemove.Add(new GenericMember(lviTag.Name, lviTag.SID, WhereDefined.Store));
                 this.modified = true;
             }
             if ((lvi.Tag as IAzManApplicationGroup) != null)
             {
                 IAzManApplicationGroup lviTag = (IAzManApplicationGroup)lvi.Tag;
                 this.NonMembersToRemove.Add(new GenericMember(lviTag.Name, lviTag.SID, WhereDefined.Application));
                 this.modified = true;
             }
             else if ((lvi.Tag as IAzManApplicationGroupMember) != null)
             {
                 IAzManApplicationGroupMember lviTag = (IAzManApplicationGroupMember)lvi.Tag;
                 this.NonMembersToRemove.Add(new GenericMember(lviTag.SID.StringValue, lviTag.SID, WhereDefined.LDAP));
                 this.modified = true;
             }
             else if ((lvi.Tag as GenericMember) != null)
             {
                 GenericMember lviTag = (GenericMember)lvi.Tag;
                 if (this.NonMembersToAdd.Remove(lviTag.sid.StringValue))
                 {
                     this.modified = true;
                 }
             }
             lvi.Selected = false;
         }
     }
     this.RefreshApplicationGroupProperties();
 }
Пример #5
0
        private ListViewItem CreateListViewItem(GenericMember member)
        {
            ListViewItem lvi = new ListViewItem();

            lvi.Tag  = member;
            lvi.Text = member.Name;
            switch (member.WhereDefined.ToString())
            {
            case "LDAP": lvi.SubItems.Add("Active Directory"); break;

            case "Local": lvi.SubItems.Add("Local"); break;

            case "Database": lvi.SubItems.Add("DB User"); break;

            case "Application": lvi.SubItems.Add("Application"); break;

            case "Store": lvi.SubItems.Add("Store"); break;
            }
            lvi.SubItems.Add(member.sid.StringValue);
            return(lvi);
        }
        private DataRow AddLDapDataRow(GenericMember member, bool isAGroup)
        {
            DataRow dr = this.dtAuthorizations.NewRow();

            dr["AttributesLink"] = this.getApplyBeforeAlert();
            dr["Owner"]          = this.currentOwnerName;
            dr["OwnerSID"]       = this.currentOwnerSid;
            dr["Name"]           = member.Name;
            MemberType memberType = isAGroup ? MemberType.WindowsNTGroup : MemberType.WindowsNTUser;

            dr["MemberType"]            = this.RenderMemberType(memberType, member.sid);
            dr["MemberTypeEnum"]        = memberType;
            dr["ObjectSID"]             = member.sid;
            dr["WhereDefined"]          = member.WhereDefined.ToString();
            dr["WhereDefinedEnum"]      = member.WhereDefined;
            dr["AuthorizationType"]     = this.RenderAuthorizationType(member.authorizationType);
            dr["AuthorizationTypeEnum"] = member.authorizationType;
            dr["ValidFrom"]             = member.validFrom.HasValue ? (object)member.validFrom.Value : DBNull.Value;
            dr["ValidTo"] = member.validTo.HasValue ? (object)member.validTo.Value : DBNull.Value;
            this.dtAuthorizations.Rows.Add(dr);
            return(dr);
        }
        private void RemoveListViewItem(ref ListView lsv, GenericMember member)
        {
            List<ListViewItem> toRemove = new List<ListViewItem>();
            foreach (ListViewItem lvi in lsv.Items)
            {
                string objectSid = null;
                if ((lvi.Tag as GenericMember) != null)
                    objectSid = ((GenericMember)lvi.Tag).sid.StringValue;
                else if ((lvi.Tag as IAzManStoreGroup) != null)
                    objectSid = ((IAzManStoreGroup)lvi.Tag).SID.StringValue;
                else if ((lvi.Tag as IAzManStoreGroupMember) != null)
                    objectSid = ((IAzManStoreGroupMember)lvi.Tag).SID.StringValue;
                if (objectSid != null)
                {
                    if (member.sid.StringValue == objectSid)
                    {
                        toRemove.Add(lvi);
                        //lvi.Remove();
                        return;
                    }
                }
            }

            ListView.Remove(lsv, toRemove);
        }
 private ListViewItem CreateListViewItem(GenericMember member)
 {
     ListViewItem lvi = new ListViewItem();
     lvi.Tag = member;
     lvi.Text = member.Name;
     switch (member.WhereDefined.ToString())
     {
         case "LDAP": lvi.SubItems.Add("Active Directory"); break;
         case "Local": lvi.SubItems.Add("Local"); break;
         case "Database": lvi.SubItems.Add("DB User"); break;
         case "Store": lvi.SubItems.Add("Store"); break;
         case "Application": lvi.SubItems.Add("Application"); break;
     }
     lvi.SubItems.Add(member.sid.StringValue);
     return lvi;
 }
 private void btnAddWindowsUsersAndGroups_Click(object sender, EventArgs e)
 {
     try
     {
         ADObject[] res = ((List<ADObject>)this.Session["selectedADObjects"]).ToArray();
         this.Session["selectedADObjects"] = null;
         if (res != null)
         {
             List<DataRow> rowsAdded = new List<DataRow>();
             foreach (ADObject o in res)
             {
                 WhereDefined wd = WhereDefined.LDAP;
                 if (!o.ADSPath.StartsWith("LDAP"))
                     wd = WhereDefined.Local;
                 string displayName = String.Empty;
                 bool isAGroup = false;
                 bool isLocal = false;
                 GenericMember gm = null;
                 DirectoryServicesWebUtils.GetMemberInfo(o.Sid, out displayName, out isAGroup, out isLocal);
                 gm = new GenericMember(new SqlAzManSID(o.Sid), wd, AuthorizationType.Neutral, null, null);
                 gm.Name = displayName;
                 rowsAdded.Add(this.AddLDapDataRow(gm, isAGroup));
                 this.modified = true;
             }
         }
         this.saveSessionVariables();
         this.bindGridView();
     }
     catch (Exception ex)
     {
         this.ShowError(ex.Message);
     }
 }
 private DataRow AddLDapDataRow(GenericMember member, bool isAGroup)
 {
     DataRow dr = this.dtAuthorizations.NewRow();
     dr["AttributesLink"] = this.getApplyBeforeAlert();
     dr["Owner"] = this.currentOwnerName;
     dr["OwnerSID"] = this.currentOwnerSid;
     dr["Name"] = member.Name;
     MemberType memberType = isAGroup ? MemberType.WindowsNTGroup : MemberType.WindowsNTUser;
     dr["MemberType"] = this.RenderMemberType(memberType, member.sid);
     dr["MemberTypeEnum"] = memberType;
     dr["ObjectSID"] = member.sid;
     dr["WhereDefined"] = member.WhereDefined.ToString();
     dr["WhereDefinedEnum"] = member.WhereDefined;
     dr["AuthorizationType"] = this.RenderAuthorizationType(member.authorizationType);
     dr["AuthorizationTypeEnum"] = member.authorizationType;
     dr["ValidFrom"] = member.validFrom.HasValue ? (object)member.validFrom.Value : DBNull.Value;
     dr["ValidTo"] = member.validTo.HasValue ? (object)member.validTo.Value : DBNull.Value;
     this.dtAuthorizations.Rows.Add(dr);
     return dr;
 }