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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inheritance flags don't seem to do anything

Status
Not open for further replies.

EagleTempest

Technical User
Jun 15, 2004
125
CA
VB 2005 & .Net 2

I'm trying to add a user group with Full Control applied to "This folder, subfolders, and file" but it seems to keep getting varied results.

The Full Control permission consistently works but it's always applied to "This folder only". Any ideas?

Code:
Private Sub AddDirSecurity(ByVal Filename As String, ByVal Account As String, ByVal Rights As FileSystemRights)
    Dim dInfo As New DirectoryInfo(Filename)
    Dim ruleF As FileSystemAccessRule

    ruleF = New FileSystemAccessRule(Account, Rights, InheritanceFlags.ObjectInherit And InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow)

    Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl
    dSecurity.AddAccessRule(ruleF)

    dInfo.SetAccessControl(dSecurity)

  End Sub
 
It seems changing AND to + did the trick
Code:
ruleF = New FileSystemAccessRule(Account, Rights, InheritanceFlags.ObjectInherit + InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top