Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm having no luck trying to pass NTLM authentication credentials via my mech object. Here is my script below:
use strict; use warnings; use WWW::Mechanize; use Crypt::SSLeay; use Authen::NTLM; # Turn buffering off $| = 1; # create the mech object my $mech = WWW::Mechanize->new( ); $mech->agent_alias( 'Windows IE 6' ); # configure the proxy $mech->proxy(['https', 'http'], 'http://proxy-server.com:80'); my $url = 'http://somewebsite.com/Pages/Default.aspx'; $mech->credentials('http://somewebsite.com/Pages/Default.aspx', '', "D +OMAIN\\user", 'password'); my $response = $mech->get( $url ); use Data::Dumper; print Dumper($response);
Am I missing something?

Replies are listed 'Best First'.
Re: mech and NTLM authentication?
by ikegami (Patriarch) on Feb 12, 2009 at 15:51 UTC

    use Authen::NTLM; (which you never use) should be use LWP::Authen::Ntlm;.

    Also, the documentation states you need to pass keep_alive => 1 to LWP::UserAgent's constructor (which you can do by passing it to WWW::Mechanize's constructor).

      I've made the changes but still receive a 401 error. Is there anyway to debug this further?
        I never used NTLM and I've never had to debug LWP/Mechanize, sorry.