Results 1 to 2 of 2

Thread: [RESOLVED] [2005] groups associated with a folder

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    22

    [RESOLVED] [2005] groups associated with a folder

    I am trying to list all the groups associated with a folder. IE - the ones listed in the security tab in the properties form of a folder.

    I have been playing with DirectorySecurity and have so far been unable to find anything to list the various groups. I have found how the replicate / add and remove groups, but so far not how to list them.

    I would be grateful for any help what so ever
    Last edited by Ping_Chow_Chi; Dec 12th, 2006 at 08:02 AM.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    22

    Re: [2005] groups associated with a folder

    This seems to work

    Private Sub outputACL(ByVal strFolder As String)
    '##
    '## Code to output the Access Control List (ACL) of a given folder
    '##
    Dim fs As Security.AccessControl.FileSecurity = System.IO.File.GetAccessControl(strFolder)
    Dim user As Security.Principal.NTAccount = CType(fs.GetOwner(GetType(Security.Principal.NTAccount)), Security.Principal.NTAccount)
    Dim author As AuthorizationRuleCollection = fs.GetAccessRules(True, True, (GetType(System.Security.Principal.NTAccount)))

    frmOutput.txtOutput.Text = "Folder" & vbTab & "Owner" & vbTab & "Perms" & vbTab & "User" & vbTab & _
    "Inhertance Flag" & vbTab & "Inherited?" & vbTab & "File System Rights" & vbNewLine
    frmOutput.txtOutput.Text = frmOutput.txtOutput.Text & strFolder & vbTab & user.ToString & vbNewLine


    For Each Rule As FileSystemAccessRule In author

    frmOutput.txtOutput.Text = frmOutput.txtOutput.Text & vbTab & vbTab & Rule.AccessControlType.ToString & vbTab & Rule.IdentityReference.Value & _
    vbTab & Rule.InheritanceFlags.ToString & vbTab & Rule.IsInherited & _
    vbTab & Rule.FileSystemRights.ToString & vbNewLine
    Next

    frmOutput.Show()

    End Sub

    I'll leave it here incase it helps anyone else in the future

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width