jrbilodeau
Member
- Joined
- Apr 29, 2009
- Messages
- 7
- Programming Experience
- 1-3
I'm in the process of writing an app that will scan a list of directories and all subdirectories, and list who has access to them. Since there are is a possibility of there being hundreds or even thousands of directories, my boss asked that i not list the subdirectories that have the same permissions as parent folder in the output report. I came up with the following code, but even when the Directory permissions are an exact match it never comes back as true. Any help would be greatly appreciated
VB.NET:
Dim dInfo As New DirectoryInfo(DirectoryName)
Dim dSecurity As New DirectorySecurity
Dim dParentInfo As New DirectoryInfo(dInfo.Parent.FullName)
Dim parentSecurity As New DirectorySecurity
Dim obTypeToGet As Type
' Get ACL object on the selected file or folder.
dSecurity = dInfo.GetAccessControl()
parentSecurity = dInfo.GetAccessControl()
obTypeToGet = Type.GetType("System.Security.Principal.NTAccount")
Dim arc As AuthorizationRuleCollection = dSecurity.GetAccessRules(True, True, obTypeToGet)
Dim arcParent As AuthorizationRuleCollection = parentSecurity.GetAccessRules(True, True, obTypeToGet)
If arc.Equals(arcParent) Then
MessageBox.Show("test")
End If