Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. On Error Resume Next
  2.  
  3. strSchoolNumber = "[cut]"
  4. strLDAPContext = "OU=" & strSchoolNumber & ",OU=Schools,DC=[cut],DC=[cut]"
  5.  
  6.  
  7. Set objExplorer = WScript.CreateObject("InternetExplorer.Application", "IE_")
  8. objExplorer.Navigate "file:///\\[cut]\PasswordInterface.html"
  9. objExplorer.ToolBar = 0
  10. objExplorer.StatusBar = 0
  11. objExplorer.Width = 500
  12. objExplorer.Height = 300
  13. objExplorer.Left = 0
  14. objExplorer.Top = 0
  15. objExplorer.Visible = 1
  16. Do While (objExplorer.Document.All.OKClicked.Value = "")
  17. WScript.Sleep 250
  18. Loop
  19. strUserName = objExplorer.Document.All.UserBox.Value
  20. strPassword = objExplorer.Document.All.PasswordBox.Value
  21. strPassword2 = objExplorer.Document.All.PasswordBox2.Value
  22. objExplorer.Quit
  23. WScript.Sleep 250
  24.  
  25. 'WScript.Echo "User: " & strUserName & " Password: " & strPassword
  26.  
  27. 'WScript.Echo "The Password is: " & Len(strPassword) & " Characters Long."
  28.  
  29. set objConnection = CreateObject("ADODB.Connection")
  30. objConnection.Open "Provider=ADsDSOObject;"
  31.  
  32. set objCommand = CreateObject("ADODB.Command")
  33. objCommand.ActiveConnection = objConnection
  34.  
  35. objCommand.CommandText = "<LDAP://" & strLDAPContext & ">;" & _
  36. "(&(objectCategory=person)(objectClass=user)(SAMAccountName=" & Lcase(strUserName) & "));sAMAccountName, " & _
  37. "distinguishedName;subtree"
  38.  
  39. set objRecordSet = objCommand.Execute
  40.  
  41. AreYouThere = 0
  42.  
  43. While Not objRecordSet.EOF
  44. If Lcase(strUserName) = Lcase(objRecordSet.Fields("sAMAccountName")) Then
  45. ' WScript.Echo "LDAP sAMAccount: " & objRecordSet.Fields("sAMAccountName")
  46. ' WScript.Echo "LDAP Distinguished: " & objRecordSet.Fields("distinguishedName")
  47. strUserDistinguished = objRecordSet.Fields("distinguishedName")
  48. AreYouThere = 1
  49. End If
  50. objRecordSet.MoveNext
  51. Wend
  52.  
  53. objConnection.Close
  54.  
  55. If strPassword <> strPassword2 Then
  56. WScript.Echo "The passwords are not the same!"
  57. Else
  58. If Len(strPassword) < 8 Then
  59. WScript.Echo "The Password is too short"
  60. Else
  61. If AreYouThere = 0 Then
  62. WScript.Echo "User Does Not Exist"
  63. Else
  64. ' WScript.Echo "Distinguished Name: " & strUserDistinguished
  65. Set objUser = GetObject ("LDAP://" & strUserDistinguished & "")
  66. objUser.SetPassword strPassword
  67. If Err <> 0 Then
  68. WScript.Echo Err.Description
  69. Else
  70. WScript.Echo "Password Set"
  71. End If
  72. End If
  73. End If
  74. End If
  75. WScript.QUit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement