rchiav has asked for the wisdom of the Perl Monks concerning the following question:
Now my question is: is there a better way to do it? It works fine, but that doesn't mean that there isn't a more apropriate way to handle it.sub GetAgedComps { my $filter = FILTER_WORKSTATION_TRUST_ACCOUNT; my $level = 2; my $fudge = 120960; my $conversion = 86400; my ($server, $age, $silent) = @_; my (@machines, $comp, %info, %accts, $buf, $x); print " Pulling information from $server...\t\t" unless $silent; if (UserEnum($server, \@machines, $filter)) { print"[OK]\n" unless $silent; } else { print "[FAILED]\n" unless $silent; die " Unable to retreive information from $server: $!\n" } my $count = @machines; print " Checking for aged accounts...\t\t\t" unless $silent; foreach $comp (@machines) { unless ($silent) { $x++; #note, the funny char is a ^H print "" x length($buf) if $buf; print $buf = "[$x/$count]"; } unless (UserGetInfo($server, $comp, $level, \%info)) { die "\n Error retreiving information for $comp: $!\n"; } if (($info{'passwordAge'} - $fudge) / $conversion > $age ) { ($accts{$comp}) = int (($info{'passwordAge'} - $fudge) +/ $conversion); } } print "\n" unless $silent; return \%accts; }
Thanks,
Rich
PS - this pulls NT machine trust accounts that haven't been accesed in over a certian number of days. I was planning on posting it here once I have it cleaned up.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Manipulating cursor position when printing to STDOUT
by bikeNomad (Priest) on Jul 16, 2001 at 19:30 UTC | |
by John M. Dlugosz (Monsignor) on Jul 17, 2001 at 01:45 UTC | |
|
Re: Manipulating cursor position when printing to STDOUT
by MZSanford (Curate) on Jul 16, 2001 at 19:35 UTC | |
|
Re: Manipulating cursor position when printing to STDOUT
by John M. Dlugosz (Monsignor) on Jul 17, 2001 at 01:52 UTC |