I've been trying to use the Net User command to reset users' passwords in a .bat script, but the script won't set the User must change password at next logon flag. How can I set this flag?
The Net User command doesn't provide an option to enable the User must change password at next logon flag. However, you can use Active Directory Service Interfaces (ADSI) or a third-party command-line utility to accomplish this task.
Using ADSI to set this flag is a three-step operation:
- Bind (i.e., connect) to the target user account.
- Set the user account's logon option.
- Commit the change to the directory.
Listing 2, page 12, shows the code you use to perform this operation on a Windows NT SAM user account. Listing 3, page 12, shows the code to perform the same operation on a Windows 2000 Active Directory (AD) user account. If you prefer to use a command-line tool, you can purchase Pukka International's NetUser tool at http://www.pukka.com/products/default.asp?productid=nu1%2e0.