thoughtless has asked for the wisdom of the Perl Monks concerning the following question:
use warnings; use Win32::Perms; unless( defined @ARGV ){ print "Error: Please supply divisions share.\n"; print "perl SharePermissions.pl \\\\server\\share\n"; exit 0; } #pull off the share provided by user my $share = pop @ARGV; my $level = 0; CheckPerms( $share ); ReadDir( $share ); sub CheckPerms{ my $directory = shift @_; my $perms = new Win32::Perms( "$directory" ) or die "Could not get permissions: $^E"; my $owner = $perms->Owner(); my $counter = $perms->Get(\ my @list ); $perms->Close(); my $space = " " x $level; foreach my $item ( @list ){ #Access, Account, Domain, Entry, Flag, Mask, #ObjectName, ObjectType, SID, Type my $sid = $item->{SID}; my $name = Win32::Perms::ResolveAccount($sid); Win32::Perms::DecodeMask( $item->{Mask}, \@mask ); my $access = $item->{Access}; $permissions{$name} = { access => $access, mask => \@mask }; } foreach ( sort keys %permissions ){ print $space . "Group/User:$_ Access:$permissions{$_}->{access}\n" +; print $space . "Permissions:"; my $array = $permissions{$_}->{mask}; print "@$array\n"; } } sub ReadDir{ my $dir = shift @_; opendir(DIR, $dir) or die "Error: Unable to open the $dir. $^E\n"; #read directory and do not count in '.' and '..' my @all = grep{ not /^\.{1,2}\z/ } readdir( DIR ); close( DIR ); foreach my $name ( @all ){ if( -d "$dir\\$name" ){ $level++; CheckPerms( "$dir\\$name" ); ReadDir( "$dir\\$name" ); $level--; next; }#elsif $all_file is a file continue with check elsif( -f $name ){ next; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::Perms and Network Shares
by arden (Curate) on Feb 06, 2004 at 16:54 UTC | |
by thoughtless (Initiate) on Feb 06, 2004 at 17:19 UTC | |
|
Re: Win32::Perms and Network Shares
by rchiav (Deacon) on Feb 06, 2004 at 22:16 UTC | |
by thoughtless (Initiate) on Feb 09, 2004 at 17:43 UTC | |
by ballJoint (Initiate) on Feb 21, 2004 at 16:57 UTC | |
by ballJoint (Initiate) on Feb 21, 2004 at 17:47 UTC | |
by zechim (Initiate) on Dec 27, 2005 at 12:22 UTC |