All worked nicely, however I couldn’t use strict with the recursive routine that accesses directories and sub directories (but this is the least of my worries at the moment. I can use File::Find module I suppose but I will continue with the recursive access for the time being)
Finally and most importantly is: if I wanted to remove the 'everyone' account from accessing certain directories or sub directories without having to remove the account from the PDC? is this possible?
I tried using Win32::NetAdmin::UserDelete, but this did not work
Can someone help me please?
I have marked the bit that dosen't in my code below
use Win32; use warnings 'all'; use Win32::FileSecurity; use Win32::NetAdmin; use Win32::AdminMisc; my $unc_path = shift @ARGV; my $accnt = pop @ARGV; $unc_path = "\\\\" . $unc_path; print "\n\nPath to scan=>\t'$unc_path'\t\t Account to remove=>\t'$accn +t'\n\n"; my %groups; Win32::AdminMisc::GetGroups($unc_path, GROUP_TYPE_ALL, \%groups) || wa +rn "\nFailed : $!, $^E\n"; foreach my $group (keys %groups) { printf "%s\t%s\n", $groups{$group}{type}, $group; } print "\n\nUser permissioned\n"; my %hash; Win32::FileSecurity::Get("$unc_path", \ %hash ) || warn "Get failed : +$!\n"; while (my ($acl_owner, $mask)=each %hash) { $acl_owner =~ s{.+\\}{}; my @perms; Win32::FileSecurity::EnumerateRights( $mask, \@perms) || warn "Enu +merateRights failed : $!\n"; my $acl_owner_type = $groups{$acl_owner}{type} || 'user'; print "$acl_owner ($acl_owner_type): "; if ( $acl_owner =~ /everyone/i ) { print "This account is about to be deleted\n"; #THIS BIT DOES NOT WORK Win32::NetAdmin::UserDelete($unc_path, $acl_owner); } @perms = $perms[0]; foreach (@perms) { print "\t\t\t$_\n" } }

In reply to Re: Win32 ACLs: Local vs Global groups by blackadder
in thread Directory level access by blackadder

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.