+ Reply to Thread
Results 1 to 15 of 15

Thread: Password Reset Script - Working But Need Alterations.

  Share/Bookmark
  1. #1

    Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation
    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    Rochdale, Lancashire
    Posts
    8,826
    Thank Post
    309
    Thanked 612 Times in 555 Posts
    Rep Power
    120

    Default Password Reset Script - Working But Need Alterations.

    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.


    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
    Would i put something like this in?

    if NOT userou = "Students" then call notstudentaccount
    But where would i put that?

    Thanks alot

  2. #2

    Reputation Reputation
    Shane's Avatar
    Join Date
    Apr 2007
    Location
    Kernow
    Posts
    167
    Thank Post
    23
    Thanked 14 Times in 12 Posts
    Rep Power
    13

    Default

    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.

  3. #3

    Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation
    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    Rochdale, Lancashire
    Posts
    8,826
    Thank Post
    309
    Thanked 612 Times in 555 Posts
    Rep Power
    120

    Default

    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.

  4. #4

    Reputation Reputation
    Shane's Avatar
    Join Date
    Apr 2007
    Location
    Kernow
    Posts
    167
    Thank Post
    23
    Thanked 14 Times in 12 Posts
    Rep Power
    13

    Default

    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?

  5. #5

    Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation
    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    Rochdale, Lancashire
    Posts
    8,826
    Thank Post
    309
    Thanked 612 Times in 555 Posts
    Rep Power
    120

    Default

    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.

  6. #6

    Reputation Reputation Reputation Reputation Reputation Reputation
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,605
    Thank Post
    33
    Thanked 123 Times in 113 Posts
    Rep Power
    41

    Default

    You need to change this line:

    Code:
    Set oUser = GetObject("WinNT://" & sDomain & "/" & sUserName & _
    ",user")
    
    To use an ldap path method like:

    Code:
    Set oUser = GetObject("LDAP://cn=" & sUserName & ",ou=students,dc=MyDomain,dc=com")
    
    Thats no 100% accurate but you get the idea. You will also need some error trapping incase its not found etc.

  7. #7

    Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation
    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    Rochdale, Lancashire
    Posts
    8,826
    Thank Post
    309
    Thanked 612 Times in 555 Posts
    Rep Power
    120

    Default

    What if they are in an ou that lives under students? Will it still work please?

    Thanks

  8. #8

    Reputation Reputation Reputation Reputation Reputation Reputation
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,605
    Thank Post
    33
    Thanked 123 Times in 113 Posts
    Rep Power
    41

    Default

    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

  9. #9

    Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation
    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    Rochdale, Lancashire
    Posts
    8,826
    Thank Post
    309
    Thanked 612 Times in 555 Posts
    Rep Power
    120

    Default

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

    Thanks

    Z

  10. #10

    Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation
    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    Rochdale, Lancashire
    Posts
    8,826
    Thank Post
    309
    Thanked 612 Times in 555 Posts
    Rep Power
    120

    Default

    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

  11. #11

    Reputation
    Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation
    webman's Avatar
    Join Date
    Nov 2005
    Location
    County Durham
    Posts
    7,475
    Blog Entries
    2
    Thank Post
    535
    Thanked 589 Times in 432 Posts
    Rep Power
    168

  12. #12

    Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation
    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    Rochdale, Lancashire
    Posts
    8,826
    Thank Post
    309
    Thanked 612 Times in 555 Posts
    Rep Power
    120

    Default

    ok so i have this

    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
    how do i get that to work how i want it to please?

  13. #13

    Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation
    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    4,034
    Thank Post
    196
    Thanked 291 Times in 270 Posts
    Rep Power
    76

    Default

    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.

  14. #14

    Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation
    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    Rochdale, Lancashire
    Posts
    8,826
    Thank Post
    309
    Thanked 612 Times in 555 Posts
    Rep Power
    120

    Default

    I would but im not sure what does what

  15. #15

    Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation Reputation
    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    Rochdale, Lancashire
    Posts
    8,826
    Thank Post
    309
    Thanked 612 Times in 555 Posts
    Rep Power
    120

    Default

    **BUMP**

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. Self Service Password Reset
    By plexer in forum EduGeek Self Service Password Reset
    Replies: 259
    Last Post: 15-07-2010, 01:41 PM
  2. Local admin password reset?
    By sidewinder in forum Windows
    Replies: 13
    Last Post: 15-10-2009, 07:26 PM
  3. Replies: 15
    Last Post: 28-08-2009, 09:55 AM
  4. reset admin password
    By fafster in forum Windows
    Replies: 11
    Last Post: 27-02-2008, 10:01 AM
  5. bulk password reset
    By Jonny_sims in forum Windows
    Replies: 8
    Last Post: 04-09-2007, 10:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts