I want to create a script that will Scan the Home folder directory looking at the folder permissions for each users Home folder. If the users permissions do not match to read/write only then write the account name and folder path to a log file.
I have only moderate knowledge in C# and would like to ask about how one would accomplish this task roughly.
--Thanks
IsaacPosted Apr 23, 2010, 12:58 PM
Try this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Security.AccessControl;
using System.Security.Principal;
namespace FolderPermissions
{
class Program
{
static void Main(string[] args)
{
DirectorySecurity dSecurity = Directory.GetAccessControl(@"c:\EmailParse");
foreach (FileSystemAccessRule rule in dSecurity.GetAccessRules(true, true, typeof(NTAccount)))
{
Console.WriteLine("Account:{0}\nRights:{1}", rule.IdentityReference.Value,
rule.FileSystemRights.ToString());
}
Console.ReadLine();
}
}
}
Shaun McLellanPosted Apr 23, 2010, 2:21 PM
Shaun McLellanPosted Apr 23, 2010, 2:01 PM