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: ()
***********************************************************

Sample code:
*********************************************************** 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') }; *****************************************************
Thanks, Nilanjan

In reply to NTLM authentication for Microsoft sharepoint by nilanjan

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.