Browse Source

Work in progress

fix/#34
Raimund Andree 11 months ago
parent
commit
84fd251fa4
4 changed files with 39 additions and 8 deletions
  1. +8
    -1
      NTFSSecurity/Extensions.cs
  2. +1
    -1
      NTFSSecurity/NTFSSecurity.csproj
  3. +19
    -6
      Security2/FileSystem/FileSystemSecurity2.cs
  4. +11
    -0
      TestClient/Program.cs

+ 8
- 1
NTFSSecurity/Extensions.cs View File

@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.AccessControl;
using Alphaleonis.Win32.Filesystem;

namespace NTFSSecurity
@@ -52,5 +54,10 @@ namespace NTFSSecurity
throw new System.IO.FileNotFoundException();
}
}
}

public static List<T> GetListOfNames<T>(this Enum source)
{
return Enum.GetValues(typeof(T)).Cast<T>().ToList();
}
}
}

+ 1
- 1
NTFSSecurity/NTFSSecurity.csproj View File

@@ -23,7 +23,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\..\..\Program Files\WindowsPowerShell\Modules\NTFSSecurity\</OutputPath>
<OutputPath>..\..\..\..\Documents\WindowsPowerShell\Modules\NTFSSecurity\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>


+ 19
- 6
Security2/FileSystem/FileSystemSecurity2.cs View File

@@ -1,5 +1,6 @@
using Alphaleonis.Win32.Filesystem;
using System;
using System.Linq;
using System.Security.AccessControl;

namespace Security2
@@ -99,14 +100,26 @@ namespace Security2

public void Write()
{
if (isFile)
var values = Enum.GetValues(typeof(System.Security.AccessControl.AccessControlSections));
foreach (var value in values) //.Cast<string>().Where(v => v != "All" | v != "None"))
{
((FileInfo)item).SetAccessControl((FileSecurity)sd);
}
else
{
((DirectoryInfo)item).SetAccessControl((DirectorySecurity)sd);
try
{
if (isFile)
{
((FileInfo)item).SetAccessControl((FileSecurity)sd, (AccessControlSections)value);
}
else
{
((DirectoryInfo)item).SetAccessControl((DirectorySecurity)sd, (AccessControlSections)value);
}
}
catch
{
//Console.WriteLine("Exception {0} - {1}", item.FullName, value);
}
}
}

public void Write(FileSystemInfo item)


+ 11
- 0
TestClient/Program.cs View File

@@ -15,6 +15,17 @@ namespace TestClient
{
static void Main(string[] args)
{
//List<AccessControlSections> fileSystemRights = new List<AccessControlSections>();

//var values = Enum.GetValues(typeof(AccessControlSections)).Cast <AccessControlSections>().ToList();

//var v1 = values.Where(v => v == AccessControlSections.All).FirstOrDefault

var x = Enum.get




var item1 = new FileInfo("D:\\file1.txt");
var item2 = new DirectoryInfo("D:\\test3");
var account1 = new List<IdentityReference2>() { (IdentityReference2)@"raandree1\randr_000" };


Loading…
Cancel
Save