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

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

Replies are listed 'Best First'.
Re: Authen::NTLM problem getting page from SharePoint Server
by Lunchy (Sexton) on May 04, 2006 at 19:51 UTC
    I don't know the answer, but I can tell you I'm getting the same results with our SharePoint installation. :) I played with the credentials a bit to no avail.