Downloads
20798.zip

I want to use Windows Script Host (WSH) to create Windows NT 4.0 user accounts. I'd like to initially set the password to somepassword for new users, then have them change their password when they first log on. How can I programmatically select the User must change password at next logon check box so that NT tells users to change their password?

You can use the Microsoft Active Directory Service Interfaces (ADSI) WinNT provider to programmatically enable the User must change password at next logon option for SAM-based user accounts. As the code in Listing 2 shows, you must first obtain a reference to the appropriate User object, then you can set that object's PasswordExpired property to 1. Finally, you use the SetInfo method to write the change from the cache to the SAM. To use the code in Listing 2, you need to replace DomainName and UserName with the names of your domain and user, respectively.

You can find more information about the PasswordExpired property, including sample code, at http://msdn.microsoft.com/library/psdk/adsi/ds2pnt4_85ke.htm. For general information about ADSI, go to http://www.microsoft.com/windows2000/library/howitworks/activedirectory/adsilinks.asp. This site includes links to download ADSI 2.5 and the ADSI software development kit (SDK).