BULK password reset and flag setting

  • Thread starter Thread starter quickslip
  • Start date Start date
Q

quickslip

Guest
Re: BULK password reset and flag setting

quickslip wrote:

> I have a need to reset all user objects in one of our AD containers to
> the same password as well as set the flag to immediately prompt for
> change. Does anyone have a quick and easy way to do this within a w2k3
> environment?


I think this can be done with command line utilities, but a VBScript program
could do this with code similar to:
=========
' Specify the Distinguished Name of the OU.
strOU = "ou=West,dc=MyDomain,dc=com"

' Specify the new password for all users in the OU.
strPassword = "xyz321"

' Bind to the OU.
Set objOU = GetObject("LDAP://" & strOU)

' Filter on user objects.
objOU.Filter = Array("user")

' Enumerate all users in the OU
For Each objUser In objOU
' Set the password.
objUser.SetPassword = strPassword
' Expire the account, so user is prompted to change
' it at the next logon.
objUser.pwdLastSet = 0
' Save changes.
objUser.SetInfo
Next

Wscript.Echo "Done"
===========
You could also have the script prompt for the new password by replacing:

strPassword = "xyz321"

with

strPassword = InputBox("Enter new password")

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
 
Back
Top