Any way to authenticate with a websense server from delphi?

断了今生、忘了曾经 提交于 2020-01-15 06:25:28

问题


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:


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);
...



回答2:


I would try HTTP authentication

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



来源:https://stackoverflow.com/questions/1227874/any-way-to-authenticate-with-a-websense-server-from-delphi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!