{ 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(); |
Removing SACLS from SubDirectories and Files....
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét