locked
Folder access rights and permisions RRS feed

  • Question

  •  

    Hello,

     

    I'm trying to make a program in c# in which I need to know (just get the information, no need to change it) the security and sharing access rights (read, write, full permissions...) on a specific folder for each group and user. I have already managed to know the security rights for my personnal account (System.Security.Principal.WindowsIdentity getWindowsIdentity) but I need to get this for everybody.

     

    How can I get the list of groups and users with customed permissions in my program (the same list as in the folder properties window in explorer). As soon as I get this list, I think that I'll be able to know the folder rights for each user account like I did for mine.

     

    I'll take care of the sharing permissions later but if you have good resources about this topic, it could be helpful.

     

    Thank you.

    Tuesday, April 17, 2007 5:22 AM

Answers

  • Hi, gOOze

    Here is a thread on this topic: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1457811&SiteID=1

    Hope it helps

    Thanks

    Friday, April 20, 2007 8:37 AM
  •  

    Hi

     

    Thanks! I finally found the solution to get information i needed. Here is how i've done, it might help:

     

     

    As I said, I aimed get the list of groups and users with customed permissions in my program (the same list as in the "user and groupe names" from the security tab in a folder properties). For exemple here, I wanted to get admin, créateur, marc...

     

    Code Snippet

       DirectorySecurity ds = new DirectorySecurity(@"C:\", AccessControlSections.All);
     
                AuthorizationRuleCollection arc = ds.GetAccessRules(true, true, typeof(NTAccount));
                foreach (FileSystemAccessRule fsar in arc)
                {
                    Console.WriteLine(fsar.IdentityReference + " : " + fsar.AccessControlType + "->" + fsar.FileSystemRights);
                }

     

    This code gives you:

     

    Everyone : Allow -> ReadAndExecute, Synchronize
    CREATOR OWNER : Allow -> FullControl
    NT AUTHORITY\SYSTEM : Allow -> FullControl
    BUILTIN\Administrators : Allow -> FullControl
    BUILTIN\Users : Allow -> ReadAndExecute, Synchronize
    BUILTIN\Users : Allow -> CreateFiles, Synchronize
    BUILTIN\Users : Allow -> AppendData, Synchronize
    ANCALAGON\Mary : Allow -> ReadAndExecute, Synchronize

     

    Bye

    gOOze

    Friday, April 20, 2007 10:02 AM

All replies

  • Hi, gOOze

    Here is a thread on this topic: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1457811&SiteID=1

    Hope it helps

    Thanks

    Friday, April 20, 2007 8:37 AM
  •  

    Hi

     

    Thanks! I finally found the solution to get information i needed. Here is how i've done, it might help:

     

     

    As I said, I aimed get the list of groups and users with customed permissions in my program (the same list as in the "user and groupe names" from the security tab in a folder properties). For exemple here, I wanted to get admin, créateur, marc...

     

    Code Snippet

       DirectorySecurity ds = new DirectorySecurity(@"C:\", AccessControlSections.All);
     
                AuthorizationRuleCollection arc = ds.GetAccessRules(true, true, typeof(NTAccount));
                foreach (FileSystemAccessRule fsar in arc)
                {
                    Console.WriteLine(fsar.IdentityReference + " : " + fsar.AccessControlType + "->" + fsar.FileSystemRights);
                }

     

    This code gives you:

     

    Everyone : Allow -> ReadAndExecute, Synchronize
    CREATOR OWNER : Allow -> FullControl
    NT AUTHORITY\SYSTEM : Allow -> FullControl
    BUILTIN\Administrators : Allow -> FullControl
    BUILTIN\Users : Allow -> ReadAndExecute, Synchronize
    BUILTIN\Users : Allow -> CreateFiles, Synchronize
    BUILTIN\Users : Allow -> AppendData, Synchronize
    ANCALAGON\Mary : Allow -> ReadAndExecute, Synchronize

     

    Bye

    gOOze

    Friday, April 20, 2007 10:02 AM