Account Unlocker Utility
Imagine that you need a utility that quickly enables and unlocks an NT or Active Directory user account. The account was locked because the password was entered incorrectly too many times in succession or because the account exceeded its expiration date. Writing a user-specific script is inefficient if you have many users. Using an input file to pass in the needed user data to a script also is inefficient. You’d have to create the input file just before running the script, because you can’t predict whose account you need to unlock. The best approach is to use command-line arguments to pass in the user data as you need it.
Example 21-5 and Example 21-6 use this approach to enable and unlock NT and Active Directory user accounts, respectively. If you have a mixed NT and Active Directory network, you can even combine these two utilities into one script.
Example 21-5 implements the unlocker with the WinNT provider.
Example 21-5. Account unlocker utility for Windows NT
'********************************************************************** 'How to unlock and enable a Windows NT user via arguments to this script ' 'Parameters should be <domain> <username> '********************************************************************** Option Explicit Dim wshArgs, objUser, strOutput On Error Resume Next '********************************************************************** 'Get the arguments '********************************************************************** Set wshArgs ...
Get Active Directory, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.