Esempio n. 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            //Need to check with the existing AceMask and then add a
            //new entry to the Advanced permissions dialog if it varies

            //Check for the edit mode or add mode. Since in the add mode user should send the null for daclInfo object
            if (_daclInfo == null)
            {
                _daclInfo = new List <LwAccessControlEntry>();

                LwAccessControlEntry ace = new LwAccessControlEntry();
                ace.AccessMask = "-1";
                ace.AceType    = 0;
                _daclInfo.Add(ace);

                ace            = new LwAccessControlEntry();
                ace.AccessMask = "-1";
                ace.AceType    = 1;
                _daclInfo.Add(ace);
            }
            //Need to calculate the access mask for the Allow and deny permission sets.
            foreach (LwAccessControlEntry ace in _daclInfo)
            {
                long iAceMask = Convert.ToInt64(ace.AccessMask);
                //Validation for the AceType = Allow
                //Update the the AceType object with modified access modes
                if (ace.AceType == 0)
                {
                    foreach (DataGridViewRow dgRow in dgPermissions.Rows)
                    {
                        if (dgRow.Cells[1].Value.ToString().Equals("True"))
                        {
                            _securityDescriptor.GetIntAccessMaskFromStringAceMask(dgRow.Cells[0].Value.ToString(), ref iAceMask);
                        }
                    }
                }

                //Validation for the AceType = Deny
                if (ace.AceType == 1)
                {
                    foreach (DataGridViewRow dgRow in dgPermissions.Rows)
                    {
                        if (dgRow.Cells[2].Value.ToString().Equals("True"))
                        {
                            _securityDescriptor.GetIntAccessMaskFromStringAceMask(dgRow.Cells[0].Value.ToString(), ref iAceMask);
                        }
                    }
                }
                //Check for the edit values
                if (Convert.ToInt32(ace.AccessMask) != Convert.ToInt32(iAceMask))
                {
                    ace.AccessMask = iAceMask.ToString();
                    IsCommit       = true;
                }
            }

            this.DialogResult = DialogResult.OK;
            Close();
        }
Esempio n. 2
0
        private void DgPermissions_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e)
        {
            DgPermissions.EndEdit();
            DataGridViewRow dgRow = DgPermissions.Rows[e.RowIndex];

            if (dgRow != null)
            {
                ListViewItem lvItem = lvGroupOrUserNames.SelectedItems[0];
                List <LwAccessControlEntry> daclInfo = lvItem.Tag as List <LwAccessControlEntry>;
                string sobjectname = lvItem.Text.Substring(0, lvItem.Text.IndexOf('('));

                foreach (LwAccessControlEntry ace in daclInfo)
                {
                    long iAceMask = Convert.ToInt64(ace.AccessMask);
                    if (iAceMask < 0)
                    {
                        iAceMask = 0;
                    }

                    //Validation for the AceType = Allow
                    //Update the the AceType object with modified access modes
                    //AceFlags = 16 is the inherited permission
                    if (ace.AceType == 0 && ace.AceFlags != 16)
                    {
                        if (dgRow.Cells[1].Value.ToString().Equals("True"))
                        {
                            _securityDescriptor.GetIntAccessMaskFromStringAceMask(dgRow.Cells[0].Value.ToString(), ref iAceMask);
                        }
                    }

                    //Validation for the AceType = Deny
                    if (ace.AceType == 1)
                    {
                        if (dgRow.Cells[2].Value.ToString().Equals("True"))
                        {
                            _securityDescriptor.GetIntAccessMaskFromStringAceMask(dgRow.Cells[0].Value.ToString(), ref iAceMask);
                        }
                    }

                    //Need to calculate the access mask for the Allow and deny permission sets.
                    ace.AccessMask = iAceMask.ToString();
                }

                if (_addedObjects.ContainsKey(sobjectname))
                {
                    _addedObjects[sobjectname] = daclInfo;
                }
                else if (_editedObjects.ContainsKey(sobjectname))
                {
                    _editedObjects[sobjectname] = daclInfo;
                }
                else
                {
                    _editedObjects.Add(sobjectname, daclInfo);
                }
            }
            CheckPemissions(sender, e);
        }