Copy the code into notepad, make necessary changes to reflect your domain and organizational units, change the number in the array to reflect the number of organizational units, and save with a .hta extension.
Note: the array amount starts counting at 0. Therefore if you have 5 organizational units, the array would be For i=0 to 4. Also, currently, this code resets a user's password to "P@ssw0rd."
<head>
<title>Change Password</title>
<HTA:APPLICATION
APPLICATIONNAME="Change Password"
SCROLL="No"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
MAXIMIZEBUTTON="no"
ICON="C:/iconlocation/icon.ico"
>
</head>
<script language="VBScript">
Sub Window_onLoad
window.resizeTo 400,250
strUserbox.Focus
End Sub
Sub Password
On Error Resume Next
Dim strUser
Dim objUser
Dim arrOU
Dim objRootDSE
Dim strDNSDomain
Dim errorVal
arrOU = Array("OU=Sales","OU=Admin","OU=Clerical","OU=Engineers","OU=Executive Staff","OU=Others","OU=More Others","OU=Trainees","OU=Temps")
strUser = struserbox.value
errorValue = 1
For i=0 to 8
Set objUser = GetObject("LDAP://sAMAccountName=" & strUser & ",OU=Users," & arrOU(i) & ",DC=domain,DC=com")
If Err.Number <> -2147016656 Then
errorValue = 0
End If
objUser.SetPassword("P@ssw0rd")
If changePass.Checked Then
objUser.Put "PwdLastSet", 0
objUser.SetInfo
End If
Set objUser = nothing
Next
If errorValue = 1 Then
Msgbox "Account does not exist: " & strUser
errorValue = 0
Else
Msgbox "Password for " & strUser & " has been reset."
End If
strUserbox.value = ""
strUserbox.Focus
changePass.checked=False
End Sub
Sub RunScript
If window.event.Keycode = 13 Then
call Password()
End If
End Sub
</script>
<body STYLE="font:14 pt arial; color:white;
filter:progid:DXImageTransform.Microsoft.Gradient
(GradientType=1, StartColorStr='#000000', EndColorStr='#0000FF')"onkeypress="RunScript">
<center>Enter Username: <P>
<input type="text" name="strUserbox" size="30"><P>
<input type="button" value=" OK " name="run_button" onClick="Password"><p>
<input type="checkbox" name="changePass"> Check this box to force a password change on next login.
</center>
</body>
I hope this helps.
No comments:
Post a Comment