JSI Tip 10290. How can a script set a domain user's password?

Jerold Schulman

March 20, 2006

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

I have scripted DomUsrPwd.bat to set a domain user's password, using the LDAP provider.

The syntax for using DomUsrPwd.bat is:

Call DomUsrPwd UserDN PassPhrase

Where:

UserDN     is the user's distinguished name, like "CN=Jordan Valley,CN=Users,DC=JSIINC,DC=COM".PassPhrase is the new password, like "My 3 dogs are very BIG!".

DomUsrPwd.bat contains:

@echo offif {%2}=={} @echo Syntax: DomUsrPwd UserDN PassPhrase&goto :EOFif exist "%TEMP%DomUsrPwd.vbs" goto :doit@echo Dim oArgs, strUserDN, strNewPasswd>"%TEMP%DomUsrPwd.vbs"@echo Set oArgs = WScript.Arguments>>"%TEMP%DomUsrPwd.vbs"@echo strUserDN = oArgs(0)>>"%TEMP%DomUsrPwd.vbs"@echo strNewPasswd = oArgs(1)>>"%TEMP%DomUsrPwd.vbs"@echo Set objUser = GetObject("LDAP://" ^& strUserDN)>>"%TEMP%DomUsrPwd.vbs"@echo objUser.SetPassword(strNewPasswd)>>"%TEMP%DomUsrPwd.vbs":doitcscript //nologo "%TEMP%DomUsrPwd.vbs" %1 %2



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