http://qs1969.pair.com?node_id=765651

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

Hi Monks,

A little help please. I need to write some test scripts over our company sharepoint intranet (from and to windows), so to that end I need to authenicate through NTLM. No problem, I've updated libperl-www to 5.862, and set up the following...

use LWP::UserAgent; my $ua = new LWP::UserAgent('keep_alive' => '1'); my $url = 'http://intranet/mypage'; $ua->credentials('intranet:80', '', "domain\\user", 'pass'); my $response =$ua->get($url); print $response->code();
The above works just fine and returns a response code of 200, groovey. However, as I'll be following links, submitting forms etc, I'd obviously much rather use Mechanize. As I beleive Mechanize is built over LWP, I don't think this should be a problem, so try the following...
use WWW::Mechanize; my $mech = WWW::Mechanize->new('keep_alive' => 1); $mech->credentials('intranet:80', '', "domain\\user", 'pass'); $mech->get( 'http://intranet/mypage' ); print $mech->status();
Unfortunately, I can't get anything other than a 401 unauthorized out of this. I'm not sure how to attack this, so any advice much appreciated.

Thanks,

Rob

---
my name's not Keith, and I'm not reasonable.