From d3063de68b1ab12e3db4767e8deb1aec086eb797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimund=20And=C3=A9e=20=5BMSFT=5D?= Date: Wed, 10 Jul 2019 01:15:41 +0200 Subject: [PATCH] Removing code that uses WinForms for compatibility with PowerShell Core --- NTFSSecurity/NTFSSecurity-Help.xml | 4 +- NTFSSecurity/NTFSSecurity.csproj | 18 - NTFSSecurity/NTFSSecurity.format.ps1xml | 3 +- NTFSSecurity/ShowSimpleAccess.Designer.cs | 309 ------------------ NTFSSecurity/ShowSimpleAccess.cs | 271 --------------- NTFSSecurity/ShowSimpleAccess.resx | 168 ---------- .../ShowSimpleEffectiveAccess.Designer.cs | 234 ------------- NTFSSecurity/ShowSimpleEffectiveAccess.cs | 222 ------------- NTFSSecurity/ShowSimpleEffectiveAccess.resx | 165 ---------- .../SimpleAccessCmdlets.cs | 75 +---- 10 files changed, 6 insertions(+), 1463 deletions(-) delete mode 100644 NTFSSecurity/ShowSimpleAccess.Designer.cs delete mode 100644 NTFSSecurity/ShowSimpleAccess.cs delete mode 100644 NTFSSecurity/ShowSimpleAccess.resx delete mode 100644 NTFSSecurity/ShowSimpleEffectiveAccess.Designer.cs delete mode 100644 NTFSSecurity/ShowSimpleEffectiveAccess.cs delete mode 100644 NTFSSecurity/ShowSimpleEffectiveAccess.resx diff --git a/NTFSSecurity/NTFSSecurity-Help.xml b/NTFSSecurity/NTFSSecurity-Help.xml index 176b9bd..573972c 100644 --- a/NTFSSecurity/NTFSSecurity-Help.xml +++ b/NTFSSecurity/NTFSSecurity-Help.xml @@ -25,7 +25,9 @@ - Account (SamAccountName or SID) - AccessRights (Read, Change, FullControl, etc., ...) - AccessType (Allow or Deny) - - ApplyTo (This folder only, Only files, etc.) + - + +(This folder only, Only files, etc.) All the options are explained in the parameter section. diff --git a/NTFSSecurity/NTFSSecurity.csproj b/NTFSSecurity/NTFSSecurity.csproj index 8de27fe..d5d189e 100644 --- a/NTFSSecurity/NTFSSecurity.csproj +++ b/NTFSSecurity/NTFSSecurity.csproj @@ -95,12 +95,6 @@ - - Form - - - ShowSimpleEffectiveAccess.cs - @@ -108,12 +102,6 @@ True Resources.resx - - Form - - - ShowSimpleAccess.cs - @@ -150,16 +138,10 @@ - - ShowSimpleEffectiveAccess.cs - PublicResXFileCodeGenerator Resources.Designer.cs - - ShowSimpleAccess.cs - diff --git a/NTFSSecurity/NTFSSecurity.format.ps1xml b/NTFSSecurity/NTFSSecurity.format.ps1xml index c82769d..fbaba4c 100644 --- a/NTFSSecurity/NTFSSecurity.format.ps1xml +++ b/NTFSSecurity/NTFSSecurity.format.ps1xml @@ -146,7 +146,8 @@ - [Security2.FileSystemSecurity2]::ConvertToApplyTo($_.InheritanceFlags, $_.PropagationFlags) + [Security2.FileSystemSecurity2]::ConvertTo + ($_.InheritanceFlags, $_.PropagationFlags) diff --git a/NTFSSecurity/ShowSimpleAccess.Designer.cs b/NTFSSecurity/ShowSimpleAccess.Designer.cs deleted file mode 100644 index b189990..0000000 --- a/NTFSSecurity/ShowSimpleAccess.Designer.cs +++ /dev/null @@ -1,309 +0,0 @@ -namespace NTFSSecurity -{ - partial class ShowSimpleAccessForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShowSimpleAccessForm)); - this.trvDirectories = new System.Windows.Forms.TreeView(); - this.imlIcons = new System.Windows.Forms.ImageList(this.components); - this.lstPermissions = new System.Windows.Forms.ListView(); - this.chdIdentity = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chdRights = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chdAccessControlType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chkRemoveFoldersWithoutAccess = new System.Windows.Forms.CheckBox(); - this.grpFilter = new System.Windows.Forms.GroupBox(); - this.grpSearchForIdentity = new System.Windows.Forms.GroupBox(); - this.btnSearchForIdentityNext = new System.Windows.Forms.Button(); - this.btnSearchForIdentityPrev = new System.Windows.Forms.Button(); - this.txtSearchForIdentity = new System.Windows.Forms.TextBox(); - this.btnSearchForIdentity = new System.Windows.Forms.Button(); - this.grpSearchForFolder = new System.Windows.Forms.GroupBox(); - this.btnSearchForFolderPrev = new System.Windows.Forms.Button(); - this.btnSearchForFolderNext = new System.Windows.Forms.Button(); - this.btnSearchForFolder = new System.Windows.Forms.Button(); - this.txtSearchForFolder = new System.Windows.Forms.TextBox(); - this.labDirectoryTreeView = new System.Windows.Forms.Label(); - this.labAccessView = new System.Windows.Forms.Label(); - this.ttSearchForFolder = new System.Windows.Forms.ToolTip(this.components); - this.grpFilter.SuspendLayout(); - this.grpSearchForIdentity.SuspendLayout(); - this.grpSearchForFolder.SuspendLayout(); - this.SuspendLayout(); - // - // trvDirectories - // - this.trvDirectories.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.trvDirectories.ImageIndex = 0; - this.trvDirectories.ImageList = this.imlIcons; - this.trvDirectories.Location = new System.Drawing.Point(12, 29); - this.trvDirectories.Name = "trvDirectories"; - this.trvDirectories.SelectedImageIndex = 0; - this.trvDirectories.Size = new System.Drawing.Size(320, 574); - this.trvDirectories.TabIndex = 0; - this.trvDirectories.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.trvDirectories_AfterSelect); - // - // imlIcons - // - this.imlIcons.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imlIcons.ImageStream"))); - this.imlIcons.TransparentColor = System.Drawing.Color.Transparent; - this.imlIcons.Images.SetKeyName(0, "container.jpg"); - // - // lstPermissions - // - this.lstPermissions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lstPermissions.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.chdIdentity, - this.chdRights, - this.chdAccessControlType}); - this.lstPermissions.Location = new System.Drawing.Point(338, 29); - this.lstPermissions.Name = "lstPermissions"; - this.lstPermissions.Size = new System.Drawing.Size(480, 342); - this.lstPermissions.SmallImageList = this.imlIcons; - this.lstPermissions.TabIndex = 1; - this.lstPermissions.UseCompatibleStateImageBehavior = false; - this.lstPermissions.View = System.Windows.Forms.View.Details; - // - // chdIdentity - // - this.chdIdentity.Text = "Identity"; - // - // chdRights - // - this.chdRights.Text = "Rights"; - // - // chdAccessControlType - // - this.chdAccessControlType.Text = "AccessControlType"; - // - // chkRemoveFoldersWithoutAccess - // - this.chkRemoveFoldersWithoutAccess.AutoSize = true; - this.chkRemoveFoldersWithoutAccess.Location = new System.Drawing.Point(6, 19); - this.chkRemoveFoldersWithoutAccess.Name = "chkRemoveFoldersWithoutAccess"; - this.chkRemoveFoldersWithoutAccess.Size = new System.Drawing.Size(347, 17); - this.chkRemoveFoldersWithoutAccess.TabIndex = 2; - this.chkRemoveFoldersWithoutAccess.Text = "Remove Folders that do not have different access than their parents"; - this.chkRemoveFoldersWithoutAccess.UseVisualStyleBackColor = true; - this.chkRemoveFoldersWithoutAccess.CheckedChanged += new System.EventHandler(this.chkRemoveFoldersWithoutAccess_CheckedChanged); - // - // grpFilter - // - this.grpFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.grpFilter.Controls.Add(this.grpSearchForIdentity); - this.grpFilter.Controls.Add(this.grpSearchForFolder); - this.grpFilter.Controls.Add(this.chkRemoveFoldersWithoutAccess); - this.grpFilter.Location = new System.Drawing.Point(338, 377); - this.grpFilter.Name = "grpFilter"; - this.grpFilter.Size = new System.Drawing.Size(480, 226); - this.grpFilter.TabIndex = 3; - this.grpFilter.TabStop = false; - this.grpFilter.Text = "Filter"; - // - // grpSearchForIdentity - // - this.grpSearchForIdentity.Controls.Add(this.btnSearchForIdentityNext); - this.grpSearchForIdentity.Controls.Add(this.btnSearchForIdentityPrev); - this.grpSearchForIdentity.Controls.Add(this.txtSearchForIdentity); - this.grpSearchForIdentity.Controls.Add(this.btnSearchForIdentity); - this.grpSearchForIdentity.Location = new System.Drawing.Point(9, 125); - this.grpSearchForIdentity.Name = "grpSearchForIdentity"; - this.grpSearchForIdentity.Size = new System.Drawing.Size(384, 95); - this.grpSearchForIdentity.TabIndex = 4; - this.grpSearchForIdentity.TabStop = false; - this.grpSearchForIdentity.Text = "Search for Identity"; - // - // btnSearchForIdentityNext - // - this.btnSearchForIdentityNext.Enabled = false; - this.btnSearchForIdentityNext.Location = new System.Drawing.Point(222, 45); - this.btnSearchForIdentityNext.Name = "btnSearchForIdentityNext"; - this.btnSearchForIdentityNext.Size = new System.Drawing.Size(75, 23); - this.btnSearchForIdentityNext.TabIndex = 7; - this.btnSearchForIdentityNext.Text = "Prev"; - this.btnSearchForIdentityNext.UseVisualStyleBackColor = true; - this.btnSearchForIdentityNext.Click += new System.EventHandler(this.btnSearchForIdentityNext_Click); - // - // btnSearchForIdentityPrev - // - this.btnSearchForIdentityPrev.Enabled = false; - this.btnSearchForIdentityPrev.Location = new System.Drawing.Point(303, 45); - this.btnSearchForIdentityPrev.Name = "btnSearchForIdentityPrev"; - this.btnSearchForIdentityPrev.Size = new System.Drawing.Size(75, 23); - this.btnSearchForIdentityPrev.TabIndex = 6; - this.btnSearchForIdentityPrev.Text = "Next"; - this.btnSearchForIdentityPrev.UseVisualStyleBackColor = true; - this.btnSearchForIdentityPrev.Click += new System.EventHandler(this.btnSearchForIdentityPrev_Click); - // - // txtSearchForIdentity - // - this.txtSearchForIdentity.Location = new System.Drawing.Point(3, 19); - this.txtSearchForIdentity.Name = "txtSearchForIdentity"; - this.txtSearchForIdentity.Size = new System.Drawing.Size(341, 20); - this.txtSearchForIdentity.TabIndex = 4; - // - // btnSearchForIdentity - // - this.btnSearchForIdentity.Location = new System.Drawing.Point(350, 17); - this.btnSearchForIdentity.Name = "btnSearchForIdentity"; - this.btnSearchForIdentity.Size = new System.Drawing.Size(28, 23); - this.btnSearchForIdentity.TabIndex = 5; - this.btnSearchForIdentity.Text = "Go"; - this.btnSearchForIdentity.UseVisualStyleBackColor = true; - this.btnSearchForIdentity.Click += new System.EventHandler(this.btnSearchForIdentity_Click); - // - // grpSearchForFolder - // - this.grpSearchForFolder.Controls.Add(this.btnSearchForFolderPrev); - this.grpSearchForFolder.Controls.Add(this.btnSearchForFolderNext); - this.grpSearchForFolder.Controls.Add(this.btnSearchForFolder); - this.grpSearchForFolder.Controls.Add(this.txtSearchForFolder); - this.grpSearchForFolder.Location = new System.Drawing.Point(6, 42); - this.grpSearchForFolder.Name = "grpSearchForFolder"; - this.grpSearchForFolder.Size = new System.Drawing.Size(387, 77); - this.grpSearchForFolder.TabIndex = 3; - this.grpSearchForFolder.TabStop = false; - this.grpSearchForFolder.Text = "Search for Folder"; - this.ttSearchForFolder.SetToolTip(this.grpSearchForFolder, "\"Search for folder\" lets you search in the tree view for the"); - // - // btnSearchForFolderPrev - // - this.btnSearchForFolderPrev.Enabled = false; - this.btnSearchForFolderPrev.Location = new System.Drawing.Point(225, 45); - this.btnSearchForFolderPrev.Name = "btnSearchForFolderPrev"; - this.btnSearchForFolderPrev.Size = new System.Drawing.Size(75, 23); - this.btnSearchForFolderPrev.TabIndex = 3; - this.btnSearchForFolderPrev.Text = "Prev"; - this.btnSearchForFolderPrev.UseVisualStyleBackColor = true; - this.btnSearchForFolderPrev.Click += new System.EventHandler(this.btnSearchForFolderPrev_Click); - // - // btnSearchForFolderNext - // - this.btnSearchForFolderNext.Enabled = false; - this.btnSearchForFolderNext.Location = new System.Drawing.Point(306, 45); - this.btnSearchForFolderNext.Name = "btnSearchForFolderNext"; - this.btnSearchForFolderNext.Size = new System.Drawing.Size(75, 23); - this.btnSearchForFolderNext.TabIndex = 2; - this.btnSearchForFolderNext.Text = "Next"; - this.btnSearchForFolderNext.UseVisualStyleBackColor = true; - this.btnSearchForFolderNext.Click += new System.EventHandler(this.btnSearchForFolderNext_Click); - // - // btnSearchForFolder - // - this.btnSearchForFolder.Location = new System.Drawing.Point(353, 17); - this.btnSearchForFolder.Name = "btnSearchForFolder"; - this.btnSearchForFolder.Size = new System.Drawing.Size(28, 23); - this.btnSearchForFolder.TabIndex = 1; - this.btnSearchForFolder.Text = "Go"; - this.btnSearchForFolder.UseVisualStyleBackColor = true; - this.btnSearchForFolder.Click += new System.EventHandler(this.btnSearchForFolder_Click); - // - // txtSearchForFolder - // - this.txtSearchForFolder.Location = new System.Drawing.Point(6, 19); - this.txtSearchForFolder.Name = "txtSearchForFolder"; - this.txtSearchForFolder.Size = new System.Drawing.Size(341, 20); - this.txtSearchForFolder.TabIndex = 0; - this.ttSearchForFolder.SetToolTip(this.txtSearchForFolder, "\"Search for folder\" lets you search in the tree view for the"); - // - // labDirectoryTreeView - // - this.labDirectoryTreeView.AutoSize = true; - this.labDirectoryTreeView.Location = new System.Drawing.Point(13, 13); - this.labDirectoryTreeView.Name = "labDirectoryTreeView"; - this.labDirectoryTreeView.Size = new System.Drawing.Size(57, 13); - this.labDirectoryTreeView.TabIndex = 4; - this.labDirectoryTreeView.Text = "Directories"; - // - // labAccessView - // - this.labAccessView.AutoSize = true; - this.labAccessView.Location = new System.Drawing.Point(344, 12); - this.labAccessView.Name = "labAccessView"; - this.labAccessView.Size = new System.Drawing.Size(202, 13); - this.labAccessView.TabIndex = 5; - this.labAccessView.Text = "Permissions given on the seletcted object"; - // - // ttSearchForFolder - // - this.ttSearchForFolder.IsBalloon = true; - this.ttSearchForFolder.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info; - // - // ShowSimpleAccessForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(830, 615); - this.Controls.Add(this.labAccessView); - this.Controls.Add(this.labDirectoryTreeView); - this.Controls.Add(this.grpFilter); - this.Controls.Add(this.lstPermissions); - this.Controls.Add(this.trvDirectories); - this.Name = "ShowSimpleAccessForm"; - this.Text = "ShowAccess"; - this.grpFilter.ResumeLayout(false); - this.grpFilter.PerformLayout(); - this.grpSearchForIdentity.ResumeLayout(false); - this.grpSearchForIdentity.PerformLayout(); - this.grpSearchForFolder.ResumeLayout(false); - this.grpSearchForFolder.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TreeView trvDirectories; - private System.Windows.Forms.ListView lstPermissions; - private System.Windows.Forms.ColumnHeader chdIdentity; - private System.Windows.Forms.ColumnHeader chdRights; - private System.Windows.Forms.ColumnHeader chdAccessControlType; - private System.Windows.Forms.ImageList imlIcons; - private System.Windows.Forms.CheckBox chkRemoveFoldersWithoutAccess; - private System.Windows.Forms.GroupBox grpFilter; - private System.Windows.Forms.Label labDirectoryTreeView; - private System.Windows.Forms.Label labAccessView; - private System.Windows.Forms.GroupBox grpSearchForFolder; - private System.Windows.Forms.Button btnSearchForFolder; - private System.Windows.Forms.TextBox txtSearchForFolder; - private System.Windows.Forms.Button btnSearchForFolderNext; - private System.Windows.Forms.Button btnSearchForFolderPrev; - private System.Windows.Forms.GroupBox grpSearchForIdentity; - private System.Windows.Forms.Button btnSearchForIdentityNext; - private System.Windows.Forms.Button btnSearchForIdentityPrev; - private System.Windows.Forms.TextBox txtSearchForIdentity; - private System.Windows.Forms.Button btnSearchForIdentity; - private System.Windows.Forms.ToolTip ttSearchForFolder; - - } -} \ No newline at end of file diff --git a/NTFSSecurity/ShowSimpleAccess.cs b/NTFSSecurity/ShowSimpleAccess.cs deleted file mode 100644 index 5dcf43d..0000000 --- a/NTFSSecurity/ShowSimpleAccess.cs +++ /dev/null @@ -1,271 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using Alphaleonis.Win32.Filesystem; -using Security2; - -namespace NTFSSecurity -{ - public partial class ShowSimpleAccessForm : Form - { - private IEnumerable directoryList; - private IQueryable aceList; - private IEnumerable searchResultByFolder; - private int searchResultByFolderIndex; - - public IEnumerable DirectoryList - { - get { return directoryList; } - } - - public IEnumerable AceList - { - get { return aceList; } - } - - public ShowSimpleAccessForm() - { - InitializeComponent(); - } - - public void BuildDirectoryTreeNodes() - { - string previousPath = string.Empty; - DirectoryTreeNode previousNode; - DirectoryTreeNode rootNode; - - var rootDirectory = directoryList.First(); - - rootNode = new DirectoryTreeNode(rootDirectory.FullName, rootDirectory.Name, aceList.Where(ace => ace.FullName == rootDirectory.Name)); - previousNode = rootNode; - trvDirectories.Nodes.Add(rootNode); - - foreach (var directory in directoryList.Skip(1)) - { - if (previousNode.Name == directory.GetParent().FullName) - { - var node = new DirectoryTreeNode(directory.FullName, directory.Name, aceList.Where(ace => ace.FullName == directory.FullName)); - previousNode.Nodes.Add(node); - } - else - { - previousNode = (DirectoryTreeNode)trvDirectories.Nodes.Find(directory.GetParent().FullName, true).FirstOrDefault(); - if (previousNode != null) - { - var node = new DirectoryTreeNode(directory.FullName, directory.Name, aceList.Where(ace => ace.FullName == directory.FullName)); - previousNode.Nodes.Add(node); - } - else - { - var node = new DirectoryTreeNode(directory.FullName, directory.Name, aceList.Where(ace => ace.FullName == directory.FullName)); - previousNode.Nodes.Add(node); - } - } - } - } - - public void BuildDirectoryTreeNodes(IEnumerable directoryList, IQueryable aceList) - { - this.directoryList = directoryList; - this.aceList = aceList; - - this.BuildDirectoryTreeNodes(); - } - - private void trvDirectories_AfterSelect(object sender, TreeViewEventArgs e) - { - lstPermissions.Items.Clear(); - - foreach (var ace in aceList.Where(ace => ace.FullName == e.Node.Name)) - { - ListViewItem listItem = new ListViewItem(); - listItem.Name = e.Node.Name; - listItem.Text = ace.Identity.AccountName; - listItem.SubItems.AddRange(new string[] { ace.AccessRights.ToString(), ace.AccessControlType.ToString(), e.Node.FullPath }); - listItem.ImageIndex = 1; - - lstPermissions.Items.Add(listItem); - } - - if (lstPermissions.Items.Count > 0) - { - foreach (ColumnHeader column in lstPermissions.Columns) - { - column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); - } - } - } - - private void chkRemoveFoldersWithoutAccess_CheckedChanged(object sender, EventArgs e) - { - if (chkRemoveFoldersWithoutAccess.Checked) - { - RemoveFoldersWithoutAccess((DirectoryTreeNode)trvDirectories.Nodes[0]); - } - else - { - trvDirectories.Nodes.Clear(); - BuildDirectoryTreeNodes(); - } - } - - public void RemoveFoldersWithoutAccess(DirectoryTreeNode node) - { - for (int i = 0; i < node.Nodes.Count; i++) - { - if (node.Nodes[i].GetNodeCount(false) > 0) - RemoveFoldersWithoutAccess((DirectoryTreeNode)node.Nodes[i]); - - if (node.Nodes[i].Nodes.Count == 0 & ((DirectoryTreeNode)node.Nodes[i]).Acl.Count() == 0) - { - node.Nodes.Remove(node.Nodes[i]); - i--; - } - } - } - - private void btnSearchForFolder_Click(object sender, EventArgs e) - { - searchResultByFolder = null; - searchResultByFolderIndex = 0; - trvDirectories.HideSelection = false; - - searchResultByFolder = FindNodeByFolder((DirectoryTreeNode)trvDirectories.Nodes[0], txtSearchForFolder.Text); - if (searchResultByFolder.Count() > 0) - { - btnSearchForFolderNext.Enabled = true; - btnSearchForFolderPrev.Enabled = true; - - trvDirectories.SelectedNode = searchResultByFolder.First(); - searchResultByFolderIndex = 0; - } - else - { - btnSearchForFolderNext.Enabled = false; - btnSearchForFolderPrev.Enabled = false; - } - } - - private IEnumerable FindNodeByFolder(DirectoryTreeNode node, string search) - { - if (node.Text.ToLower().Contains(search.ToLower())) - { - yield return node; - } - - foreach (DirectoryTreeNode childNode in node.Nodes) - { - foreach (DirectoryTreeNode match in this.FindNodeByFolder(childNode, search)) - { - yield return match; - } - } - } - - private IEnumerable FindNodeByIdentity(DirectoryTreeNode node, string search) - { - if (node.Acl.Where(ace => ace.Identity.AccountName.ToLower().Contains(search.ToLower())).Count() > 0) - { - yield return node; - } - - foreach (DirectoryTreeNode childNode in node.Nodes) - { - foreach (DirectoryTreeNode match in this.FindNodeByIdentity(childNode, search)) - { - yield return match; - } - } - } - - private void btnSearchForFolderNext_Click(object sender, EventArgs e) - { - if (searchResultByFolder.Count() > searchResultByFolderIndex + 1) - { - searchResultByFolderIndex++; - trvDirectories.SelectedNode = searchResultByFolder.ElementAt(searchResultByFolderIndex); - } - } - - private void btnSearchForFolderPrev_Click(object sender, EventArgs e) - { - if (searchResultByFolderIndex - 1 > -1) - { - searchResultByFolderIndex--; - trvDirectories.SelectedNode = searchResultByFolder.ElementAt(searchResultByFolderIndex); - } - } - - private void btnSearchForIdentity_Click(object sender, EventArgs e) - { - trvDirectories.HideSelection = false; - searchResultByFolder = null; - searchResultByFolderIndex = 0; - - searchResultByFolder = FindNodeByIdentity((DirectoryTreeNode)trvDirectories.Nodes[0], txtSearchForIdentity.Text); - if (searchResultByFolder.Count() > 0) - { - btnSearchForIdentityNext.Enabled = true; - btnSearchForIdentityPrev.Enabled = true; - - trvDirectories.SelectedNode = searchResultByFolder.First(); - searchResultByFolderIndex = 0; - } - else - { - btnSearchForIdentityNext.Enabled = false; - btnSearchForIdentityPrev.Enabled = false; - } - } - - private void btnSearchForIdentityPrev_Click(object sender, EventArgs e) - { - if (searchResultByFolder.Count() > searchResultByFolderIndex + 1) - { - searchResultByFolderIndex++; - trvDirectories.SelectedNode = searchResultByFolder.ElementAt(searchResultByFolderIndex); - } - } - - private void btnSearchForIdentityNext_Click(object sender, EventArgs e) - { - if (searchResultByFolderIndex - 1 > -1) - { - searchResultByFolderIndex--; - trvDirectories.SelectedNode = searchResultByFolder.ElementAt(searchResultByFolderIndex); - } - } - } - - public class DirectoryTreeNode : TreeNode - { - private IList acl; - - public IList Acl - { - get { return acl; } - } - - public DirectoryTreeNode(string key, string text) - : base(text) - { - this.Name = key; - } - - public DirectoryTreeNode(string key, string text, IQueryable acl) - : this(key, text) - { - this.acl = acl.ToList(); - - if (acl.Count() == 0) - { - this.ForeColor = Color.Gray; - } - } - } -} \ No newline at end of file diff --git a/NTFSSecurity/ShowSimpleAccess.resx b/NTFSSecurity/ShowSimpleAccess.resx deleted file mode 100644 index d30058d..0000000 --- a/NTFSSecurity/ShowSimpleAccess.resx +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w - LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 - ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAs - CAAAAk1TRnQBSQFMAwEBAAGIAQABiAEAARABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA - AUADAAEQAwABAQEAAQgGAAEEGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEA - AfABygGmAQABMwUAATMBAAEzAQABMwEAAjMCAAMW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BPcDkgL3AZIB9wHyAf8wAAH/Ae8LFAEPAQcB/zAAAf8B7AGZAnkBHAF5ARwBWAEcAXkBHAFzAUMBBwH/ - MAAB/wHtAfQEeQFeAZkBXgJ5ARwBQwEHAf8wAAH/Ae0BwwN5AV4BmQFeAZkBXgF5AVgBQwEHAf8wAAH/ - Ae0B9AJ5AV0BmQFeAbwBXgGZAV4B9wFDAQcB/zAAAf8B7QHDAXoCeQFeAZkBXgGZAV4BeQFYAUMBBwH/ - MAAB/wHtAfQEeQFeAZkBXgJ5ARwBQwEHAf8wAAH/Ae0BwwOgAeUBGgHlARoB5QEaAXkBQwEHAf8wAAH/ - Ae0BGwGgAcMBGgGgARsEBwH3AewB8QH/MAAB/wG8ARwEeQH3AvABvALwAfMC/zAAAv8BvAHtAnMB7QHw - CP8wAAP/BPQJ/zAAEP8wAAFCAU0BPgcAAT4DAAEoAwABQAMAARADAAEBAQABAQUAAYAXAAP/gQAL - - - - 114, 17 - - \ No newline at end of file diff --git a/NTFSSecurity/ShowSimpleEffectiveAccess.Designer.cs b/NTFSSecurity/ShowSimpleEffectiveAccess.Designer.cs deleted file mode 100644 index 05076e9..0000000 --- a/NTFSSecurity/ShowSimpleEffectiveAccess.Designer.cs +++ /dev/null @@ -1,234 +0,0 @@ -namespace NTFSSecurity -{ - partial class ShowSimpleEffectiveAccessForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShowSimpleEffectiveAccessForm)); - this.trvDirectories = new System.Windows.Forms.TreeView(); - this.imlIcons = new System.Windows.Forms.ImageList(this.components); - this.lstPermissions = new System.Windows.Forms.ListView(); - this.chdIdentity = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chdRights = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chdAccessControlType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.chkRemoveFoldersWithoutAccess = new System.Windows.Forms.CheckBox(); - this.grpFilter = new System.Windows.Forms.GroupBox(); - this.grpSearchForFolder = new System.Windows.Forms.GroupBox(); - this.btnSearchForFolderPrev = new System.Windows.Forms.Button(); - this.btnSearchForFolderNext = new System.Windows.Forms.Button(); - this.btnSearchForFolder = new System.Windows.Forms.Button(); - this.txtSearchForFolder = new System.Windows.Forms.TextBox(); - this.labDirectoryTreeView = new System.Windows.Forms.Label(); - this.labAccessView = new System.Windows.Forms.Label(); - this.grpFilter.SuspendLayout(); - this.grpSearchForFolder.SuspendLayout(); - this.SuspendLayout(); - // - // trvDirectories - // - this.trvDirectories.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.trvDirectories.ImageIndex = 0; - this.trvDirectories.ImageList = this.imlIcons; - this.trvDirectories.Location = new System.Drawing.Point(12, 29); - this.trvDirectories.Name = "trvDirectories"; - this.trvDirectories.SelectedImageIndex = 0; - this.trvDirectories.Size = new System.Drawing.Size(320, 353); - this.trvDirectories.TabIndex = 0; - this.trvDirectories.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.trvDirectories_AfterSelect); - // - // imlIcons - // - this.imlIcons.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imlIcons.ImageStream"))); - this.imlIcons.TransparentColor = System.Drawing.Color.Transparent; - this.imlIcons.Images.SetKeyName(0, "container.jpg"); - // - // lstPermissions - // - this.lstPermissions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lstPermissions.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.chdIdentity, - this.chdRights, - this.chdAccessControlType}); - this.lstPermissions.Location = new System.Drawing.Point(338, 29); - this.lstPermissions.Name = "lstPermissions"; - this.lstPermissions.Size = new System.Drawing.Size(480, 226); - this.lstPermissions.SmallImageList = this.imlIcons; - this.lstPermissions.TabIndex = 1; - this.lstPermissions.UseCompatibleStateImageBehavior = false; - this.lstPermissions.View = System.Windows.Forms.View.Details; - // - // chdIdentity - // - this.chdIdentity.Text = "Identity"; - // - // chdRights - // - this.chdRights.Text = "Rights"; - // - // chdAccessControlType - // - this.chdAccessControlType.Text = "AccessControlType"; - // - // chkRemoveFoldersWithoutAccess - // - this.chkRemoveFoldersWithoutAccess.AutoSize = true; - this.chkRemoveFoldersWithoutAccess.Location = new System.Drawing.Point(6, 19); - this.chkRemoveFoldersWithoutAccess.Name = "chkRemoveFoldersWithoutAccess"; - this.chkRemoveFoldersWithoutAccess.Size = new System.Drawing.Size(347, 17); - this.chkRemoveFoldersWithoutAccess.TabIndex = 2; - this.chkRemoveFoldersWithoutAccess.Text = "Remove Folders that do not have different access than their parents"; - this.chkRemoveFoldersWithoutAccess.UseVisualStyleBackColor = true; - this.chkRemoveFoldersWithoutAccess.CheckedChanged += new System.EventHandler(this.chkRemoveFoldersWithoutAccess_CheckedChanged); - // - // grpFilter - // - this.grpFilter.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.grpFilter.Controls.Add(this.grpSearchForFolder); - this.grpFilter.Controls.Add(this.chkRemoveFoldersWithoutAccess); - this.grpFilter.Location = new System.Drawing.Point(338, 258); - this.grpFilter.Name = "grpFilter"; - this.grpFilter.Size = new System.Drawing.Size(480, 124); - this.grpFilter.TabIndex = 3; - this.grpFilter.TabStop = false; - this.grpFilter.Text = "Filter"; - // - // grpSearchForFolder - // - this.grpSearchForFolder.Controls.Add(this.btnSearchForFolderPrev); - this.grpSearchForFolder.Controls.Add(this.btnSearchForFolderNext); - this.grpSearchForFolder.Controls.Add(this.btnSearchForFolder); - this.grpSearchForFolder.Controls.Add(this.txtSearchForFolder); - this.grpSearchForFolder.Location = new System.Drawing.Point(6, 42); - this.grpSearchForFolder.Name = "grpSearchForFolder"; - this.grpSearchForFolder.Size = new System.Drawing.Size(421, 77); - this.grpSearchForFolder.TabIndex = 3; - this.grpSearchForFolder.TabStop = false; - this.grpSearchForFolder.Text = "Search for Folder"; - // - // btnSearchForFolderPrev - // - this.btnSearchForFolderPrev.Enabled = false; - this.btnSearchForFolderPrev.Location = new System.Drawing.Point(240, 45); - this.btnSearchForFolderPrev.Name = "btnSearchForFolderPrev"; - this.btnSearchForFolderPrev.Size = new System.Drawing.Size(75, 23); - this.btnSearchForFolderPrev.TabIndex = 3; - this.btnSearchForFolderPrev.Text = "Prev"; - this.btnSearchForFolderPrev.UseVisualStyleBackColor = true; - this.btnSearchForFolderPrev.Click += new System.EventHandler(this.btnSearchForFolderPrev_Click); - // - // btnSearchForFolderNext - // - this.btnSearchForFolderNext.Enabled = false; - this.btnSearchForFolderNext.Location = new System.Drawing.Point(321, 45); - this.btnSearchForFolderNext.Name = "btnSearchForFolderNext"; - this.btnSearchForFolderNext.Size = new System.Drawing.Size(75, 23); - this.btnSearchForFolderNext.TabIndex = 2; - this.btnSearchForFolderNext.Text = "Next"; - this.btnSearchForFolderNext.UseVisualStyleBackColor = true; - this.btnSearchForFolderNext.Click += new System.EventHandler(this.btnSearchForFolderNext_Click); - // - // btnSearchForFolder - // - this.btnSearchForFolder.Location = new System.Drawing.Point(353, 17); - this.btnSearchForFolder.Name = "btnSearchForFolder"; - this.btnSearchForFolder.Size = new System.Drawing.Size(43, 23); - this.btnSearchForFolder.TabIndex = 1; - this.btnSearchForFolder.Text = "Go"; - this.btnSearchForFolder.UseVisualStyleBackColor = true; - this.btnSearchForFolder.Click += new System.EventHandler(this.btnSearchForFolder_Click); - // - // txtSearchForFolder - // - this.txtSearchForFolder.Location = new System.Drawing.Point(6, 19); - this.txtSearchForFolder.Name = "txtSearchForFolder"; - this.txtSearchForFolder.Size = new System.Drawing.Size(341, 20); - this.txtSearchForFolder.TabIndex = 0; - // - // labDirectoryTreeView - // - this.labDirectoryTreeView.AutoSize = true; - this.labDirectoryTreeView.Location = new System.Drawing.Point(13, 13); - this.labDirectoryTreeView.Name = "labDirectoryTreeView"; - this.labDirectoryTreeView.Size = new System.Drawing.Size(57, 13); - this.labDirectoryTreeView.TabIndex = 4; - this.labDirectoryTreeView.Text = "Directories"; - // - // labAccessView - // - this.labAccessView.AutoSize = true; - this.labAccessView.Location = new System.Drawing.Point(344, 12); - this.labAccessView.Name = "labAccessView"; - this.labAccessView.Size = new System.Drawing.Size(202, 13); - this.labAccessView.TabIndex = 5; - this.labAccessView.Text = "Permissions given on the seletcted object"; - // - // ShowSimpleEffectiveAccessForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(830, 389); - this.Controls.Add(this.labAccessView); - this.Controls.Add(this.labDirectoryTreeView); - this.Controls.Add(this.grpFilter); - this.Controls.Add(this.lstPermissions); - this.Controls.Add(this.trvDirectories); - this.Name = "ShowSimpleEffectiveAccessForm"; - this.Text = "ShowAccess"; - this.grpFilter.ResumeLayout(false); - this.grpFilter.PerformLayout(); - this.grpSearchForFolder.ResumeLayout(false); - this.grpSearchForFolder.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TreeView trvDirectories; - private System.Windows.Forms.ListView lstPermissions; - private System.Windows.Forms.ColumnHeader chdIdentity; - private System.Windows.Forms.ColumnHeader chdRights; - private System.Windows.Forms.ColumnHeader chdAccessControlType; - private System.Windows.Forms.ImageList imlIcons; - private System.Windows.Forms.CheckBox chkRemoveFoldersWithoutAccess; - private System.Windows.Forms.GroupBox grpFilter; - private System.Windows.Forms.Label labDirectoryTreeView; - private System.Windows.Forms.Label labAccessView; - private System.Windows.Forms.GroupBox grpSearchForFolder; - private System.Windows.Forms.Button btnSearchForFolder; - private System.Windows.Forms.TextBox txtSearchForFolder; - private System.Windows.Forms.Button btnSearchForFolderNext; - private System.Windows.Forms.Button btnSearchForFolderPrev; - - } -} \ No newline at end of file diff --git a/NTFSSecurity/ShowSimpleEffectiveAccess.cs b/NTFSSecurity/ShowSimpleEffectiveAccess.cs deleted file mode 100644 index 751b34d..0000000 --- a/NTFSSecurity/ShowSimpleEffectiveAccess.cs +++ /dev/null @@ -1,222 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using System.IO; -using Security2; - -namespace NTFSSecurity -{ - public partial class ShowSimpleEffectiveAccessForm : Form - { - private IEnumerable directoryList; - private IQueryable aceList; - private IEnumerable searchResultByFolder; - private int searchResultByFolderIndex; - - public IEnumerable DirectoryList - { - get { return directoryList; } - } - - public IEnumerable AceList - { - get { return aceList; } - } - - public ShowSimpleEffectiveAccessForm() - { - InitializeComponent(); - } - - public void BuildDirectoryTreeNodes() - { - string previousPath = string.Empty; - DirectoryTreeNode previousNode; - DirectoryTreeNode rootNode; - - var rootDirectory = directoryList.First(); - - rootNode = new DirectoryTreeNode(rootDirectory.FullName, rootDirectory.Name, aceList.Where(ace => ace.FullName == rootDirectory.Name)); - previousNode = rootNode; - trvDirectories.Nodes.Add(rootNode); - - foreach (var directory in directoryList.Skip(1)) - { - if (previousNode.Name == directory.GetParent().FullName) - { - var node = new DirectoryTreeNode(directory.FullName, directory.Name, aceList.Where(ace => ace.FullName == directory.FullName)); - previousNode.Nodes.Add(node); - } - else - { - previousNode = (DirectoryTreeNode)trvDirectories.Nodes.Find(directory.GetParent().FullName, true).FirstOrDefault(); - if (previousNode != null) - { - var node = new DirectoryTreeNode(directory.FullName, directory.Name, aceList.Where(ace => ace.FullName == directory.FullName)); - previousNode.Nodes.Add(node); - } - else - { - var node = new DirectoryTreeNode(directory.FullName, directory.Name, aceList.Where(ace => ace.FullName == directory.FullName)); - previousNode.Nodes.Add(node); - } - } - } - } - - public void BuildDirectoryTreeNodes(IEnumerable directoryList, IQueryable aceList) - { - this.directoryList = directoryList; - this.aceList = aceList; - - this.BuildDirectoryTreeNodes(); - } - - private void trvDirectories_AfterSelect(object sender, TreeViewEventArgs e) - { - lstPermissions.Items.Clear(); - - foreach (var ace in aceList.Where(ace => ace.FullName == e.Node.Name)) - { - ListViewItem listItem = new ListViewItem(); - listItem.Name = e.Node.Name; - listItem.Text = ace.Identity.AccountName; - listItem.SubItems.AddRange(new string[] { ace.AccessRights.ToString(), ace.AccessControlType.ToString(), e.Node.FullPath }); - listItem.ImageIndex = 1; - - lstPermissions.Items.Add(listItem); - } - - if (lstPermissions.Items.Count > 0) - { - foreach (ColumnHeader column in lstPermissions.Columns) - { - column.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); - } - } - } - - private void chkRemoveFoldersWithoutAccess_CheckedChanged(object sender, EventArgs e) - { - if (chkRemoveFoldersWithoutAccess.Checked) - { - RemoveFoldersWithoutAccess((DirectoryTreeNode)trvDirectories.Nodes[0]); - } - else - { - trvDirectories.Nodes.Clear(); - BuildDirectoryTreeNodes(); - } - } - - public void RemoveFoldersWithoutAccess(DirectoryTreeNode node) - { - for (int i = 0; i < node.Nodes.Count; i++) - { - if (node.Nodes[i].GetNodeCount(false) > 0) - RemoveFoldersWithoutAccess((DirectoryTreeNode)node.Nodes[i]); - - if (node.Nodes[i].Nodes.Count == 0 & ((DirectoryTreeNode)node.Nodes[i]).Acl.Count() == 0) - { - node.Nodes.Remove(node.Nodes[i]); - i--; - } - } - } - - private void btnSearchForFolder_Click(object sender, EventArgs e) - { - searchResultByFolder = null; - searchResultByFolderIndex = 0; - trvDirectories.HideSelection = false; - - searchResultByFolder = FindNodeByFolder((DirectoryTreeNode)trvDirectories.Nodes[0], txtSearchForFolder.Text); - if (searchResultByFolder.Count() > 0) - { - btnSearchForFolderNext.Enabled = true; - btnSearchForFolderPrev.Enabled = true; - - trvDirectories.SelectedNode = searchResultByFolder.First(); - searchResultByFolderIndex = 0; - } - else - { - btnSearchForFolderNext.Enabled = false; - btnSearchForFolderPrev.Enabled = false; - } - } - - private IEnumerable FindNodeByFolder(DirectoryTreeNode node, string search) - { - if (node.Text.ToLower().Contains(search.ToLower())) - { - yield return node; - } - - foreach (DirectoryTreeNode childNode in node.Nodes) - { - foreach (DirectoryTreeNode match in this.FindNodeByFolder(childNode, search)) - { - yield return match; - } - } - } - - private IEnumerable FindNodeByIdentity(DirectoryTreeNode node, string search) - { - if (node.Acl.Where(ace => ace.Identity.AccountName.ToLower().Contains(search.ToLower())).Count() > 0) - { - yield return node; - } - - foreach (DirectoryTreeNode childNode in node.Nodes) - { - foreach (DirectoryTreeNode match in this.FindNodeByIdentity(childNode, search)) - { - yield return match; - } - } - } - - private void btnSearchForFolderNext_Click(object sender, EventArgs e) - { - if (searchResultByFolder.Count() > searchResultByFolderIndex + 1) - { - searchResultByFolderIndex++; - trvDirectories.SelectedNode = searchResultByFolder.ElementAt(searchResultByFolderIndex); - } - } - - private void btnSearchForFolderPrev_Click(object sender, EventArgs e) - { - if (searchResultByFolderIndex - 1 > -1) - { - searchResultByFolderIndex--; - trvDirectories.SelectedNode = searchResultByFolder.ElementAt(searchResultByFolderIndex); - } - } - - private void btnSearchForIdentityPrev_Click(object sender, EventArgs e) - { - if (searchResultByFolder.Count() > searchResultByFolderIndex + 1) - { - searchResultByFolderIndex++; - trvDirectories.SelectedNode = searchResultByFolder.ElementAt(searchResultByFolderIndex); - } - } - - private void btnSearchForIdentityNext_Click(object sender, EventArgs e) - { - if (searchResultByFolderIndex - 1 > -1) - { - searchResultByFolderIndex--; - trvDirectories.SelectedNode = searchResultByFolder.ElementAt(searchResultByFolderIndex); - } - } - } -} \ No newline at end of file diff --git a/NTFSSecurity/ShowSimpleEffectiveAccess.resx b/NTFSSecurity/ShowSimpleEffectiveAccess.resx deleted file mode 100644 index 1c12697..0000000 --- a/NTFSSecurity/ShowSimpleEffectiveAccess.resx +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w - LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 - ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAs - CAAAAk1TRnQBSQFMAwEBAAGQAQABkAEAARABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA - AUADAAEQAwABAQEAAQgGAAEEGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEA - AfABygGmAQABMwUAATMBAAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANCAQADOQEA - AYABfAH/AQACUAH/AQABkwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ATMDAAFm - AwABmQMAAcwCAAEzAwACMwIAATMBZgIAATMBmQIAATMBzAIAATMB/wIAAWYDAAFmATM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9AJ5AV0BmQFeAbwBXgGZAV4B9wFDAQcB/zAAAf8B7QHDAXoCeQFeAZkBXgGZAV4BeQFYAUMBBwH/ - MAAB/wHtAfQEeQFeAZkBXgJ5ARwBQwEHAf8wAAH/Ae0BwwOgAeUBGgHlARoB5QEaAXkBQwEHAf8wAAH/ - Ae0BGwGgAcMBGgGgARsEBwH3AewB8QH/MAAB/wG8ARwEeQH3AvABvALwAfMC/zAAAv8BvAHtAnMB7QHw - CP8wAAP/BPQJ/zAAEP8wAAFCAU0BPgcAAT4DAAEoAwABQAMAARADAAEBAQABAQUAAYAXAAP/gQAL - - - \ No newline at end of file diff --git a/NTFSSecurity/SimpleAccessCmdlets/SimpleAccessCmdlets.cs b/NTFSSecurity/SimpleAccessCmdlets/SimpleAccessCmdlets.cs index c6251e6..123e04a 100644 --- a/NTFSSecurity/SimpleAccessCmdlets/SimpleAccessCmdlets.cs +++ b/NTFSSecurity/SimpleAccessCmdlets/SimpleAccessCmdlets.cs @@ -221,78 +221,5 @@ namespace NTFSSecurity //} //#endregion - #region Show-SimpleAccess - [Cmdlet(VerbsCommon.Show, "SimpleAccess")] - public class ShowSimpleAccess : GetSimpleAccess - { - Stopwatch stopwatch; - - protected override void BeginProcessing() - { - stopwatch = new Stopwatch(); - stopwatch.Start(); - - WriteDebug("Running Get-SimpleAccess"); - } - - protected override void ProcessRecord() - { - base.ProcessRecord(); - } - - protected override void EndProcessing() - { - stopwatch.Stop(); - WriteDebug(string.Format("Runtime of Get-SimpleAccess: {0}.", stopwatch.Elapsed.ToString())); - - stopwatch.Reset(); stopwatch.Start(); - WriteDebug("Creating TreeView"); - - ShowSimpleAccessForm form = new ShowSimpleAccessForm(); - form.BuildDirectoryTreeNodes(directoryList, aceList.AsQueryable()); - stopwatch.Stop(); - - WriteDebug(string.Format("Creating the Treeview took: {0}.", stopwatch.Elapsed.ToString())); - - form.ShowDialog(); - } - } - #endregion - - //#region Show-SimpleEffectiveAccess - //[Cmdlet(VerbsCommon.Show, "SimpleEffectiveAccess")] - //public class ShowSimpleEffectiveAccess : GetSimpleEffectiveAccess - //{ - // Stopwatch stopwatch; - - // protected override void BeginProcessing() - // { - // stopwatch = new Stopwatch(); - // stopwatch.Start(); - - // this.WriteDebug("Running Get-SimpleAccess"); - // } - // protected override void ProcessRecord() - // { - // base.ProcessRecord(); - // } - - // protected override void EndProcessing() - // { - // stopwatch.Stop(); - // this.WriteDebug(string.Format("Runtime of Get-SimpleAccess: {0}.", stopwatch.Elapsed.ToString())); - - // stopwatch.Reset(); stopwatch.Start(); - // this.WriteDebug("Creating TreeView"); - - // ShowSimpleEffectiveAccessForm form = new ShowSimpleEffectiveAccessForm(); - // form.BuildDirectoryTreeNodes(directoryList, aceList.AsQueryable()); - // stopwatch.Stop(); - - // this.WriteDebug(string.Format("Creating the Treeview took: {0}.", stopwatch.Elapsed.ToString())); - - // form.ShowDialog(); - // } - //} - //#endregion + } \ No newline at end of file