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

Hi, As part of an Active Directory cleanup I'm having to change users login names and, therefore, their home folder name and permissions. Using win32::perm I can change the permissions on the home folder and all child folders using
use strict; use warnings; use Win32::Perms; my $user1 = 'john123'; my $home = 'C:\test_'.$user1; # Create a new Security Descriptor and auto import permissions # from the directory my $dir = new Win32::Perms($home) || die; $dir->Remove(-1); # remove defaults my $user2 ='john321'; $dir->Allow('Domain Admins',FULL,FILE); $dir->Allow('Domain Admins',FULL,DIR); $dir->Allow($user2,CHANGE,FILE); $dir->Allow($user2,CHANGE,DIR); #$dir->Owner($user); my $home1 = $home.'\*'; $dir->Set()or die "ERROR: Failed to set Permissions on folder(1)"; $dir->SetRecurse($home1)or die "ERROR: Failed to set Permissions on fo +lder(2)"; $dir->Close();
which seems to do a very nice job. How can I do this recursively for all the files contained in the folder(s)? When I try to set the path in SetRecurse to ...\*.* it doesn't work.

Replies are listed 'Best First'.
Re: win32::perm recursive file permission setting
by NetWallah (Canon) on Jun 08, 2006 at 05:53 UTC
    Googling "SetRecurse Perms" shows many users having trouble similar to yours. This non-PM thread is a good read on the subject, and suggests using a free external program, Setacl to set the perms.

         "For every complex problem, there is a simple answer ... and it is wrong." --H.L. Mencken

      I'll look into that, thanks!
Re: win32::perm recursive file permission setting
by steverippl (Novice) on Jun 08, 2006 at 18:44 UTC
    Incase anyone comes across this on their own search, xcacls.vbs, provided by M$ themselves does a great job of changing file and folder permissions recursively... I'll just try to run that from within my perl script : )