Esempio n. 1
0
        private void EditUrlAcl()
        {
            try
            {
                UrlAclConfigItem selectedItem = (UrlAclConfigItem)urlAclListView.SelectedItems[0];

                string originalSddl = selectedItem.Dacl.ToSddl();

                string editedSddl = SecurityEditor.EditSecurity(Handle, selectedItem.Url, originalSddl);

                if (editedSddl != originalSddl)
                {
                    selectedItem.Dacl = Acl.FromSddl(editedSddl);

                    if (selectedItem.Status == ModifiedStatus.Unmodified)
                    {
                        selectedItem.Status = ModifiedStatus.Modified;
                    }

                    applyButton.Enabled = true;

                    PopulateConfigListView(_urlAclItems, urlAclListView);
                }
            }
            finally
            {
                EnableUrlAclButtons();
            }
        }
Esempio n. 2
0
        private void addUrlAclButton_Click(object sender, System.EventArgs e)
        {
            try
            {
                using (InputBox input = new InputBox("New URL", "Please enter the URL:"))
                {
                    if (input.ShowDialog(this) == DialogResult.OK)
                    {
                        UrlAclConfigItem newItem = new UrlAclConfigItem();

                        newItem.Url = input.UserInput;

                        bool exists = false;
                        if (_urlAclItems.Contains(newItem.Key))
                        {
                            exists = true;

                            if (((ConfigItem)_urlAclItems[newItem.Key]).Status != ModifiedStatus.Removed)
                            {
                                MessageBox.Show(this, "Security is already configured for the Url you entered.", "Invalid Input");
                                return;
                            }
                        }

                        string originalSddl = newItem.Dacl != null?newItem.Dacl.ToSddl() : "D:";

                        string editedSddl = SecurityEditor.EditSecurity(Handle, newItem.Url, originalSddl);

                        if (editedSddl != originalSddl)
                        {
                            if (exists)
                            {
                                newItem.Status            = ModifiedStatus.Modified;
                                _urlAclItems[newItem.Key] = newItem;
                            }
                            else
                            {
                                newItem.Dacl   = Acl.FromSddl(editedSddl);
                                newItem.Status = ModifiedStatus.Added;
                                _urlAclItems.Add(newItem.Key, newItem);
                            }

                            applyButton.Enabled = true;

                            PopulateConfigListView(_urlAclItems, urlAclListView);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DisplayError(ex);
            }
            finally
            {
                EnableUrlAclButtons();
            }
        }
Esempio n. 3
0
        public static string EditSecurity(IntPtr hwndOwner, string objectName, string sddl)
        {
            using (SecurityEditor editor = new SecurityEditor(objectName, sddl))
            {
                if (!EditSecurity(hwndOwner, editor._pSecurityInterface))
                {
                    int err = Marshal.GetLastWin32Error();

                    throw new System.ComponentModel.Win32Exception(err, "EditSecurity failed.  Error = " + err);
                }

                return(editor._sddl);
            }
        }