Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Something Funky with setting folder permissions

Status
Not open for further replies.

pkirill

Technical User
Jun 15, 2002
134
0
0
US
I'm using the code below to set folder permission on a mapped network drive. It seems to function correctly - people who need access can access those that don't can't. Simple enough. The funky part is that when I view the security settings (right click>properties>security) there are no checks in any of the boxes for any users. However if I click the Advanced button, I see entries for all the users and the proper permissions.

Any thoughts on how to get the checks to show up? I also welcome any comments or opinions on the use of "SetAccessRuleProtection" to remove inheritance from the the parent folder.

Thanks in advance!

Code:
Sub AddDirectorySecurity(ByVal strProjectPath As String, ByVal strSubFolder As String)

        My.Computer.FileSystem.CreateDirectory(strProjectPath & strSubfolder)
        Dim di As New IO.DirectoryInfo(strProjectPath & strSubFolder)
        Dim ds As DirectorySecurity = di.GetAccessControl()



        ds.SetAccessRuleProtection(True, False)
        ds.AddAccessRule(New FileSystemAccessRule("builtin\administrators", FileSystemRights.FullControl, AccessControlType.Allow))
        ds.AddAccessRule(New FileSystemAccessRule("system", FileSystemRights.FullControl, AccessControlType.Allow))
        ds.AddAccessRule(New FileSystemAccessRule("builtin\users", FileSystemRights.FullControl, AccessControlType.Allow))
        di.SetAccessControl(ds)
    End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top