I am currently trying to set the attribute on a folder to inherit permissions from it's parent if it is not already set to do so using ADsSecurity from the Windows 2003 Resource kit, but I can't seem to figure this out. From everything I've read the below code should work okay, can anyone point out something that I'm missing? In the end the plan is to set a folder to inherit permissions if it already isn't inheriting and then set one explicit permission on that folder for a specific user.
use constant SE_DACL_PROTECTED => 0x1000; my $ADsSecurity = Win32::OLE->new("ADsSecurity"); my $objSD = $ADsSecurity->GetSecurityDescriptor("FILE://". $path); #get the control flags my $control_flags = $objSD->{Control}; print "Current Flag: $control_flags\n"; #37892 = 0x9404 = no inheritance set if($control_flags == 37892){ #37892 ^ 4096 (0x1000) = 33796 = 0x8404 = set inheritance $control_flags = $control_flags ^ SE_DACL_PROTECTED; $objSD->{Control} = $control_flags; $ADsSecurity->SetSecurityDescriptor($objSD); print "Set for Inheritance: $control_flags\n"; }
Any help would be apperciated. Thanks.

In reply to Modifying NTFS Permissions by onetime

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.