I found this on the Perl Win32 Admin Archive and it works to turn off permissions inheritence on directories but how do you do the same on files in the directories?
Any help is appreciated. Than ks, Dax -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Jason, You can't do this with Win32::Perms. The best way I've found is to use WMI. Here's a simple sub to do it, pulled from one of my scripts. Pass it the path to the directory and a flag value from this list: 0 - DENY_INHERIT (Uncheck the "Allow inheritable..." check box) 1 - ALLOW_INHERIT (Check the box) 2 - DENY_INHERIT_PLUS (Uncheck the box and force Windows to re-run the inheritance algorithim of the dir and all of it's children) 3 - ALLOW_INHERIT_PLUS (Same thing as 2 but with the box checked) -Shawn ### ---------- Begin Code ---------- ### use Win32::OLE; sub inheritance { ### Syntax: inheritance( DirToModify, FlagValue ) ### ---------- Declarations ---------- ### use constant ALLOW_INHERIT => 33796; use constant ALLOW_INHERIT_PLUS => ALLOW_INHERIT + 256; use constant DENY_INHERIT => 37892; use constant DENY_INHERIT_PLUS => DENY_INHERIT + 256; my ($Fpath, $cc) = @_; $Fpath =~ s/'/\\'/; my $wmi = Win32::OLE-> GetObject( "winmgmts:{impersonationLevel=impersonate}!". "//$currentServerName/root/CIMV2" ); #print "vars - $currentServerName/$Fpath\n"; eval { $object = $wmi-> Get("CIM_Directory='$Fpath'"); $objSecSetting = $wmi-> Get("Win32_LogicalFileSecuritySetting.Path=" . "\'" . $object-> {Name} . "\'"); $outParam = $objSecSetting-> ExecMethod_("GetSecurityDescriptor"); $objSecDescriptor = $wmi-> Get("Win32_SecurityDescriptor")->SpawnInstance_; #$objMethod = $objSecSetting-> Methods_("SetSecurityDescriptor"); #$inParam = $objMethod-> inParameters->SpawnInstance_; if ($cc == 0) { $objSecDescriptor-> {ControlFlags} = DENY_INHERIT; } elsif ($cc == 1) { $objSecDescriptor-> {ControlFlags} = ALLOW_INHERIT; } elsif ($cc == 2) { $objSecDescriptor-> {ControlFlags} = DENY_INHERIT_PLUS; } elsif ($cc == 3) { $objSecDescriptor-> {ControlFlags} = ALLOW_INHERIT_PLUS; } $objSecDescriptor-> {DACL} = $outParam->{Descriptor}->{DACL}; #$inParam-> {Descriptor} = $objSecDescriptor; #$objSecSetting-> ExecMethod_("SetSecurityDescriptor"), $inParam); $objSecSetting-> SetSecurityDescriptor( $objSecDescriptor ); }; } # End Sub ### ---------- End Code ---------- ### -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Jason shaw Sent: Monday, August 05, 2002 4:31 PM To: [EMAIL PROTECTED] Subject: Win32::Perms and Inheritance I'm having problems trying to set the permissions on a folder on a Win2K system. Does any one know how to remove the "Allow inheritable permissions from parent to propagate to this object" on the security tab of a folder's properties. From everything I understand, this should be possible with Win32::Perms, but I guess I'm just not seeing it. And I've looked through past posts and seen people talk about it, but never saw a solution. I've been working on this for a while now and I'm running outta ideas. Any help would be great! Thanks! _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
