RE: New System.Security.AccessControl classes
From: brckcc (brckcc_at_newsgroup.nospam)
Date: 10/31/05
- Next message: Skywing: "Re: winlogon not loading 32 bit xxgina.dll in xp 64 bit"
- Previous message: john: "Re: Question about OffloadModExpo() Function"
- In reply to: Jeffrey Tan[MSFT]: "RE: New System.Security.AccessControl classes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Mon, 31 Oct 2005 06:56:06 -0800
Thank you. This will help.
--
Bruce R.
""Jeffrey Tan[MSFT]"" wrote:
> Hi Bruce,
>
> Thanks for your post.
>
> Based on my understanding, you want to do the Security Descriptor dump for
> files/folders with .Net2.0 classes.
>
> In .Net2.0, doing ACL programming is much easier than before, .Net provided
> managed classes for ACL programming. Below is a code snippet for dumping
> the owner and DACL of a file:
>
> private void button1_Click(object sender, EventArgs e)
> {
> FileSecurity sd=File.GetAccessControl(@"C:\boot.ini");
> PrintOwerAndDACL(sd);
> }
>
> static void PrintOwerAndDACL(FileSecurity sd)
> {
>
> Console.WriteLine("Owner: {0}", sd.GetOwner(typeof(NTAccount)));
> // rule represents an ACE
> foreach (FileSystemAccessRule rule in sd.GetAccessRules(true, true,
> typeof(NTAccount)))
> {
> PrintACE(rule);
> }
> }
>
> static void PrintACE(FileSystemAccessRule rule)
> {
> Console.WriteLine("{0} {1} to {2} ({3})",AccessControlType.Allow ==
> rule.AccessControlType ?
> "grant" : "deny",
> rule.FileSystemRights, // access permission mask
> rule.IdentityReference,
> rule.IsInherited ? "inherited" : "direct");
> }
>
> Addtionally, Keith brown has writen an excellent windows security book for
> .Net 2.0, there is an online version in the link below:
> "The .NET Developer's Guide to Windows Security"
> http://pluralsight.com/wiki/default.aspx/Keith.GuideBook.HomePage
>
> Hope this helps
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>
>
- Next message: Skywing: "Re: winlogon not loading 32 bit xxgina.dll in xp 64 bit"
- Previous message: john: "Re: Question about OffloadModExpo() Function"
- In reply to: Jeffrey Tan[MSFT]: "RE: New System.Security.AccessControl classes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]