Misaro said:
I need to apply it to all users in differents OU's at the
same time .you talked about an script I would like to find
it and if you can do it Explain me how may I use it ?
Hi
Put the VBScript below in a .vbs file and run it by double clicking on
it in Explorer. It will put out a message box for each OU it is about
to process (press OK to let the script continue).
You will need to create a text file with the OU paths where there are
users you want to expire the password for (update the path in the sFile
variable to correct path/name).
The text file with the OU list needs to be like this, each full OU path
on a seperate line:
OU=Spain,OU=Users
OU=Test,OU=Spain,OU=Users
The VBScript file:
'--------------------8<----------------------
Const OpenAsDefault = -2
Const FailIfNotExist = 0
Const ForReading = 1
sFile = "c:\scripts\OUList.txt"
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set fFile = oFSO.OpenTextFile(sFile, ForReading, _
FailIfNotExist, OpenAsDefault)
aOUs = Split(fFile.ReadAll, vbNewLine)
fFile.Close
' Determine the DNS domain from the RootDSE object.
Set oRootDSE = GetObject("LDAP://RootDSE")
sDNSDomain = oRootDSE.Get("defaultNamingContext")
' verify that we can connect to all OUs before we start
' modifying the user objects
For Each sOU In aOUs
If sOU <> "" Then
On Error Resume Next
sLDAPPath = "LDAP://" & sOU & "," & sDNSDomain
Set oTargetOU = GetObject(sLDAPPath)
If Err.Number <> 0 Then
MsgBox "Quitting (no users changed), could not connect to path " _
& sLDAPPath, vbCritical + vbSystemModal, "Expire Password"
WScript.Quit
End If
End If
Next
On Error Goto 0
' start changing the user objects
For Each sOU In aOUs
If sOU <> "" Then
sLDAPPath = "LDAP://" & sOU & "," & sDNSDomain
MsgBox "About to enumerate users in path " & sLDAPPath, _
vbInformation + vbSystemModal, "Expire Password"
Set oTargetOU = GetObject(sLDAPPath)
oTargetOU.Filter = Array("user")
For Each oUser In oTargetOU
If Left(oUser.ObjectCategory, 9) = "CN=Person" Then
oUser.pwdLastSet = Clng(0)
' Save changes
oUser.SetInfo
End If
Next
End If
Next
MsgBox "Done!", vbInformation + vbSystemModal, "Expire Password"
'--------------------8<----------------------