anu_1 has asked for the wisdom of the Perl Monks concerning the following question:

I am using this function to get the folder permission
use Win32::FileSecurity qw(Get EnumerateRights); Get($folder,\%htrustees); while (($trustee, $mask) = each %htrustees) { print "$trustee:$mask"; }
Is there any function to get the folder inheritance also ("Apply to" part in windows permission box)..? Like "This Files only", "Subfolders only" etc

Replies are listed 'Best First'.
Re: windows folder permission
by cdarke (Prior) on Oct 11, 2010 at 15:02 UTC
    Not as easy as it sounds. You have to look specifically for inheritable ACEs, and that can be a lot of work. Look at Win32::Security.
Re: windows folder permission
by locked_user sundialsvc4 (Abbot) on Oct 11, 2010 at 14:40 UTC

    Probably...

    In most cases, I just “try it and see.”   If you want to see if the current-user can create a file somewhere ... try to do it.   Using a “junk” filename, try to create it (using some system-command like e.g. touch, in a qx// block), and then immediately remove it (same way).   Wrap the whole thing in an eval block.   If an error is thrown (“$@” is non-blank), you know it didn’t work.   Yeah, it’s a hack, but it works reliably when a lot of other things don’t.

    There are so many things that can affect file-access, that it is often much more difficult to “guess,” than to simply “push on the gate and see if an alarm goes off.”

      How does this "advice" even begin to address the OPs question; "Is there a function to ..."?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.