private DataRow AddLDapDataRow(GenericMember member, bool isAGroup)
        {
            DataRow dr = this.dtAuthorizations.NewRow();

            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);
            //Adjust columns Width
            foreach (DataGridViewColumn dgvc in this.dgAuthorizations.Columns)
            {
                dgvc.Width = dgvc.GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true);
            }
            return(dr);
        }
Esempio n. 2
0
 private void RemoveListViewItem(ref ListView lsv, GenericMember member)
 {
     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 IAzManApplicationGroup) != null)
         {
             objectSid = ((IAzManApplicationGroup)lvi.Tag).SID.StringValue;
         }
         else if ((lvi.Tag as IAzManApplicationGroupMember) != null)
         {
             objectSid = ((IAzManApplicationGroupMember)lvi.Tag).SID.StringValue;
         }
         if (objectSid != null)
         {
             if (member.sid.StringValue == objectSid)
             {
                 lvi.Remove();
                 return;
             }
         }
     }
 }
 private void btnNonMembersRemove_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem lvi in this.lsvNonMembers.SelectedItems)
     {
         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;
         }
         else if ((lvi.Tag as IAzManStoreGroupMember) != null)
         {
             IAzManStoreGroupMember lviTag = (IAzManStoreGroupMember)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;
             }
         }
     }
     this.RefreshStoreGroupProperties();
     if (this.lsvNonMembers.Items.Count == 0)
     {
         this.btnNonMembersRemove.Enabled = false;
     }
     this.HourGlass(false);
 }
Esempio n. 4
0
 private void btnRemoveTask_Click(object sender, EventArgs e)
 {
     this.DialogResult = DialogResult.None;
     this.HourGlass(true);
     foreach (ListViewItem lvi in this.lsvTasks.CheckedItems)
     {
         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();
     if (this.lsvTasks.Items.Count == 0 || this.lsvTasks.CheckedItems.Count == 0)
     {
         this.btnRemoveTask.Enabled = false;
     }
     this.HourGlass(false);
 }
 private void btnAddWindowsUsersAndGroups_Click(object sender, EventArgs e)
 {
     try
     {
         this.HourGlass(true);
         ADObject[] res = DirectoryServicesUtils.ADObjectPickerShowDialog(this, this.item.Application.Store.Storage.Mode == NetSqlAzManMode.Developer);
         /*Application.DoEvents();*/
         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;
                 bool   isAGroup;
                 bool   isLocal;
                 DirectoryServicesUtils.GetMemberInfo(o.Sid, out displayName, out isAGroup, out isLocal);
                 GenericMember 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.SelectDataGridViewRows(rowsAdded);
         }
         this.btnApply.Enabled = this.modified;
         //Adjust columns Width
         foreach (DataGridViewColumn dgvc in this.dgAuthorizations.Columns)
         {
             dgvc.Width = dgvc.GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true);
         }
         this.HourGlass(false);
     }
     catch (Exception ex)
     {
         this.HourGlass(false);
         this.ShowError(ex.Message, Globalization.MultilanguageResource.GetString("frmItemAuthorizations_Msg10"));
     }
     finally
     {
         this.btnApply.Enabled = this.modified;
     }
 }
Esempio n. 6
0
        private ListViewItem CreateListViewItem(GenericMember member)
        {
            ListViewItem lvi = new ListViewItem();

            if (member != null)
            {
                lvi.Tag  = member;
                lvi.Text = member.Name;
                switch (member.WhereDefined.ToString())
                {
                case "LDAP": lvi.SubItems.Add(Globalization.MultilanguageResource.GetString("WhereDefined_LDAP")); break;

                case "Local": lvi.SubItems.Add(Globalization.MultilanguageResource.GetString("WhereDefined_Local")); break;

                case "Database": lvi.SubItems.Add(Globalization.MultilanguageResource.GetString("WhereDefined_DB")); break;

                case "Store": lvi.SubItems.Add(Globalization.MultilanguageResource.GetString("WhereDefined_Store")); break;

                case "Application": lvi.SubItems.Add(Globalization.MultilanguageResource.GetString("WhereDefined_Application")); break;
                }
            }
            return(lvi);
        }
 private void RemoveListViewItem(ref ListView lsv, GenericMember member)
 {
     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)
             {
                 lvi.Remove();
                 return;
             }
         }
     }
 }
 private ListViewItem CreateListViewItem(GenericMember member)
 {
     ListViewItem lvi = new ListViewItem();
     if (member != null)
     {
         lvi.Tag = member;
         lvi.Text = member.Name;
         switch (member.WhereDefined.ToString())
         {
             case "LDAP": lvi.SubItems.Add(Globalization.MultilanguageResource.GetString("WhereDefined_LDAP")); break;
             case "Local": lvi.SubItems.Add(Globalization.MultilanguageResource.GetString("WhereDefined_Local")); break;
             case "Database": lvi.SubItems.Add(Globalization.MultilanguageResource.GetString("WhereDefined_DB")); break;
             case "Store": lvi.SubItems.Add(Globalization.MultilanguageResource.GetString("WhereDefined_Store")); break;
             case "Application": lvi.SubItems.Add(Globalization.MultilanguageResource.GetString("WhereDefined_Application")); break;
         }
     }
     return lvi;
 }
 private void btnAddWindowsUsersAndGroups_Click(object sender, EventArgs e)
 {
     try
     {
         this.HourGlass(true);
         ADObject[] res = DirectoryServicesUtils.ADObjectPickerShowDialog(this, this.item.Application.Store.Storage.Mode == NetSqlAzManMode.Developer);
         /*Application.DoEvents();*/
         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;
                 bool isAGroup;
                 bool isLocal;
                 DirectoryServicesUtils.GetMemberInfo(o.Sid, out displayName, out isAGroup, out isLocal);
                 GenericMember 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.SelectDataGridViewRows(rowsAdded);
         }
         this.btnApply.Enabled = this.modified;
         //Adjust columns Width
         foreach (DataGridViewColumn dgvc in this.dgAuthorizations.Columns)
         {
             dgvc.Width = dgvc.GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true);
         }
         this.HourGlass(false);
     }
     catch (Exception ex)
     {
         this.HourGlass(false);
         this.ShowError(ex.Message, Globalization.MultilanguageResource.GetString("frmItemAuthorizations_Msg10"));
     }
     finally
     {
         this.btnApply.Enabled = this.modified;
     }
 }
 private DataRow AddLDapDataRow(GenericMember member, bool isAGroup)
 {
     DataRow dr = this.dtAuthorizations.NewRow();
     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);
     //Adjust columns Width
     foreach (DataGridViewColumn dgvc in this.dgAuthorizations.Columns)
     {
         dgvc.Width = dgvc.GetPreferredWidth(DataGridViewAutoSizeColumnMode.AllCells, true);
     }
     return dr;
 }