Unlock user account
This script will check if a user account is locked (due to several failed logon attempts) and if it is then unlock it and send me an email.
The reason for this script was that we have a kind of general user account that is among other things used for authenticating against a web tool. This link is placed on users desktop with the username and password hardcoded into the url like this:
http://webuser:password@servername/abcde
Now, users sometimes think that they can type servername/abcde into the link box in IE and get away with it, but when they do this they’ll only get presented with the username and password box and they’ll try to enter webuser (some of them know that it’s running under this account) and whatever as password and the account gets locked out.
Now, this is no good as noone can use this system all of a sudden. And if I’m sitting outside in the sunshine having my lunch then they’ll call me - and I don’t want that!
Checkwebuser.vbs
'Check if the Operator account is locked and
'if it is then unlock it and email me
Set objUser = GetObject _
("LDAP://cn=webuser,ou=it,ou=users,ou=luxembourg,dc=domain,dc=prv")
If objUser.IsAccountLocked = True Then
objUser.IsAccountLocked = False
objUser.SetInfo
Set objEmail = CreateObject("CDO.Message")
With objEmail
.From = "job_LuxChris@mydomain.com"
.To = "cjarnaker@mydomain.com"
.Subject = "The operator account has been unlocked"
'.TextBody = ""
'.AddAttachment ""
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "luxmail"
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Configuration.Fields.Update
.Send
End With
WScript.Echo "The operator account has been unlocked."
Else
WScript.Echo "Account not locked."
End If
WScript.Quit
This script is scheduled to run every 5 minutes on my workstation with this command line:
C:\\WINDOWS\\system32\\cscript.exe c:\\jobs\\checkwebuser.vbs
