Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Change Password for everyone in a OU

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,25757
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Change Password for everyone in a OU
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Change Password for everyone in a OU - 9/8/2005 7:36:07 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Guys.

Does anyone know how i could change this script so that is will walk through an OU and change the password for each user in that OU?


Set objUser = GetObject _
   ("LDAP://cn=MyerKen,ou=management,dc=fabrikam,dc=com")

objUser.SetPassword "i5A2sj*!"


Many thanks for your help on this

< Message edited by cjwallace -- 9/8/2005 7:45:00 PM >
 
 
Post #: 1
 
 RE: Change Password for everyone in a OU - 9/8/2005 8:38:54 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Not to worry. I have found a script to walk through a OU and change the passwords

Option Explicit
Dim objOU, objUser, objRootDSE
Dim strContainer, strDNSDomain, strPassword
Dim intCounter, intAccValue, intPwdValue
' --------------------------------------------------------'
' Note: Please change OU=nowhere, to reflect your domain
' --------------------------------------------------------'
strContainer = "OU=TEST,OU=LONDON USERS,OU=WITHERS USERS,"
strPassword = "Passw0rd"
intAccValue = 544
rem Unrem line 58 and also unrem line 73 to force the user to reset the their
rem password at next logon.
rem intPwdValue = 0
intCounter = 0
' -------------------------------------------------------'
' Makes the user change Passw0rd1 password at first logon
' -------------------------------------------------------'
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
strContainer = strContainer & strDNSDomain
Set objOU =GetObject("LDAP://" & strContainer )
For Each objUser In objOU
If objUser.class="user" Then
objUser.SetPassword strPassword
objUser.SetInfo
rem objUser.Put "pwdLastSet", intPwdValue
objUser.SetInfo
objUser.Put "userAccountControl", intAccValue
objUser.SetInfo
intCounter = intCounter +1
End If
Next
WScript.Echo strPassword & " is Password. UserAccountValue = " _
& intAccValue & vbCr & intCounter & " accounts changed"
WScript.Quit
' End of change password example VBScript

(in reply to cjwallace)
 
 
Post #: 2
 
 RE: Change Password for everyone in a OU - 9/8/2005 8:43:44 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Set objOU = GetObject("LDAP://*")
strPassword = "NewPassword"
objOU.Filter = array("user")"
for Each objUser in objOU
If objUser.class="user" Then
objUser.SetPassword strPassword
objUser.SetInfo
rem objUser.Put "pwdLastSet", intPwdValue
objUser.SetInfo
objUser.Put "userAccountControl", intAccValue
objUser.SetInfo
next



//edit:  Oops too late....

< Message edited by Snipah -- 9/8/2005 8:44:48 PM >


_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to cjwallace)
 
 
Post #: 3
 
 RE: Change Password for everyone in a OU - 9/8/2005 9:00:32 PM   
  cjwallace

 

Posts: 491
Score: 0
Joined: 3/5/2005
From: United Kingdom
Status: offline
Thanks for the reply though mate. Mnay thanks

(in reply to Snipah)
 
 
Post #: 4
 
 RE: Change Password for everyone in a OU - 9/9/2005 6:51:56 AM   
  royb5000

 

Posts: 54
Score: 0
Joined: 5/4/2005
From: USA
Status: offline
I was just curious, how does yours work, does it let you go in and give each person a separate password, or the same one?  Just curious because I have one that does everybody in an ou to the exact same password.  Thanks.

(in reply to cjwallace)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Change Password for everyone in a OU Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts