Get list of groups-users-permissions-special permission for a folder in Windows 2003, programmatically

I am using a Window 2003 server and I need to get security folder information using C # programmatically.

I want to create an access control tool. I need to get groups, users, permissions and special permissions for the folder,

C: \ Documents and Settings \ All Users \ Application Data \ Microsoft \ Crypto \ RSA \ MachineKeys

edit:

The following is sample code for the GetSecurityDescriptorSddlForm method.

public static string GetObjectPermission(string fullFolderName) { FileSecurity fileSecure = File.GetAccessControl(fullFolderName); StringBuilder acer = new StringBuilder(); fileSecure.GetSecurityDescriptorSddlForm(AccessControlSections.All); foreach (FileSystemAccessRule ace in fileSecure.GetAccessRules(true, true, typeof(NTAccount))) { acer.Append(ace.FileSystemRights + ":" + ' ' + ace.IdentityReference.Value + "\n"); } return acer.ToString(); } 

This code example will show you which NTAccount can modify or read a folder, for example this function.

How can I get groups and special permissions?

Any sample code suggestions?

+7
security c # permissions ntfs
source share
1 answer

Could you use DirectoryInfo to get the ACL? All ACLs should be there (user, group):

  // Create a new DirectoryInfo object. DirectoryInfo dInfo = new DirectoryInfo(FileName); // Get a DirectorySecurity object that represents the // current security settings. DirectorySecurity dSecurity = dInfo.GetAccessControl(); 

Full documents: http://msdn.microsoft.com/en-us/library/c1f66bc2 (v = vs .110) .aspx

+2
source share

All Articles