Authen::NTLM problem getting page from SharePoint Server
hraj
created: 2006-05-04 00:39:52
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', 'password');

$request = HTTP::Request->new(
    GET => $url,
    HTTP::Headers->new(user_agent => 'Internet Explorer/6.0', www_authenticate => '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 header:
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 authentication
LWP::Authen::Ntlm::authenticate: Returning response object with auth header:
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

Re: Authen::NTLM problem getting page from SharePoint Server
created: 2006-05-04 15:51:15
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.

perlmonks.org content © perlmonks.org and hraj, Lunchy

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03