Getting the Access Permissions for a specific SID on a File / folder

Getting the Access Permissions for a specific SID on a File / folder

Post by Mike Spik » Wed, 19 Jul 2006 20:06:37


HI all,

How do I go about getting the permmisions of a file.

I have been able to get a list of access control rules and tell if they are
restricting or permiting a permmision but I cant tell which role / right
they are refering to:

I can get this type information by using the fileSystemSecurity object and
pointing it to a file or folder:
---------------------------------
Administrator, allow, inhertited
Users, allow, inhereted
----------------------------------

But what I am aiming for is

---------------------------------
Administrator, allow Full Control, inhertited
Users, allow, read + Modify, inhereted
----------------------------------

I have looked through the classes in the security name space but I am not
sure which class I need to do this or if the class I am using will work.

Any help would be very welcome or even any external refrences.

By the way I am using VB.Net and the 2.0 framework.

Regards,

Mike
 
 
 

Getting the Access Permissions for a specific SID on a File / folder

Post by Dominick B » Thu, 20 Jul 2006 00:02:10

foreach (FileSystemAccessRule rule in security.GetAccessRules(true, true,
typeof(NTAccount)))
{
Console.WriteLine("{0} {1} access to {2}",
rule.AccessControlType == AccessControlType.Allow ?
"grant: " : "deny: ",
rule.FileSystemRights,
rule.IdentityReference.ToString());
SecurityIdentifier sid = (SecurityIdentifier)rule.IdentityReference.Translate(typeof(SecurityIdentifier));
Console.WriteLine(sid.Value);
}

 
 
 

Getting the Access Permissions for a specific SID on a File / folder

Post by msnews.mic » Thu, 20 Jul 2006 04:22:17

ThanksDominick,

This looks like C rather than vb I will see if can work out the VB
equivelents.

I am still learning the dotnet framework so, it might take me a while, will
post back if I can't work it out.

Regards,
Michael.

"Dominick Baier" < XXXX@XXXXX.COM > wrote in
 
 
 

Getting the Access Permissions for a specific SID on a File / folder

Post by msnews.mic » Thu, 20 Jul 2006 04:36:00

Hey Thanks agian Dominick,

rule.IdentityReference.ToString());

This was the bit I needed, I could get the account Name and if it was a
Grant or Deny, but did not see how to get the type of rule it was refering
to.

Michael.