WEB LISTING 1: TestUserReplicationGUI.pl use Tk; use Win32::NetAdmin qw(UsersExist); use Net::Ping; $SuccessCounter = 0; $ServerCounter = 0; # Configure a list of the DCs you want to test. @DCList = qw(DOM-DC-01 DOM-DC-02 DOM-DC-03 DOM-DC-04 DOM-DC-05 DOM-DC-06 DOM-DC-07 DOM-DC-08 DOM-DC-09 DOM-DC-10); # Create the main window with user entry box. $main = new MainWindow; $main->Label(-padx => 10, -pady => 5,-wraplength => 260, -relief => groove, -text => 'Please enter the account ID.')->pack; $entry1 = $USERID = $main->Entry( -takefocus => 1, -width => 20); $USERID->pack; $entry1 -> focus; # Create a button to launch the user test. $button1 = $main->Button( -text => 'Test user existence on DCs', -font => "Arial 10 bold", -background => gray, -cursor => hand2, -command => sub{do_extract($USERID)})->pack; MainLoop; sub do_extract($USERID) { $USERID = ($USERID)->get; foreach $Server ( @DCList ) { # Test ping response of server. $p = Net::Ping->new("icmp"); if ($p->ping($Server, 1)) { # You can comment out the following print statement if you # want onscreen status information. $ServerCounter++; if ( UsersExist("\\\\$Server", "$USERID")) { print "$User account exists on $Server\n"; $SuccessCounter++; } else { print "$User account does not exist\n"; $FailCounter++; } $p->close(); } else { $p->close(); } } # If the number of online servers equals 0, you have a problem. if ( $ServerCounter == 0 ) { $main->Label(-padx => 10, -pady => 5, -wraplength => 175, -relief => groove, -text => "No servers appear to be online! Check for network problems or server list issues.")- >pack; $main->Button(-text => 'Exit', -background => gray, -takefocus => 1, -cursor => hand2, -font => "Arial 10 bold", -command => sub{exit} )->pack; $button1 ->configure(state => 'disabled'); # If the number of online servers equals the successes in user # tests, you have 100 percent replication. } elsif ( $ServerCounter == $SuccessCounter) { $main->Label(-padx => 10, -pady => 5, -wraplength => 175, -relief => groove, -text => "100% replication success has been verified on $USERID account on $ServerCounter servers")->pack; $main->Button(-text => 'Exit', -background => gray, -takefocus => 1, -cursor => hand2, -font => "Arial 10 bold", -command => sub{exit} )->pack; $button1 ->configure(state => 'disabled'); # If the number of success on the user test equals 0, you # probably have another problem. } elsif ($SuccessCounter == 0) { print "$Success% replication success.\n"; $main->Label(-padx => 10, -pady => 5, -wraplength => 175, -relief => groove, -text => "0% replication success on $USERID account $ServerCounter servers suggest that user ID may be incorrectly entered. Please verify...")->pack; $main->Button(-text => 'Exit', -background => gray, -takefocus => 1, -cursor => hand2, -font => "Arial 10 bold", -command => sub{exit} )->pack; $button1 ->configure(state => 'disabled'); # Do the math to figure out the percentage of user test successes # given the number of online servers. } else { $Success = ($SuccessCounter/$ServerCounter) * 100; $Success=sprintf("%5.1f", "$Success"); print "$Success% replication success.\n"; $main->Label(-padx => 10, -pady => 5, -wraplength => 175, -relief => groove, -text => "$Success% replication success on $USERID account $ServerCounter servers")->pack; $main->Button(-text => 'Exit', -background => gray, -takefocus => 1, -cursor => hand2, -font => "Arial 10 bold", -command => sub{exit} )->pack; $button1 ->configure(state => 'disabled'); } }