Пример #1
0
        private void DoEdit()
        {
            if (!string.IsNullOrEmpty((string)ListHttpNamespaces.SelectedItem))
            {
                Elevate(NamespaceManagerAction.Edit, (string)ListHttpNamespaces.SelectedItem);

                var original = nsTable[(string)ListHttpNamespaces.SelectedItem].DACL;

                var aclDialog = new AccessControlListDialog((string)ListHttpNamespaces.SelectedItem,
                                                            original != null ? new AccessControlList(original) : new AccessControlList(),
                                                            new List <AceRights>(new AceRights[] { AceRights.GenericAll, AceRights.GenericExecute, AceRights.GenericRead, AceRights.GenericWrite }),
                                                            new List <AceType>(new AceType[] { AceType.AccessAllowed }));
                if (aclDialog.ShowDialog() == DialogResult.OK)
                {
                    var removed = false;
                    try
                    {
                        nsManager.RemoveHttpHamespaceAcl((string)ListHttpNamespaces.SelectedItem);
                        removed = true;
                        nsTable[(string)ListHttpNamespaces.SelectedItem].DACL = aclDialog.ACL;
                        nsManager.SetHttpNamespaceAcl((string)ListHttpNamespaces.SelectedItem, nsTable[(string)ListHttpNamespaces.SelectedItem]);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error Setting ACL. " + ex.Message, "Error Setting ACL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        if (removed)
                        {
                            try
                            {
                                nsTable[(string)ListHttpNamespaces.SelectedItem].DACL = original;
                                nsManager.SetHttpNamespaceAcl((string)ListHttpNamespaces.SelectedItem, nsTable[(string)ListHttpNamespaces.SelectedItem]);
                            }
                            catch (Exception ex2)
                            {
                                MessageBox.Show("Unable to Restore Original ACL, ACL may be corrupt. " + ex2.Message, "Error Retoring ACL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        private void ButtonAdd_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty((string)ListHttpNamespaces.SelectedItem))
            {
                Elevate(NamespaceManagerAction.Add, (string)ListHttpNamespaces.SelectedItem);


                InputBox.Show("Enter URL", "Enter the URL to add:", out var url);

                if (!string.IsNullOrEmpty(url))
                {
                    var newSd = new SecurityDescriptor
                    {
                        DACL = new AccessControlList()
                    };

                    var aclDlg = new AccessControlListDialog(url,
                                                             newSd.DACL,
                                                             new List <AceRights>(new AceRights[] { AceRights.GenericAll, AceRights.GenericExecute, AceRights.GenericRead, AceRights.GenericWrite }),
                                                             new List <AceType>(new AceType[] { AceType.AccessAllowed }));

                    if (aclDlg.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            nsManager.SetHttpNamespaceAcl(url, newSd);
                            nsTable.Add(url, newSd);
                            ListHttpNamespaces.Items.Add(url);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error Adding ACL. " + ex.Message, "Error Adding ACL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Пример #3
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty((string)listHttpNamespaces.SelectedItem))
            {
                Elevate(NamespaceManagerAction.Edit, (string)listHttpNamespaces.SelectedItem);

                AccessControlList original = this.nsTable[(string)listHttpNamespaces.SelectedItem].DACL;

                AccessControlListDialog aclDialog = new AccessControlListDialog((string)listHttpNamespaces.SelectedItem,
                    original != null ? new AccessControlList(original) : new AccessControlList(),
                    new List<AceRights>(new AceRights[] { AceRights.GenericAll, AceRights.GenericExecute, AceRights.GenericRead, AceRights.GenericWrite }),
                    new List<AceType>(new AceType[] { AceType.AccessAllowed }));
                if (aclDialog.ShowDialog() == DialogResult.OK)
                {
                    bool removed = false;
                    try
                    {
                        this.nsManager.RemoveHttpHamespaceAcl((string)listHttpNamespaces.SelectedItem);
                        removed = true;
                        this.nsTable[(string)listHttpNamespaces.SelectedItem].DACL = aclDialog.ACL;
                        this.nsManager.SetHttpNamespaceAcl((string)listHttpNamespaces.SelectedItem, this.nsTable[(string)listHttpNamespaces.SelectedItem]);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error Setting ACL. " + ex.Message, "Error Setting ACL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        if (removed)
                        {
                            try
                            {
                                this.nsTable[(string)listHttpNamespaces.SelectedItem].DACL = original;
                                this.nsManager.SetHttpNamespaceAcl((string)listHttpNamespaces.SelectedItem, this.nsTable[(string)listHttpNamespaces.SelectedItem]);
                            }
                            catch (Exception ex2)
                            {
                                MessageBox.Show("Unable to Restore Original ACL, ACL may be corrupt. " + ex2.Message, "Error Retoring ACL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
        }
Пример #4
-1
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty((string)listHttpNamespaces.SelectedItem))
            {
                Elevate(NamespaceManagerAction.Add, (string)listHttpNamespaces.SelectedItem);

                string url;

                InputBox.Show("Enter URL", "Enter the URL to add:", out url);

                if (!String.IsNullOrEmpty(url))
                {
                    SecurityDescriptor newSd = new SecurityDescriptor();
                    newSd.DACL = new AccessControlList();

                    AccessControlListDialog aclDlg = new AccessControlListDialog(url,
                        newSd.DACL,
                        new List<AceRights>(new AceRights[] { AceRights.GenericAll, AceRights.GenericExecute, AceRights.GenericRead, AceRights.GenericWrite }),
                        new List<AceType>(new AceType[] { AceType.AccessAllowed }));

                    if (aclDlg.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            this.nsManager.SetHttpNamespaceAcl(url, newSd);
                            this.nsTable.Add(url, newSd);
                            this.listHttpNamespaces.Items.Add(url);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error Adding ACL. " + ex.Message, "Error Adding ACL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }