Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- On Error Resume Next
- strSchoolNumber = "[cut]"
- strLDAPContext = "OU=" & strSchoolNumber & ",OU=Schools,DC=[cut],DC=[cut]"
- Set objExplorer = WScript.CreateObject("InternetExplorer.Application", "IE_")
- objExplorer.Navigate "file:///\\[cut]\PasswordInterface.html"
- objExplorer.ToolBar = 0
- objExplorer.StatusBar = 0
- objExplorer.Width = 500
- objExplorer.Height = 300
- objExplorer.Left = 0
- objExplorer.Top = 0
- objExplorer.Visible = 1
- Do While (objExplorer.Document.All.OKClicked.Value = "")
- WScript.Sleep 250
- Loop
- strUserName = objExplorer.Document.All.UserBox.Value
- strPassword = objExplorer.Document.All.PasswordBox.Value
- strPassword2 = objExplorer.Document.All.PasswordBox2.Value
- objExplorer.Quit
- WScript.Sleep 250
- 'WScript.Echo "User: " & strUserName & " Password: " & strPassword
- 'WScript.Echo "The Password is: " & Len(strPassword) & " Characters Long."
- set objConnection = CreateObject("ADODB.Connection")
- objConnection.Open "Provider=ADsDSOObject;"
- set objCommand = CreateObject("ADODB.Command")
- objCommand.ActiveConnection = objConnection
- objCommand.CommandText = "<LDAP://" & strLDAPContext & ">;" & _
- "(&(objectCategory=person)(objectClass=user)(SAMAccountName=" & Lcase(strUserName) & "));sAMAccountName, " & _
- "distinguishedName;subtree"
- set objRecordSet = objCommand.Execute
- AreYouThere = 0
- While Not objRecordSet.EOF
- If Lcase(strUserName) = Lcase(objRecordSet.Fields("sAMAccountName")) Then
- ' WScript.Echo "LDAP sAMAccount: " & objRecordSet.Fields("sAMAccountName")
- ' WScript.Echo "LDAP Distinguished: " & objRecordSet.Fields("distinguishedName")
- strUserDistinguished = objRecordSet.Fields("distinguishedName")
- AreYouThere = 1
- End If
- objRecordSet.MoveNext
- Wend
- objConnection.Close
- If strPassword <> strPassword2 Then
- WScript.Echo "The passwords are not the same!"
- Else
- If Len(strPassword) < 8 Then
- WScript.Echo "The Password is too short"
- Else
- If AreYouThere = 0 Then
- WScript.Echo "User Does Not Exist"
- Else
- ' WScript.Echo "Distinguished Name: " & strUserDistinguished
- Set objUser = GetObject ("LDAP://" & strUserDistinguished & "")
- objUser.SetPassword strPassword
- If Err <> 0 Then
- WScript.Echo Err.Description
- Else
- WScript.Echo "Password Set"
- End If
- End If
- End If
- End If
- WScript.QUit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement