
We have this password reset script it works fine. How do i make an alteration so that it will only reset password an OU called "students" please?
This is our script.
Would i put something like this in?
Dim sUserName, sDomain, oUser, oNet, sComputer, pw, vbClrf, _
sPword2, sPword3, oComputer
sUserName = InputBox("Please type Username", "Password Change")
bConfirm = MsgBox ("Password to be reset, are you sure?", 4, sUsername)
If bConfirm = 7 then wscript.Quit
Set oNet = CreateObject("Wscript.Network")
sDomain = "HCHS"
sPword = "football"
sComputer = oNet.ComputerName
Set oUser = GetObject("WinNT://" & sDomain & "/" & sUserName & _
",user")
oUser.SetPassword sPword
oUser.Put "PasswordExpired", 1
oUser.SetInfo
WScript.Echo "The password for user account " & chr(13) & chr(13) & sUserName & chr(13) & chr(13) & " in domain " & sDomain & " has been reset to football."
'Additional script to log the changing of passwords
'Dim filesys, testfile
'Set filesys = CreateObject("Scripting.FileSystemObject")
'Set testfile= filesys.CreateTextFile("passwords.txt", True)
'testfile.WriteLine sUsername
'testfile.Close
dim filesys, filetxt
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile("passwords.txt", ForAppending, True)
filetxt.WriteLine sUsername & " , Password reset , " & date & " , " & Time
filetxt.Close
But where would i put that?if NOT userou = "Students" then call notstudentaccount
Thanks alot
What is it that you want to happen if the user is not from the student group?
Sorry, can't really say where to put it without knowing what action you would like taken.

Hi
I just want the script to reset passwords on accounts that come under an ou call students. Basically i don't want it able to reset staff and service account passwords.
So the script will bulk change all student users to the same password or are you sticking with current method of typing in each user you want to change?

This is for teachers use. They will type the student’s username in and it will reset the password. I want to make it so it will only reset student passwords.
You need to change this line:
To use an ldap path method like:Code:Set oUser = GetObject("WinNT://" & sDomain & "/" & sUserName & _ ",user")
Thats no 100% accurate but you get the idea. You will also need some error trapping incase its not found etc.Code:Set oUser = GetObject("LDAP://cn=" & sUserName & ",ou=students,dc=MyDomain,dc=com")

What if they are in an ou that lives under students? Will it still work please?
Thanks
you need to work out the full LDAP path you work backwards eg if the ou was students > Year 7 the path would be
cn=joe bloggs,ou=year7,ou=students,dc=MyDomain,dc=com

ok, is it possible so it will only reset passwords for users in a particular group?
Thanks
Z

Just going to give this a bump
is it possible to configure it so it will only reset passwords for users in a particular group please?
Thanks

http://www.sanx.org/tipShow.asp?index=66
Found using Google.

ok so i have this
how do i get that to work how i want it to please?Private Function IsMember(groupName)
Set netObj = CreateObject("WScript.Network")
domain = netObj.UserDomain
user = netObj.UserName
flgIsMember = false
Set userObj = GetObject("WinNT://" & domain & "/" & user & ",user")
For Each grp In userObj.Groups
If grp.Name = groupName Then
flgIsMember = true
Exit For
End If
Next
IsMember = flgIsMember
Set userObj = nothing
Set netObj = nothing
End Function
I would suggest first reading through the code and trying to identify what each part does. Then look at your script and work out what each part does. Then try and combine the code to get what you need. The code you posted checks that a user is part of a group and then returns either a true or false value. So if true you want the password to be changed and if false you perhaps want to display some sort of error message.

I would but im not sure what does what

**BUMP**
There are currently 1 users browsing this thread. (0 members and 1 guests)