nilanjan has asked for the wisdom of the Perl Monks concerning the following question:
Hi Gurus, I have used the below code to get some data frm Microsoft sharepoint with NTLM authentication. But I am getting "401 Unauthorized" error. Any idea why? I can see an warning as : "Client-Warning: Unsupported authentication scheme 'ntlm' ". I renamed the "Ntlm.pm" to "ntlm.pm" assuming some issue with cases. Below is the detail stack trace:
*****************************************************************
LWP::UserAgent::new: ()
SOAP::Lite::new: ()
LWP::UserAgent::new: ()
SOAP::Transport::HTTP::Client::new: ()
SOAP::Lite::call: ()
SOAP::Serializer::envelope: ()
SOAP::Serializer::envelope: GetListCollection
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0x2362c68)
SOAP::Transport::HTTP::Client::send_receive: POST http://abt.sp.xx.com/teams/Test/_vti_bin/lists.asmx
Accept: text/xml
Accept: multipart/*
Content-Length: 482
Content-Type: text/xml; charset=utf-8
SOAPAction: http://schemas.microsoft.com/sharepoint/soap/GetListCollection
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENC="http://
schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlso
ap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/
" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3
.org/1999/XMLSchema"><SOAP-ENV:Body><namesp1:GetListCollection xmlns:namesp1="ht
tp://schemas.microsoft.com/sharepoint/soap/"/></SOAP-ENV:Body></SOAP-ENV:Envelop
e>
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: POST http://abt.sp.xx.com/teams/Test/_vti_bin/lists.asmx
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 16 bytes
LWP::Protocol::http::request: Keep the http connection to teams1.sharepoint.hp.c
om:80
LWP::UserAgent::request: Simple response: Unauthorized
SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x21da2ec)
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 401 Unauthorized
Cache-Control: private, max-age=0
Connection: Keep-Alive
Connection: Proxy-Support
Date: Sun, 22 Feb 2009 18:39:58 GMT
Via: 1.1 S70W0013
Server: Microsoft-IIS/6.0
WWW-Authenticate: NTLM
Content-Length: 16
Client-Date: Sun, 22 Feb 2009 18:39:59 GMT
Client-Peer: 16.236.18.17:80
Client-Response-Num: 1
Client-Warning: Unsupported authentication scheme 'ntlm'
MicrosoftSharePointTeamServices: 12.0.0.6300
Proxy-Support: Session-Based-Authentication
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
401 UNAUTHORIZED
SOAP::Deserializer::deserialize: ()
SOAP::Parser::decode: ()
401 Unauthorized at test.pl line 28
SOAP::Data::DESTROY: ()
SOAP::Data::DESTROY: ()
SOAP::Data::DESTROY: ()
SOAP::Transport::HTTP::Client::DESTROY: ()
SOAP::Transport::DESTROY: ()
SOAP::Deserializer::DESTROY: ()
SOAP::Serializer::DESTROY: ()
SOAP::Data::DESTROY: ()
SOAP::Transport::DESTROY: ()
SOAP::Serializer::DESTROY: ()
SOAP::Deserializer::DESTROY: ()
SOAP::Lite::DESTROY: ()
SOAP::Parser::DESTROY: ()
SOAP::Lite::DESTROY: ()
***********************************************************
Thanks, Nilanjan*********************************************************** use LWP::UserAgent; use LWP::Debug; use SOAP::Lite on_action => sub { "$_[0]$_[1]"; }; import SOAP::Data 'name', 'value'; our $sp_endpoint = 'http://abt.sp.xx.com/teams/Test/_vti_bin/lists.asm +x'; #our $sp_domain = 'teams1.sharepoint.hp.com:80'; our $sp_domain = 'ASIAPAC'; our $sp_username = 'ASIAPAC\\XXX'; our $sp_password = 'YYY'; $debug = 1; if ($debug) { LWP::Debug::level('+'); SOAP::Lite->import(+trace => 'all'); } my @ua_args = (keep_alive => 1); my @credentials = ($sp_domain, "", $sp_username, $sp_password); my $schema_ua = LWP::UserAgent->new(@ua_args); $schema_ua->credentials(@credentials); $soap = SOAP::Lite->proxy($sp_endpoint, @ua_args, credentials => \@cre +dentials); #$soap->schema->useragent($schema_ua); $soap->uri("http://schemas.microsoft.com/sharepoint/soap/"); $lists = $soap->GetListCollection(); quit(1, $lists->faultstring()) if defined $lists->fault(); my @result = $lists->dataof('//GetListCollectionResult/Lists/List'); foreach my $data (@result) { my $attr = $data->attr; foreach my $a qw/Title Description DefaultViewUrl Name ID WebId It +emCount/ { printf "%-16s %s\n", $a, $attr->{$a}; } print "\n"; } sub SOAP::Transport::HTTP::Client::get_basic_credentials { return ('AS +IAPAC\\XXX' => 'YYY') }; *****************************************************
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: NTLM authentication for Microsoft sharepoint
by Anonymous Monk on Feb 25, 2009 at 13:43 UTC | |
|
Re: NTLM authentication for Microsoft sharepoint
by Anonymous Monk on Feb 25, 2009 at 13:38 UTC | |
by nilanjan (Initiate) on Feb 26, 2009 at 04:18 UTC | |
by Anonymous Monk on Feb 26, 2009 at 07:16 UTC |