I am trying to have a folder with a username created with 2 subfolders. I need to have the folder grant a specific user read-only access to the folder while still retaining the inherited permissions. One of the subfolders need to grant the user Write access. So the structure will look like this:
c:\ftp (not listed in ACL)
Now, I've grabbed code from other posts and got it almost working. The problem I have is the permissions are being applied correctly to the subfolders, but the user-named folder lists the user in the ACL, but they have no effective permissions.
Here is the code that calls the function:
AddDirectorySecurity((userDirectory), Me.AccountName.Text, FileSystemRights.ReadAndExecute, AccessControlType.Allow)
Then here is the code for the function:
Sub AddDirectorySecurity(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal ControlType As AccessControlType)
' Get a DirectorySecurity object that represents the current security settings.
Dim dSecurity As DirectorySecurity = Directory.GetAccessControl(FileName)
' Add the FileSystemAccessRule to the security settings (**following is one line of code**).
dSecurity.AddAccessRule(New FileSystemAccessRule(Account, Rights, (InheritanceFlags.ContainerInherit + InheritanceFlags.ObjectInherit), PropagationFlags.InheritOnly, ControlType))
' Set the new access settings.
I can't figure out why my top username folder isn't getting the accesspermissions set on them.