Sunday, 27 October 2013

Content

Ø  Unit 1-Intro to Troubleshooting Technique and Procedures
ü  Technique for solving problems
ü  Log Analysis
ü  Additional information gathering
ü  Runlevels
ü  Best practices
Ø  Unit 2-Common Troubleshooting Tools
ü  Advanced head and tail
ü  awk
ü  Syslog for logging
ü  Rebuilding the RPM Database
ü  Verifying with RPM
    

1 comment:

  1. using System.IO;
    using System.Security.AccessControl;
    using System.Security.Principal;

    private void Form1_Load(object sender, EventArgs e)
    {
    GetDirectorySecurity(@"c:\temp\", 1);
    }

    static void GetDirectorySecurity(string dir, int levels)
    {
    int curLevel = 1;
    string[] dirs = Directory.GetDirectories(dir);
    string strFileCont = string.Empty;
    foreach (string directory in dirs)
    {
    Console.WriteLine("---------------------------------------------------------");
    Console.WriteLine(directory);
    try
    {

    DirectoryInfo dInfo = new DirectoryInfo(directory);
    DirectorySecurity dSecurity = dInfo.GetAccessControl();
    AuthorizationRuleCollection acl = dSecurity.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
    foreach (FileSystemAccessRule ace in acl)
    {

    strFileCont = strFileCont + directory + "," + ace.IdentityReference.Value + "," + ace.AccessControlType + "," + ace.FileSystemRights + "," + ace.IsInherited.ToString() + Environment.NewLine;
    }
    if (curLevel < levels)
    GetDirectorySecurity(@directory, curLevel + 1, levels);
    }
    catch
    {
    }
    }

    FileStream fileStream = new FileStream(@"c:\temp\" + "File1.csv", FileMode.Create);
    fileStream.Close();
    TextWriter sw = new StreamWriter(@"c:\temp\" + "File1.csv");
    sw.WriteLine(strFileCont);
    sw.Close();
    }
    static void GetDirectorySecurity(string dir, int curLevel, int levels)
    {
    string[] dirs = Directory.GetDirectories(@dir);
    string tabs = "";
    for (int i = 0; i < curLevel; i++)
    tabs += "\t";
    foreach (string directory in dirs)
    {
    Console.WriteLine(tabs.Substring(0, tabs.Length - 1) + "---------------------------------------------------------");
    Console.WriteLine(tabs.Substring(0, tabs.Length - 1) + directory);
    try
    {
    DirectoryInfo dInfo = new DirectoryInfo(directory);
    DirectorySecurity dSecurity = dInfo.GetAccessControl();
    AuthorizationRuleCollection acl = dSecurity.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));
    foreach (FileSystemAccessRule ace in acl)
    {
    Console.WriteLine("{0}Account: {1}", tabs, ace.IdentityReference.Value);
    Console.WriteLine("{0}Type: {1}", tabs, ace.AccessControlType);
    Console.WriteLine("{0}Rights: {1}", tabs, ace.FileSystemRights);
    Console.WriteLine("{0}Inherited: {1}", tabs, ace.IsInherited);
    Console.WriteLine();
    }
    if (curLevel < levels)
    GetDirectorySecurity(@directory, curLevel + 1, levels);
    }
    catch
    {
    Console.WriteLine("Could not access {0}", directory);
    }
    }
    }

    ReplyDelete