Jump to content
Sign in to follow this  
Irongeek

Basic Authentication _IECreate/InetGet

Recommended Posts

Irongeek

Hi all, I found some information via search, but it was out of date. I need to access a site that is using basic auth with either the _IECreate or InetGet functions. The old answer was to put the credentials in the URL like https://user:pass@someplace.com . However, Autoit uses IE, and post IE 6 credentials are disabled in the URL. Is there another way?

Thanks

Share this post


Link to post
Share on other sites
Irongeek

It's hard to believe none else has had this problem.

Share this post


Link to post
Share on other sites
99Failz

It's hard to believe none else has had this problem.

I was thinking a long the same lines...

I probably looked for it for about 3 hours.

I am sure there are better ways to do it but here is what I did to work with websites that have basic authentication.

#include <IE.au3>
#Region Vars
$o_Addy = "ip or something.com"
$user = "username goes here"
$pass = "password goes here"
#EndRegion Vars

#Region Controls
#cs
    Login window vars
    When using the AU3Info tool the class of the login window is $Class.
    The $ctrlU thru $ctrlS is the "ClassnameNN" for each textbox and button on the login window.
#ce
$Class = "[CLASS:#32770]"
$ctrlU = "Edit2"
$ctrlP = "Edit3"
$ctrlS = "Button2"
#EndRegion Controls

#Region Navigation to login prompt
$o_IE = _IECreate()
#cs
    Allowing the script to continue while page is still loading was the tricky part for me.
    the zero at the end of the navigation command is "$f_wait=0". 0 does not wait for page to load and 1 waits.
#ce
_IENavigate($o_IE, $o_Addy, 0)
#EndRegion Navigation to login prompt

;wait for 5 seconds for login window.
Sleep(5000)

#Region Control the login window
ControlSend($Class, "", $ctrlU, $user)
ControlSend($Class, "", $ctrlP, $pass)
ControlClick($Class, "", $ctrlS, "")
MsgBox(0, "Finished", "Bob's your uncle")
#EndRegion Control the login window

Share this post


Link to post
Share on other sites
KaFu

; http://support.microsoft.com/kb/834489
#include <IE.au3>
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE","iexplore.exe","REG_DWORD",0)
_IECreate ("http://USERNAME:PASSWORD@website.com/protected_dir/")
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_HTTP_USERNAME_PASSWORD_DISABLE","iexplore.exe","REG_DWORD",1)

Share this post


Link to post
Share on other sites
99Failz

Thanks KaFu, thats a much better way of doing it.

Share this post


Link to post
Share on other sites
KaFu

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
Sign in to follow this  

×