JSI Tip 10414. How can I force a user to change their password at next logon, using the WinNT provider?

Jerold Schulman

April 18, 2006

1 Min Read
ITPro Today logo in a gray background | ITPro Today


To force a user to change their password at next logon, you could use the following VBScript:

Dim usrSet usr = GetObject("WinNT://NetBIOSDomainName/UserLogonName,user")usr.Put "PasswordExpired", CLng(1)usr.SetInfo

Where:

NetBIOSDomainName is the NetBIOS Domain Name, like JSIINC.UserLogonName     is the user logon name, like Jerry.

NOTE: To clear the User must change password at next logon flag, change CLng(1) to CLng(0).

I have scripted MCPANL.bat to force a user to change their password at next logon.

The syntax for using MCPANL.bat is:

[Call] MCPANL NetBIOSDomainName UserLogonName

MCPANL.bat contains:

@echo offif {%2}=={} @echo Syntax: MCPANL NetBIOSDomainName UserLogonName&goto :EOFsetlocalset dom=%1set usr=%2if exist "%TEMP%MCPANL.VBS" goto [email protected] usr, objArguments>"%TEMP%MCPANL.VBS"@echo set objArguments = Wscript.Arguments>>"%TEMP%MCPANL.VBS"@echo dom=objArguments(0)>>"%TEMP%MCPANL.VBS"@echo un=objArguments(1)>>"%TEMP%MCPANL.VBS"@echo ldp = "WinNT://" ^& dom ^& "/" ^& un ^& ",user">>"%TEMP%MCPANL.VBS"@echo Set usr = GetObject(ldp)>>"%TEMP%MCPANL.VBS"@echo usr.Put "PasswordExpired", CLng(1)>>"%TEMP%MCPANL.VBS"@echo usr.SetInfo>>"%TEMP%MCPANL.VBS":doitcscript //nologo "%TEMP%MCPANL.VBS" %dom% %usr%endlocal



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like