Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

comment on

( [id://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":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-22 15:07 GMT
Find Nodes?
    Voting Booth?

    No recent polls found