Perl Mechanize with NTLM authentication

966 Views Asked by At

I haven't seen examples of NTLM support with Mechanize. Does anyone know how we can make use of NTLM libraries with Mechanize? If not, does LWP do the job?

my $mech = WWW::Mechanize->new( 'keepalive' => 1 );

my $url = "http://URL/I/NEED/TO/ACCESS"; <---Requires NTLM authorization
my $username = "username";
my $password = "password";

$mech->credentials($username, $password);
$mech->get($url);          
1

There are 1 best solutions below

1
On

According to this

Using WWW::Mechanize Credentials

you need to make sure you;re using v1.5.2 or later of WWW::Mechanize and ultimately it will use Authen::NTLM

If you have a backslash in your real username then you will have to use single quotes or escape it

 my $username = "domain\\user";