Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

windows folder permission

by anu_1 (Acolyte)
on Oct 11, 2010 at 11:21 UTC ( #864584=perlquestion: print w/replies, xml ) Need Help??

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 sundialsvc4 (Abbot) on Oct 11, 2010 at 14:40 UTC


    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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://864584]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2022-05-17 08:48 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (65 votes). Check out past polls.