Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

show all FileSystemRights with C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
auldh - 24 Oct 2007 18:36 GMT
i have read internet and publish manuals.

i'm not able to get FileSystemRighs in C# to present to me all the
permissions so that i can display, capture and compare. when i do a
console.writeline({0}, rule.FileSystemRighs); i get a simple line:
Read&Execute.

yet if i step through the code i will get maybe 4 or more values. so the
question is how do i work with FileSystemRights to capture the complete
permissions string for me to do what ever to?

here is a sample of code:
       static void PrintACE(FileSystemAccessRule rule)
       {
           Console.WriteLine("{0}  {1} to {2}  ({3})",
               AccessControlType.Allow == rule.AccessControlType ? "Grant"
: "Deny",
               rule.FileSystemRights,
               rule.IdentityReference,
               rule.IsInherited ? "Inherited" : "Direct");
       }

here is the output of one user:
ReadAndExecute, Synchronize

what i see in debug mode:
rule.FileSystemRights = ReadData | ReadExtendedAttributes | ExecuteFile |
ReadAttributes | ReadPermissions | Synchronize

thanks.
herb
Willy Denoyette [MVP] - 24 Oct 2007 21:42 GMT
>i have read internet and publish manuals.
>
[quoted text clipped - 27 lines]
> thanks.
> herb

ReadAndExecute is the "unification" of a couple of other accessrights
(ReadData, ReadExtendedAttributes,| ExecuteFile, ReadAttributes and
ReadPermissions ), take a look at the FileSystemRights  enum you'll
understand which ones.

If you need each individual right from the FileSystemRights value then
you'll have to parse the value back into it's individual values.

Willy.
auldh - 24 Oct 2007 23:13 GMT
Willy,
that is what i want to do. is that a matter or running it throught
"switch/case" what is the best way to parse it correctly?

i see tons of inputs about how to modify, add and delete but nothing to
iterate the output of FileSystemRights. can you help?

> >i have read internet and publish manuals.
> >
[quoted text clipped - 37 lines]
>
> Willy.
Willy Denoyette [MVP] - 25 Oct 2007 16:42 GMT
If you really need to parse all individual bits you'll have to loop through
the enum values, sure there are different ways to do this, following
illustrates one possibility:

static void PrintACE(FileSystemAccessRule rule)
{
  foreach (string right in Enum.GetNames(typeof(FileSystemRights)))
  {
   int val = Convert.ToInt32(Enum.Parse(typeof(FileSystemRights), right));
   // remove combined values
   if((val != 0x1f01ff) && (val != 0x301bf) && (val != 0x20089) && (val !=
0x200a9) && (val != 0x116))
    {
    if(((int)rule.FileSystemRights & val) > 0)
     Console.WriteLine("{0} ", right);
   }
  }
}

Willy.

> Willy,
> that is what i want to do. is that a matter or running it throught
[quoted text clipped - 47 lines]
>>
>> Willy.
auldh - 25 Oct 2007 19:19 GMT
Willy,
this is absolutely brilliant. simple and clean.
i did not see anything like this anywhere.

what do you use for a reference guide on this windows security stuff. i
picked up Keith Brown's "Programming windows security" and "the .NET
developer's guide to Windows security". it missed this type of detail.

thank you very.

> If you really need to parse all individual bits you'll have to loop through
> the enum values, sure there are different ways to do this, following
[quoted text clipped - 68 lines]
> >>
> >> Willy.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.