Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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.



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

In reply to NTLM authentication fails with WWW:Mechanize, fine with LWP::UserAgent by reasonablekeith

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (7)
    As of 2019-12-06 07:37 GMT
    Find Nodes?
      Voting Booth?
      Strict and warnings: which comes first?

      Results (154 votes). Check out past polls.