Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 05-30-2007, 08:45 AM   #1 (permalink)
 
True Techie

Join Date: Feb 2004

Posts: 196

star_topology

Default Help With SubOUs (VBS)

Hello,

I'm trying to refine a script I got from computerperformance.co.uk in regards to resetting passwords on an OU in Active Directory. I would like to drill down to the sub OU in my domain that I have specified. For explanation purposes, I have an OU, "High School" and four sub-OUs "Freshmen" "Sophomores" etc. The script only resets passwords that are in the main OU "High School." Any help would be appreciated.

--------------------------
' pw_reset.vbs

Option Explicit
Dim objOU, objUser, objRootDSE
Dim strContainer, strDNSDomain, strPassword
Dim intCounter, intAccValue, intPwdValue, intpwdLastSet

strContainer = "OU=High School,"
strPassword = "l33tsauce*"
intAccValue = 544
intPwdValue = 0
intCounter = 0
intpwdLastSet = 0

' -------------------------------------------------------'
' Makes the user change l33tsauce* password at first logon
' intpwdLastSet = 0 sets "Password Must be Changed at next 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

objUser.Put "userAccountControl", intAccValue
objUser.SetInfo
intCounter = intCounter +1
End if
next

WScript.Echo strPassword & " is the password. UserAccountValue = " _
& intAccValue & vbCr & intCounter & " accounts changed"
WScript.Quit

--------------------------
__________________
*\'Failure\' is not a four-letter word.
star_topology is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On