Richard's profileRichard Siddaway's BlogPhotosBlogLists Tools Help

Blog


    February 06

    File system: Allow inheritable permissions from parent to propagate

    In this post http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!800.entry I showed how to set the permissions on AD objects such that objects inherit permissions from their parent.

    I had a message sent through my blog asking how this could be applied to a file on a NTFS file system.  The first thing to note is that the file cannot be accessed through LDAP in the same way as an AD object.  Instead we have to use the NTFS permissions.  With PowerShell this is easy due to the Get-Acl cmdlet.

    We start by get the ACLs for the file

    PS> $acl = Get-Acl file.txt
    PS> $acl.areaccessrulesprotected
    True
    PS> $isProtected = $false
    PS> $preserveInheritance = $true
    PS> $acl.SetAccessRuleProtection($isProtected, $preserveInheritance)
    PS> $acl.areaccessrulesprotected
    False
    PS> Set-Acl -Path file.txt -AclObject $acl
    PS>

    The property that we are interested in is areaccessrulesprotected - true means that permissions are not inherited.  So we set a couple of boolean objects.  $isProtected = $false allows inheritance.  $preserveinheritance is actually ignored.

    We then use SetAccessRuleProtection() to set the new permissions so inheritance is allowed.   Final step is to use Set-Acl to actually apply the permissions as shown.

    Could I ask that if you leave me message and want a reply then please set your communication preferences to allow me to reply.

    Share this post :

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!1069.trak
    Weblogs that reference this entry
    • None