get current InheritanceFlag and PropagationFlag State

  • Thread starter Thread starter CHSTechSolutions
  • Start date Start date
C

CHSTechSolutions

Guest
i am having an issue with getting and setting InheritanceFlags and PropagationFlags

When running the following code


Dim FolderPath As String = "C:\test" Specify the folder here
Dim UserAccount As String = "CHRISSNYDERFC9D\test1" Specify the user here

Dim FolderInfo As IO.DirectoryInfo = New IO.DirectoryInfo(FolderPath)
Dim FolderAcl As New DirectorySecurity
FolderAcl.AddAccessRule(New FileSystemAccessRule(UserAccount, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow))
FolderInfo.SetAccessControl(FolderAcl)


as you can see the InheritanceFlags property is set to ContainerInherit however when i read it back to verify and check permissions with the following code


Dim fSecurity As FileSecurity = File.GetAccessControl(ParentFolder)
Dim Access As AuthorizationRuleCollection = fSecurity.GetAccessRules(True, cbInherit.Checked, GetType(NTAccount))
For Each fsaRule As FileSystemAccessRule In Access
if fsaRule.InheritanceFlags = InheritanceFlags.ContainerInherit Then
Code to run
End If
Next


everything come back with InheritanceFlags.None

Please help
Thanks

Continue reading...
 
Back
Top