Beispiel #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();
            }
        }
Beispiel #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();
            }
        }
Beispiel #3
0
        private static UrlAclConfigItem Deserialize(IntPtr pUrlAclConfigSetStruct)
        {
            UrlAclConfigItem item = new UrlAclConfigItem();

            HttpApi.HTTP_SERVICE_CONFIG_URLACL_SET aclStruct =
                (HttpApi.HTTP_SERVICE_CONFIG_URLACL_SET)Marshal.PtrToStructure(pUrlAclConfigSetStruct, typeof(HttpApi.HTTP_SERVICE_CONFIG_URLACL_SET));

            item.Url = aclStruct.KeyDesc.pUrlPrefix;

            item.Dacl = Acl.FromSddl(aclStruct.ParamDesc.pStringSecurityDescriptor);

            item.Status = ModifiedStatus.Unmodified;

            return(item);
        }