I am writing a perl script below that will get the web page source, looking into the response header from server, you can see it provides NTLM and Negotiate, but it seems always uses Negotiate, how can I select NTLM for authentication? I might use NTLM authentication with the way LWP::Useragent->credentials, but I don't know how to use Negotiate.
#!/usr/bin/perl use LWP::UserAgent; use HTTP::Request::Common; use LWP::Debug qw(+); use Authen::NTLM; use strict; use warnings; my $url = "http://10.1.1.1"; my $ua = new LWP::UserAgent(keep_alive => 1); $ua->credentials('10.1.1.1:80', '', 'user', 'passwd'); my $req = HTTP::Request->new(GET => $url); print "--Peforming request now...---------\n"; my $res = $ua->request($req); print "--Done with request ...---------\n"; # check the outcome if ($res->is_success) { print $res->content; } else { print "Error: " . $res->status_line . "\n"; print $res->headers()->as_string(), "\n"; } exit 0;
The output:
elvis@elvis-laptop:~/tmp/person$ ./d2.pl --Peforming request now...--------- --Done with request ...--------- Error: 401 Unauthorized Date: Tue, 11 Oct 2011 02:13:08 GMT Server: Microsoft-IIS/7.5 WWW-Authenticate: Negotiate WWW-Authenticate: NTLM Content-Length: 1181 Content-Type: text/html Client-Date: Tue, 11 Oct 2011 02:12:23 GMT Client-Peer: 10.1.1.2:80 Client-Response-Num: 1 Client-Warning: Unsupported authentication scheme 'negotiate' Title: 401 - δ��Ȩ: ���&#6 +5533;ƾ����Ч��&#6 +5533;��ʱ��ܾ X-Powered-By: ASP.NET
From the output, you can see it will redirect to 10.1.1.2 for authentication. I am not sure if it is the problem that authentication wasn't passed to next server. Any comments will be appreciated. the web page

In reply to How to select NTLM authentication with LWP by tiedwu

Title:
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, details, 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, summary, 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.