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

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 off
if \{%2\}==\{\} @echo Syntax: DomUsrPwd UserDN PassPhrase&goto :EOF
if 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"
:doit
cscript //nologo "%TEMP%\DomUsrPwd.vbs" %1 %2



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish