Bypass Basic Authentication

Add-in Express™ Support Service
That's what is more important than anything else

Bypass Basic Authentication
 
christianbpedersen




Posts: 34
Joined: 2009-07-19
Hi!

I have a BHO that currently works fine, but I want to add a feature to it, that allows it to log me into sites that use basic authentication, using a list of usernames/password that I have.

I've tried adding the "Authorization: Basic..." header to the IEApp.Navigate(...) call, but that only works for the first page downloaded. All subsequent requests cause the basic authentication dialog to popup. I think I need to store the username and password for a certain URL in IE's credential cache somehow, but I'm unsure about how to do this.

I've tried integrating the technique described here: http://izlooite.blogspot.com/2009/06/bypass-integrated-authentication-using.html but I'm having trouble hooking it up to IEApp, as it does not expose the ActiveXInstance property.

Any help would be greatly appreciated.

Cheers,
Christian
Posted 24 Jul, 2010 10:48:45 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Christian.

I think that you don't need the ActiveXInstance property at all.
Do you use the header in the BeforeNavigate2 event handler?
Posted 26 Jul, 2010 06:59:25 Top
christianbpedersen




Posts: 34
Joined: 2009-07-19
Hmm... I'm not sure if the page resources fire a BeforeNavigate event as well, but it's worth a try.

Do I just add the header to the AddinExpress.IE.ADXIEBeforeNavigate2EventArgs.headers passed to the event? It doesn't seem to insert the credentials to the current navigation.

Cheers

- Christian
Posted 27 Jul, 2010 04:20:19 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Christian.

I suppose that you need to use the ADXIEBeforeNavigate2EventArgs.headers property for subsequent navigation after you have called the IEApp.Navigate method.
Posted 27 Jul, 2010 06:37:57 Top
christianbpedersen




Posts: 34
Joined: 2009-07-19
I tried doing that, but it doesn't seem to affect the headers in the actual request.

Is ADXIEBeforeNavigate2EventArgs.headers intended to be writeable for the upcoming request?

- Christian
Posted 27 Jul, 2010 07:25:30 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Posted 28 Jul, 2010 10:22:58 Top
christianbpedersen




Posts: 34
Joined: 2009-07-19
Yes, from the documentation the BeforeNavigate2 parameters seems writeable, but the question is if they also are through your wrapper object (ADXIEBeforeNavigate2EventArgs)?
Posted 30 Jul, 2010 07:41:44 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Christian.

Add-in Express uses the code below to pass the parameter.

internal void DoBeforeNavigate2(object pDisp, ref object url, ref object flags,
ref object targetFrameName, ref object postData, ref object headers, ref bool cancel)
{
ADXIEBeforeNavigate2_EventHandler proc = this.beforeNavigate2Handlers;
if (proc != null)
{
try
{
ADXIEBeforeNavigate2EventArgs e =
new ADXIEBeforeNavigate2EventArgs(pDisp, url, (int)flags,
(String.IsNullOrEmpty((string)targetFrameName) ? String.Empty : targetFrameName.ToString()),
postData,
(String.IsNullOrEmpty((string)headers) ? String.Empty : headers.ToString()),
cancel);
proc(e);
url = e.Url;
flags = e.Flags;
targetFrameName = e.TargetFrameName;
postData = e.PostData;
headers = e.Headers;
cancel = e.Cancel;
}
catch (Exception err)
{
DoError(this, ADXIEExternalException.Wrap(err));
}
}
}
Posted 20 Aug, 2010 14:50:19 Top