in reply to Re: win32 ACL problem.
in thread win32 ACL problem.

thanks for the warning explication.
for the second thing: I wont access the property "This folder, Subfolders and files" via Perl and not via mouse!
any idea?
Thanks in any case..
lorenzo*

Replies are listed 'Best First'.
Re: Re: Re: win32 ACL problem.
by blm (Hermit) on Sep 24, 2002 at 13:15 UTC

    I get the feeling that Win32::FileSecurity tries to do the inheritance stuff automagically. I use Win32::Perms for my work as it seems to expose more functionality. Doing the same script with Win32::Perms seems not to have the same problems as the code you posted. Here is my Win32::Perms version:

    use Win32::Perms; $cart='TestingFolder'; mkdir $cart || warn $!; # Create a new Security Descriptor and auto import permissions # from the directory $Dir = new Win32::Perms( $cart ) || die; my @perms; my $perm; $Dir->Get(\@perms); my $index = 0; $Dir->Dump; do { $perm = $perms[$index]; } while ($perm->{'Account'} ne 'Everyone') and (++$index); # One of three ways to remove an ACE print ($Dir->Remove($index)); $Dir->Set(); $Dir->Dump;
    --blm--

    ps you may notice that I don't use $Dir->Remove('Everyone'), This is because I could not get it to delete any ACEs. So I compute the index of the ACE in the ACL and delete based on that. I will investigate this further.

      I made mistakes in this script. On line 4 it should read

      mkdir $cart or warn $!;

      (I should listen to my own advice)

      Also it fails if there is no ACE with everyone as the account. So I rejigged it as follows.

      use Win32::Perms; ### # # get_index_of($account_name, $ace) # # Return an array of positions of ACEs # with trustee of $account_name or if called # in scalar context the index of the first matching ACE # ### sub get_index_of { my ($account_name, $ace) = @_; my $index = -1; my @positions; do { $index++; print "$index"; $perm = $$ace[$index]; print $perm; if ($perm->{'Account'} eq $account_name) { push @positions, $i +ndex }; } while ($index < $#$ace); wantscalar and return $positions[0]; return @positions; } $cart='TestingFolder'; mkdir $cart or warn $!; # Create a new Security Descriptor and auto import permissions # from the directory my @perms; my $perm; my $Dir = new Win32::Perms( $cart ) or die; $Dir->Get(\@perms) or die; #Get permissions $Dir->Dump; my $acl_index = get_index_of('Everyone', \@perms); print "Returned ", $acl_index; print $perm->{'Account'}; if (defined $acl_index) { $Dir->Remove($acl_index) or die $!; $Dir->Set() or die$!; } $Dir->Dump;

      If you --me can you let me know so I can learn?

      --blm--