Jump to content

Recommended Posts

Posted

Hello,

 

I am trying to make an auto log in script that will log in on our server with all the accounts of the people working on our domain read from the database(arround 20 accounts). The reason for this is everyone to recive update e-mail.

We recive update e-mail with the latest updates everytime time we log in so that is the reason that i am creating this.

Here is a small reproducer:

#include "WinHttp.au3"
OnAutoItExitRegister("_sExit")
Global $sRead, $hOpen, $hConnect
Global Const $sUsername[3] = ["name1", "name2", "name3"]
Global Const $sPassword[3] = ["pass1", "pass2", "pass3"]
Global Const $sUrl = "https://www.myServer.com/"
Global Const $sUserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)"
Local $a
Local $b
$hOpen = _WinHttpOpen($sUserAgent)
$hConnect = _WinHttpConnect($hOpen, $sUrl)
For $i = 0 To UBound($sUsername)-1
 $a = $sUsername[$i]
  $b = $sPassword[$i]
  $sRead = _WinHttpSimpleFormFill($hConnect, _
   Default, _
   "login_1", _
   "name:name", $a, _
   "name:pass", $b)
   If @error Then
    ConsoleWrite(@error & @LF)
   Else
    If StringInStr($sRead, $a) Then ConsoleWrite($a & " succesfully logged in." & @LF)
   EndIf
Next

Func _sExit()
 _WinHttpCloseHandle($hConnect)
 _WinHttpCloseHandle($hOpen)
EndFunc

If i put the $hOpen and $hConnect within the For/Next loop it will work but it will take more than 1 min to log in on our server with all the accounts.

If not it won't work for all the accounts. If i use $hOpen and $hConnect only once then the server will fire error after 4-5 log ins and the winhttpsimpleformfill function will return that there are no forms, @error 1.

Any other way to perform a log in without filling the form with data and submitting it?

Cheers.

Posted

Does the error occur on all subsequent calls to _WinHttpSimpleFormFill? What if you reestablish the handles once an error is detected?

Yes after the the first 4-5 log ins then it occur on all the rest. I am re-establishing the handles when it returns an error but it still is slow. On the last post you suggested something else if i recall right. Open request and send data i think. Is it possible to call a log in on a server with this way?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...