Hi All,
I'm using the following code to set permissions, this is working...however its overwriting any previous permissions on there.
For example my folder has the following Users/Groups attached to it;
CREATOR OWNER
SYSTEM
Administrators
Users
TestUser
Remote Desktop Users
After I run the following VB Code the Users/Groups I'm left with are
CREATOR OWNER
SYSTEM
Administrators
Users
TestUser
As you can see this code is removing all the permissions then adding the Inherited permissions back and adding my specified user
Thanks
Swain90
I'm using the following code to set permissions, this is working...however its overwriting any previous permissions on there.
For example my folder has the following Users/Groups attached to it;
CREATOR OWNER
SYSTEM
Administrators
Users
TestUser
Remote Desktop Users
After I run the following VB Code the Users/Groups I'm left with are
CREATOR OWNER
SYSTEM
Administrators
Users
TestUser
As you can see this code is removing all the permissions then adding the Inherited permissions back and adding my specified user
Code:
Dim FolderPath As String = "C:\Test"
Dim UserAccount As String = "Domain.com\TestUser"
Dim FolderInfo As IO.DirectoryInfo = New IO.DirectoryInfo(FolderPath)
Dim FolderAcl As New DirectorySecurity
Try
'Dim Rule As FileSystemAccessRule = New FileSystemAccessRule(UserAccount, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow)
FolderAcl.AddAccessRule(New FileSystemAccessRule(UserAccount, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow))
FolderInfo.SetAccessControl(FolderAcl)
Catch ex As Exception
MessageBox.Show(ex.Message, "Test File/Folder Permissions", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Try
Swain90