+ Post New Thread
Results 1 to 15 of 15
Scripts Thread, Password Reset Script - Working But Need Alterations. in Coding and Web Development; We have this password reset script it works fine. How do i make an alteration so that it will only ...
  1. #1

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454

    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
    Shane's Avatar
    Join Date
    Apr 2007
    Location
    Kernow
    Posts
    166
    Thank Post
    23
    Thanked 14 Times in 12 Posts
    Rep Power
    22
    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

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454
    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
    Shane's Avatar
    Join Date
    Apr 2007
    Location
    Kernow
    Posts
    166
    Thank Post
    23
    Thanked 14 Times in 12 Posts
    Rep Power
    22
    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

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454
    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
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,987
    Thank Post
    120
    Thanked 283 Times in 261 Posts
    Rep Power
    107
    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

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454
    What if they are in an ou that lives under students? Will it still work please?

    Thanks

  8. #8
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,987
    Thank Post
    120
    Thanked 283 Times in 261 Posts
    Rep Power
    107
    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

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454
    ok, is it possible so it will only reset passwords for users in a particular group?

    Thanks

    Z

  10. #10

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454
    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

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,408
    Thank Post
    640
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    326

  12. #12

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454
    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

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,161
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    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

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454
    I would but im not sure what does what

  15. #15

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,058
    Thank Post
    888
    Thanked 1,731 Times in 1,494 Posts
    Blog Entries
    12
    Rep Power
    454
    **BUMP**

SHARE:
+ Post New Thread

Similar Threads

  1. Self Service Password Reset
    By plexer in forum EduGeek Self Service Password Reset
    Replies: 273
    Last Post: 5th November 2013, 06:51 PM
  2. bulk password reset
    By Jonny_sims in forum Windows
    Replies: 10
    Last Post: 26th September 2011, 10:12 PM
  3. Local admin password reset?
    By sidewinder in forum Windows
    Replies: 13
    Last Post: 15th October 2009, 07:26 PM
  4. Replies: 15
    Last Post: 28th August 2009, 09:55 AM
  5. reset admin password
    By fafster in forum Windows
    Replies: 11
    Last Post: 27th February 2008, 10:01 AM

Thread Information

Users Browsing this Thread

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

Posting Permissions

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