Hi,

I need to get a web page from the SharePoint which runs in Windows IIS server. So it using NTLM authentication. I have tried the following which should work for NTLM authentication, but it gives "401 Unauthorized" error. I have posted the source code and the LWP::Debug output below. Any help will be much appriciated.

Code:

use LWP::UserAgent; use HTTP::Request::Common; use HTTP::Headers; use LWP::Debug qw(+); my $url = 'http://site.domine.com'; my $ua = new LWP::UserAgent(keep_alive=>1); $ua->credentials('site.domine.com:80', '', 'domine\\username', 'passwo +rd'); $request = HTTP::Request->new( GET => $url, HTTP::Headers->new(user_agent => 'Internet Explorer/6.0', www_auth +enticate => 'NTLM') ); print "--Performing request now...-----------\n"; $response = $ua->request($request); print "--Done with request-------------------\n"; if ($response->is_success) {print "It worked!->" . $response->code . " +\n"} else {print "It didn't work!->" . $response->code . "\n"}


Debugger Output:

LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://site.domine.com LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 690 bytes LWP::Protocol::collect: read 966 bytes LWP::Protocol::http::request: Keep the http connection to site.domine. +com:80 LWP::UserAgent::request: Simple response: Unauthorized LWP::Authen::Ntlm::authenticate: authenticate() has been called LWP::Authen::Ntlm::authenticate: In first phase of NTLM authentication LWP::Authen::Ntlm::authenticate: Returning response object with auth h +eader: Authorization NTLM TlRMTVNTUAABAAAAB7IAAAgACAAgAAAA LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://site.domine.com LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 369 bytes LWP::Protocol::collect: read 1170 bytes LWP::Protocol::http::request: Keep the http connection to site.domine. +com:80 LWP::UserAgent::request: Simple response: Unauthorized LWP::Authen::Ntlm::authenticate: authenticate() has been called LWP::Authen::Ntlm::authenticate: In second phase of NTLM authenticatio +n LWP::Authen::Ntlm::authenticate: Returning response object with auth h +eader: Authorization NTLM TlRMTVNTUAADAAAAGAAYAEAAA LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://site.domine.com LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::collect: read 690 bytes LWP::Protocol::collect: read 849 bytes LWP::Protocol::http::request: Keep the http connection to site.domine. +com:80 LWP::UserAgent::request: Simple response: Unauthorized LWP::Authen::Ntlm::authenticate: authenticate() has been called LWP::Authen::Ntlm::authenticate: In first phase of NTLM authentication


(LWP tries for three times and stops...)

Thanks in advance.

Hemaraj

Edit: g0n - replaced pre tags with code tags


In reply to Authen::NTLM problem getting page from SharePoint Server by hraj

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.