Click here to Skip to main content
15,894,720 members
Home / Discussions / C#
   

C#

 
AnswerRe: I am making outlook add-ins and have question about it. Pin
fjdiewornncalwe17-Feb-11 13:18
professionalfjdiewornncalwe17-Feb-11 13:18 
GeneralRe: I am making outlook add-ins and have question about it. Pin
buffering8317-Feb-11 14:18
buffering8317-Feb-11 14:18 
Questionsraw method Pin
om_metab17-Feb-11 9:13
om_metab17-Feb-11 9:13 
AnswerRe: sraw method Pin
Henry Minute17-Feb-11 9:17
Henry Minute17-Feb-11 9:17 
AnswerRe: draw method Pin
Luc Pattyn17-Feb-11 9:22
sitebuilderLuc Pattyn17-Feb-11 9:22 
AnswerRe: sraw method Pin
Dalek Dave17-Feb-11 12:49
professionalDalek Dave17-Feb-11 12:49 
AnswerRe: sraw method Pin
RaviRanjanKr21-Feb-11 17:53
professionalRaviRanjanKr21-Feb-11 17:53 
QuestionHelp getting Sacl information from AllDirectories and Files. Pin
Twdeveloper17-Feb-11 7:42
Twdeveloper17-Feb-11 7:42 
Hello,

I have developed a Console App with CommandLine Args that can display and then remove SACLs from a user inputted Path.
Works great. However, the way I have it setup is that in only displays or removes the SACLS based on the Directory entered.
I need my code to enumerate the Directory and display information not only from the Directory, but also Subdirectories and Files in the directories.

Anyone have this code available or can point me in the right direction?

Thank You!

Here is some sample code of what I have done. Again, it reads in a Directory only. I need the Directory, SubDirectories, and files.

class Program
{

static void Main(string[] args)
{

try
{

if (args[0].ToUpper().Trim() == "SEARCH") // Displays all Sacls for path
{
Console.WriteLine("Enter your Directory path: ex. C:\\TestFolder");
string path = Console.ReadLine();
Console.WriteLine("{0}", path);

if (Directory.Exists(path))
{
Console.WriteLine(GetDirectoryAuditControlInformation(path));
}
else
{
Console.WriteLine("Path does not exist");
}

}

else if // argument for == CLEAN which removes all Sacls.
// my function for GetDirectoryAuditControlInformation(string path)

public static string GetDirectoryAuditControlInformation(string path)
{
StringBuilder info = new StringBuilder();
info.AppendLine("SACL entries for the path \ "" + path + "\":");
info.AppendLine();
DirectorySecurity dsecurity = Directory.GetAccessControl(path, AccessControlSections.Audit);
AuthorizationRuleCollection acl = dsecurity.GetAuditRules(true, true, typeof(System.Security.Principal.NTAccount));
foreach (FileSystemAuditRule ace in acl)
{
string aceInfo = GetAuditAceInformation(ace);
info.AppendLine(aceInfo);
}
return info.ToString();
}

public static string GetAuditInformation(FileSystemAuditRule ace)
{
StringBuilder info = new StringBuilder();
string line = string.Format("Account: {0}", ace.IdentityReference.Value);
info.AppendLine(line);
line = string.Format("Type: {0}", ace.AuditFlags);
info.AppendLine(line);
line = string.Format("Rights: {0}", ace.FileSystemRights);
info.AppendLine(line);
line = string.Format("Inherited ACE: {0}", ace.IsInherited);
info.AppendLine(line);
return info.ToString();
}
AnswerRe: Help getting Sacl information from AllDirectories and Files. Pin
Wendelius17-Feb-11 8:40
mentorWendelius17-Feb-11 8:40 
GeneralRe: Help getting Sacl information from AllDirectories and Files. Pin
#realJSOP17-Feb-11 9:41
mve#realJSOP17-Feb-11 9:41 
GeneralRe: Help getting Sacl information from AllDirectories and Files. Pin
Wendelius17-Feb-11 10:37
mentorWendelius17-Feb-11 10:37 
GeneralRe: Help getting Sacl information from AllDirectories and Files. Pin
Richard MacCutchan17-Feb-11 22:09
mveRichard MacCutchan17-Feb-11 22:09 
QuestionHelp with sendkey or postmessage Pin
turbosupramk317-Feb-11 5:00
turbosupramk317-Feb-11 5:00 
AnswerRe: Help with sendkey or postmessage Pin
musefan17-Feb-11 5:13
musefan17-Feb-11 5:13 
GeneralRe: Help with sendkey or postmessage Pin
turbosupramk317-Feb-11 5:37
turbosupramk317-Feb-11 5:37 
AnswerRe: Help with sendkey or postmessage [modified] Pin
musefan17-Feb-11 6:05
musefan17-Feb-11 6:05 
GeneralRe: Help with sendkey or postmessage Pin
musefan17-Feb-11 6:07
musefan17-Feb-11 6:07 
GeneralRe: Help with sendkey or postmessage Pin
turbosupramk317-Feb-11 7:25
turbosupramk317-Feb-11 7:25 
AnswerRe: Help with sendkey or postmessage Pin
Henry Minute17-Feb-11 6:26
Henry Minute17-Feb-11 6:26 
GeneralRe: Help with sendkey or postmessage Pin
turbosupramk317-Feb-11 7:19
turbosupramk317-Feb-11 7:19 
AnswerRe: Help with sendkey or postmessage Pin
Luc Pattyn17-Feb-11 7:39
sitebuilderLuc Pattyn17-Feb-11 7:39 
QuestionConstructing a class from a static function Pin
musefan17-Feb-11 1:37
musefan17-Feb-11 1:37 
AnswerRe: Constructing a class from a static function Pin
Xmen Real 17-Feb-11 1:45
professional Xmen Real 17-Feb-11 1:45 
GeneralRe: Constructing a class from a static function Pin
musefan17-Feb-11 2:08
musefan17-Feb-11 2:08 
GeneralRe: Constructing a class from a static function Pin
PIEBALDconsult17-Feb-11 4:27
mvePIEBALDconsult17-Feb-11 4:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.