I know you wanted a Web Version, but here is something you might find Educational. I tried creating a Web Version, but I haven't had time to do it. But atleast I can give you something to look at. It only unlocks people that are locked out.
but it is always nice to see how someone else has done it.
use Win32::OLE;
use Win32::OLE 'in';
use Win32::OLE::Enum;
use Win32::NetAdmin;
@empty = ();
($sec,$min,$hour,$day,$mon,$yr,$wday,$yday,$dntcare)=localtime(time);
+
$yr-=100;
$yr="$yr";
$yr = (length($yr)<2) ? "0$yr" : $yr;
$mon = (++$mon < 10) ? "0$mon" : "$mon";
$day = ($day < 10) ? "0$day" : "$day";
$date = "unlock$day-$mon-$yr.txt";
open (UNLOCK , ">>$date") || die "Can\\'t Create file";
while ( $choice != 7 ) {
system(cls);
print "===============================================================
+===========\n";
print "This Program Will Unlock Users on the Network. Enter the \n";
print "Number for the location and press the Enter Key\n";
print "Created by: Steve Sherman\n";
print "===============================================================
+===========\n";
print "\n";
print "\n";
print "1) Main\n";
print "2) Regional\n";
print "3) Cuba\n";
print "4) Union\n";
print "5) Motor\n";
print "6) Labadie\n";
print "7) Exit\n\n";
$choice = <stdin>;
chomp($choice);
sub Localuser {
if (Win32::NetAdmin::LoggedOnUsers($server,\%userRef)) {
print UNLOCK "User: " . $userRef{1} . " Unlocked the Following user\n"
+;
@local = split(/;/,$userRef{1});
my $accesslocal = Win32::OLE->GetObject("LDAP://$local[0]");
foreach $group (in $accesslocal->{memberof}) {
push(@groups, $group);
print "$group\n";
}
}
}
sub Lookup {
my $adsuser = Win32::OLE->GetObject("LDAP://bos-ad01/ou=$location,dc=a
+sdf,dc=com") || die ("Can't find user:
".Win32::OLE->LastError()."\n");
$strDomain = "adsg";
$num = 1;
foreach $strUsername (in $adsuser){
my $objUser = Win32::OLE->GetObject("WinNT://$strDomai
+n/$strUsername->
{sAMAccountName}");
if ($objUser->{IsAccountLocked} == 1) {
#$objUser->{IsAccountLocked} = 0;
#$objUser->SetInfo;
print "$num) $strUsername->{sAMAccountName}\n";
push(@users, $strUsername->{sAMAccountName});
push(@DnUsers, $strUsername->{distinguishedName}
+);
$num++;
}
}#end foreach
if (@users == @empty) {
print "No Users to Unlock \n\n";
}
}
sub unlock {
if (@users == @empty) {
next;
}
if ($choice == 0) {
next;
}
$choice = $choice - 1;
my $objUser = Win32::OLE->GetObject("LDAP://bos-ad01/$DnUsers[$cho
+ice]");
print "$!\n";
$objUser->{IsAccountLocked} = 0;
$objUser->SetInfo();
Localuser();
print UNLOCK "$users[$choice]\n";
print UNLOCK "$day-$mon-$yr\n\n";
@users = ();
@DnUsers = ();
}
if ($choice == 1) {
$location = "main";
system(cls);
print "=======================================================
+===================\n";
print "Select The Number that is associated with the user you
+wish to unlock\n";
print "then press the Enter key.\n";
print "************************ WARNING WARNING WARNING ******
+*******************\n";
print "Please Only Unlock The user(s) that have requested to b
+e unlocked\n";
print "=======================================================
+===================\n";
Lookup();
print "0 ) Exit\n\n";
$choice = <stdin>;
unlock();
}
if ($choice == 2) {
$location = "Regional";
system(cls);
print "Select The User you wish to Unlock\n";
print "To Exit Press 0\n";
print "=====================================\n\n\n";
Lookup();
print "0 ) Exit\n\n";
$choice = <stdin>;
unlock();
}
if ($choice == 3) {
$location = "Cuba";
system(cls);
print "Select The User you wish to Unlock\n";
print "To Exit Press 0\n";
print "=====================================\n\n\n";
Lookup();
print "0 ) Exit\n\n";
$choice = <stdin>;
if ($choice > 0) {
unlock();
}
}
if ($choice == 4) {
$location = "Union";
system(cls);
print "Select The User you wish to Unlock\n";
print "To Exit Press 0\n";
print "=====================================\n\n\n";
Lookup();
print "0 ) Exit\n\n";
$choice = <stdin>;
if ($choice > 0) {
unlock();
}
}
if ($choice == 5) {
$location = "Main";
system(cls);
print "Select The User you wish to Unlock\n";
print "To Exit Press 0\n";
print "=====================================\n\n\n";
Lookup();
print "0 ) Exit\n\n";
$choice = <stdin>;
if ($choice > 0) {
unlock();
}
}
if ($choice == 6) {
$location = "Labadie";
system(cls);
print "Select The User you wish to Unlock\n";
print "To Exit Press 0\n";
print "=====================================\n\n\n";
Lookup();
print "0 ) Exit\n\n";
$choice = <stdin>;
if ($choice > 0) {
unlock();
}
}
}
|