AC_UK
asked on
Setting AD user attributes programatically
Hello,
I am trying to write a few scripts that will in basic terms adds the "User must change password on next logon" flag and removes the "Password never expries flag"
Done a fair bit of searching but nothing as yet.
These scripts are to be run on XP SP1 / SP2. Pref VBS, Dos or WSI
I am trying to write a few scripts that will in basic terms adds the "User must change password on next logon" flag and removes the "Password never expries flag"
Done a fair bit of searching but nothing as yet.
These scripts are to be run on XP SP1 / SP2. Pref VBS, Dos or WSI
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The first example does what I want almost.......
It does need to remove the flag for " Password never expires" at the same time
Also I need the option to import a list of names rather than just target a sinlge OU.
If you can manage that you have the points.
It does need to remove the flag for " Password never expires" at the same time
Also I need the option to import a list of names rather than just target a sinlge OU.
If you can manage that you have the points.
You mean you want to set here "OU=Accounts" with a list of OUs instead of Accounts?
ASKER
All done with that anyway. Thanks for the Script.
You are welcome.
Option Explicit
Dim objOU, objUser, objRootDSE, objShell
Dim strContainer, strDNSDomain, strPassword
Dim intPwdValue
' Bind to Active Directory Domain
Set objRootDSE = GetObject("LDAP://RootDSE"
strDNSDomain = objRootDSE.Get("DefaultNam
' --------------------------
' Important change OU= to reflect your domain
' --------------------------
strContainer = "OU=Accounts, "
strPassword = "P@ssw0rd"
strContainer = strContainer & strDNSDomain
' Here we force a change of password at next logon
intPwdValue = 0
' Loop through OU=, setting passwords for all users
set objOU =GetObject("LDAP://" & strContainer )
For each objUser in objOU
If objUser.class="user" then
objUser.SetPassword strPassword
objUser.Put "PwdLastSet", intPwdValue
objUser.SetInfo
End If
Next
' Optional section to launch Active Directory Uses and Computers
Set objShell=CreateObject("WSc
objShell.Run "%systemroot%\system32\dsa
WScript.Quit
' End of Sample PwdLastSet Advanced VBScript