views:

288

answers:

2

We use a websense internet filter at my workplace. I have an application that tries to retrieve information from the internet.

On my client machine, I have to authenticate with websense manually (i.e., open firefox and give my username / password) or I'll get an error in my application when it tries to do the download.

The error message is:

HTTP/1.0 302 Moved.

Does anyone know of a way to authenticate with websense from code? Examples in any language are welcome- I am using Delphi and Indy's TIdHTTP component.

+1  A: 

I would try HTTP authentication

http://en.wikipedia.org/wiki/Basic_access_authentication

port-zero
+2  A: 

Answering my own question; this is what worked for me.

The custom user agent string is only required if you want the authentication to let MSN / Live messenger get through, as described under "notes" at the end of this article.

In a command line application:

uses
  ... IdHTTP ...;

...
var
  httpGetter: TIdHTTP;
...    
httpGetter.Request.Username := username;
httpGetter.Request.Password := password;
httpGetter.HandleRedirects := True;
httpGetter.Request.BasicAuthentication := True;

//custom useragent required to let live messenger work
httpGetter.Request.UserAgent := 'MSN Explorer/9.0 (MSN 8.0; TmstmpExt)';

httpGetter.Get(url,MS);
...
JosephStyons