I'm looking to duplicate the Windows Explorer security screen for a directory, the one you get when you right click a directory, go to properties, and click on the Security tab. At the top it lists "Groups or user names" then if you click a user at the bottom it will show the permissions (Full Control, Modify, Read & Execute, etc). So far I've been able to duplicate the Groups or user names box (for the most part) but I'm having trouble pulling the actual allow and deny permissions. I've seen some C++ examples on assigning or removing premissions but thats not what I want and I wasn't able to use those examples to pull the actual permissions correctly. Heres basically what I have so far:
This so far lets a user click a directory from a tree, pulls some info (not all listed..like accessed date, created date, etc) including the owner and the lsit of users on the ACL (Although some names just come up as BUILTIN\USER and not actual names....). It tags those that are inherited from a parent folder with (Inherited). Then I want someone to be able to click a name and pull up the actual permissions but I can't seem to get to these properties. This is in VB.Net 2005 (.Net v2).
-Allan.
VB.NET:
' Get directory info for selected directory
myDirInfo = My.Computer.FileSystem.GetDirectoryInfo(DirectoryStructureTreeView.SelectedNode.Text)
' Get the folders owner
Dim myOwner As Security.Principal.IdentityReference = myDirInfo.GetAccessControl.GetOwner(GetType(Security.Principal.NTAccount))
OwnerLabel.Text = myOwner.ToString
' Get our ACL, or what I think is the ACL
myARC = myDirInfo.GetAccessControl.GetAccessRules(True, True, GetType(Security.Principal.NTAccount))
' Fill the ListView with the users in the Access Control List
Dim x As Integer = 0
For Each ar As AccessRule In myARC
GroupsandUsersListView.Items.Add(ar.IdentityReference.Value.ToString).Text = ar.IdentityReference.Value.ToString
If ar.IsInherited.ToString = "True" Then
GroupsandUsersListView.Items(x).SubItems.Add("(Inherited)")
End If
x += 1
Next
-Allan.