Browse Source

Work in progress

fix/#34
Raimund Andree 2 years ago
parent
commit
84fd251fa4
  1. 9
      NTFSSecurity/Extensions.cs
  2. 2
      NTFSSecurity/NTFSSecurity.csproj
  3. 25
      Security2/FileSystem/FileSystemSecurity2.cs
  4. 11
      TestClient/Program.cs

9
NTFSSecurity/Extensions.cs

@ -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();
}
}
}

2
NTFSSecurity/NTFSSecurity.csproj

@ -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>

25
Security2/FileSystem/FileSystemSecurity2.cs

@ -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
TestClient/Program.cs

@ -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