CynPro

CynPro - Code to change user passwords.

Jul 6th, 2011
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. '************************************************************************
  2. '* This script is for all user management needs.
  3. '* computer running Win2K or WinNT w/WMI installed.
  4. '************************************************************************
  5.  
  6. Option Explicit
  7. On Error Resume Next
  8. Dim User , LstNm , Acry , dlg , UserName, MSG ,Prop , result,domainname,newpass
  9. domainname = InputBox("Please enter domain name: " & vbcrlf & "If you leave it blank the domain name will be accepted as DOMAIN. " , "Domain Information")
  10. if domainname = "" then domainname = "DOMAIN"
  11. call main()
  12. sub main()
  13. UserName = InputBox("Please enter UserName: ", "User Information")
  14. set User = GetObject("WinNT://" + domainname + "/" + UserName)
  15. If User.Name = "" Then
  16. Dim wu
  17. wu = MsgBox("UserName is not specified." & vbcrlf & vbcrlf & "Do you want to enter another name?",4,"No such user")
  18. msgbox wu
  19. if wu=6 then call main else exit sub
  20. Else
  21. MSG= vbCRLf
  22. MSG = MSG & "User (ID): " & UserName & vbcrlf
  23. MSG = MSG & "Full Name: " & User.FullName & vbcrlf
  24. MSG = MSG & "Description: " & User.Description & vbcrlf
  25. MSG = MSG & vbcrlf
  26. MSG = MSG & "Group Membership " & vbcrlf
  27. For Each Prop In User.groups
  28. MSG = MSG & " " & Prop.Name & vbcrlf
  29. Next 'Prop
  30. Acry = Instr(1, User.FullName, ", ", 1)
  31. 'LstNm = Left(User.FullName, Acry - 1)
  32. If User.IsAccountLocked = -1 Then
  33. MSG = MSG & vbcrlf
  34. MSG = MSG & "Account Status: Locked" & vbcrlf
  35. Else
  36. MSG = MSG & vbcrlf
  37. MSG = MSG & "Account Status: Active" & vbcrlf
  38. End if
  39. 'If User.LastLogin < 0 Then
  40. 'MSG = MSG & vbcrlf
  41. 'MSG = MSG & LstNm & " is not logged on to domain." & vbcrlf
  42. 'Else
  43. 'MSG = MSG & vbcrlf
  44. 'MSG = MSG & LstNm & " Last" & vbCRLF & "User Logon" & vbCRLF & "Time: " & User.LastLogin & vbcrlf
  45. 'End if
  46. If User.IsAccountLocked = -1 Then
  47. MSG = MSG & vbcrlf
  48. MSG = MSG & "Do you want to unlock " & vbcrlf
  49. result=msgbox (msg,4,Username & " Status")
  50. Else
  51. MSG = MSG & vbcrlf
  52. MSG = MSG & "The user is not locked out." & vbcrlf
  53. result=msgbox (msg,0,Username & " Status")
  54. End if
  55. if result=6 then
  56. User.IsAccountLocked = 0
  57. User.SetInfo
  58. result = msgbox(username & " has been unlocked successfully.")
  59. end if
  60. result = msgbox (username & " Attempt to change the password of the user?",4,"Password")
  61. if result = 6 then
  62. newpass = InputBox(" Please enter the user's new password : ", "New Password")
  63. Call User.SetPassword(NewPass)
  64. result = msgbox (username & " The password has been changed successfully.",0,"Password change")
  65. end if
  66. result = msgbox (username & " user is allowed to change his/her password" & vbcrlf & "at next logon?",4,"Authorization State")
  67. if result = 6 then
  68. User.passwordexpired = 1
  69. User.SetInfo
  70. result = msgbox (username & " will be able to change his/her password at next logon.",0,"Status Change")
  71. end if
  72. set User = nothing
  73. set LstNm = nothing
  74. set Acry = nothing
  75. set wu = nothing
  76. End If
  77. wu = MsgBox("Do you want to enter another user name?",4,"New User")
  78. if wu=6 then call main
  79. end sub
Add Comment
Please, Sign In to add comment