NTLM and LWP::UserAgent


M

mumebuhi

I am having problems accessing any sites outside my organization using
LWP::UserAgent. My organization is using NTLM authentication.

My code looks like the following (similar to the one explained in
http://search.cpan.org/dist/libwww-perl/lib/LWP/Authen/Ntlm.pm).

# --- start ---
use HTTP::Request::Common;
use LWP::UserAgent;
use LWP::Debug qw(+);

my $url = 'http://www.google.com';

my $ua = LWP::UserAgent->new(keep_alive => 1);
$ua->credentials('host:8080', '', 'username', 'password');
$request = new HTTP::Request GET => $url;
$response = $ua->request($request);
print $response->code . "\n";
# --- end ---

The output is
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET http://www.google.com
LWP::UserAgent::_need_proxy: Not proxied
LWP::protocol::http::request: ()
LWP::protocol::collect: read 624 bytes
LWP::UserAgent::request: Simple response: Found
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET
http://bcauth/?cfru=aHR0cDovL3d3dy5nb29nbGUuY29tLw==
LWP::UserAgent::_need_proxy: Not proxied
LWP::protocol::http::request: ()
LWP::protocol::collect: read 744 bytes
LWP::protocol::collect: read 66 bytes
LWP::UserAgent::request: Simple response: Unauthorized
401

Help?
 
Ad

Advertisements

M

mumebuhi

I have several topics that discuss similar problem. However, I
unfortunately still can not my problem. I hope somebody can help.
Thanks.


Buhi
 
A

Aaron Sherman

mumebuhi said:
I am having problems accessing any sites outside my organization using
LWP::UserAgent. My organization is using NTLM authentication.

It looks like you get redirected by some internal system to an
authentication page and then authentication fails. Check your
credentials. Are you SURE the netloc field is right. You give a sample
(which is clearly bogus, but you might have sanitized it for security
reasons) of "host:8080". Did you verify with the people maintaining the
outgoing proxy that the netloc you are using is correct?

If the word "netloc" isn't familiar, start with "perldoc
LWP::UserAgent" and search for "cred".
 
M

mumebuhi

I am sure that the netloc argument is right.

my $ua = LWP::UserAgent->new(keep_alive => 1);
$ua->credentials('172.26.1.2:8080', '', 'username', 'password'); #
unsanitized version

I even tried (notice the single/double quotes and the domain name):
$ua->credentials('172.26.1.2:8080', '', "domain_name\\username",
'password');
$ua->credentials('172.26.1.2:8080', '', 'domain_name\username',
'password');

By the way, when do we need to specify a domain name?


Buhi
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top