in reply to Win32::Perms doesn't get local groups
I have to admit that a lot of the Win32 modules have a poor API, are poorly documented and often don't quite work as intended. To be fair the writers of these modules, it's more often Windows' internals that are the problem rather than Perl.
Anyway, having had to do this for a production service on which 40k people rely, the most robust method I could find was to use WMI to enumerate all the shares on a remote server and then use a Windows resource kit tool - rmtshare - to get the permissions off. It copes very well with all manner of local and domain groups.
This is a quick and ready code snippett that I hacked up in a hurry, so it may not be the best:
open (COMMAND, "rmtshare \\\\$server\\\$share\" |" ) or die "Eeek, una +ble to run rmtshare\n"; while ( <COMMAND> ) { next unless /:/g; next if /^Path/; next if /^Permissions/; chomp; if ( $_ ) { #$_ =~ s/\s+//g; my ( $user, $perm ) = split( /:/, $_ ); $perm =~ s/FULLCONTROL$/FULL/; $perm =~ s/FULL CONTROL$/FULL/; $user =~ s/^\\Everyone/Everyone/; $user =~ s/^\s+//; $user =~ s/\s+$//; $perm =~ s/^\s+//; $perm =~ s/\s+$//; print "$user:$perm\n"; } } close COMMAND;
|
|---|