Since we need to pass authentication, we are trying to pass this on window server first before moving to Linux or Unix. We have identified two good blogs on this topics and tried the approach. However, we are getting 401 UNAUTHORIZED error against both NTLM and Kerberos SharePoint 2010 sites. We believe the NTLM perl package may not configured correctly or Perl may not connect to SharePoint Kerberos sites. Since we are not perl or SharePoint integration expertise, we could like to get some help.
We have tried on 2008 64bit window VM server before moving to Linux or Unix. Here are the steps we tried.
- Install ActivePerl 5.12.3
- Install SOAP::Lite using cpan command cpan -i SOAP:Lite since it’s difficult using ppm
- Setup SharePoint site and list and grant site collection admin to the test user account
- Tried the script from The SharePoint / Perl Connection (Part 1)
- Error The exception is on line: $lists = $soap->GetListCollection();
Client-Warning: Unsupported authentication scheme 'ntlm'.
6. I also tried to add the following line:
use Authen::NTLM; ntlmv2(1);
But got error
E:\Share\ws>ws1.pl
Can't locate Authen/NTLM.pm in @INC (@INC contains: C:/Perl64/site/lib C:/Perl64
/lib .) at E:\Share\ws\ws1.pl line 3.
It seems like the NTLM.pm is inside C:\Perl64\lib\LWP\Authen.
7. I also tried to install LWP::Authen::NTLM from CPAN http://search.cpan.org/~gaas/libwww-perl/lib/LWP/Authen/Ntlm.pm. I’m not familiar the perl make installation.
Here is the script from John Wefler and I modified with our server and site.
================================================
print "Start\n";
use LWP::UserAgent;
use LWP::Debug;
use SOAP::Lite on_action => sub { "$_[0]$_[1]"; };
import SOAP::Data 'name', 'value';
sub SOAP::Transport::HTTP::Client::get_basic_credentials { return ('user' => 'password') };
our $sp_endpoint = 'http://sbx01/sites/Harry/_vti_bin/lists.asmx';
our $sp_domain = 'sbx01.na.qulacomm.com:80';
our $sp_username = 'adminaccount';
our $sp_password = 'password';
$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 => \@credentials);
$soap->schema->useragent($schema_ua);
$soap->uri("http://schemas.microsoft.com/sharepoint/soap/");
$lists = $soap->GetListCollection();
quit(1, $lists->faultstring()) if defined $lists->fault();
sub lists_getid {
my $title = shift;
my @result = $lists->dataof('//GetListCollectionResult/Lists/List');
foreach my $data (@result) {
my $attr = $data->attr;
return $attr->{ID}
if ($attr->{Title} eq $title);
}
return undef;
}
sub lists_getitems
{
my $listid = shift;
my $in_listName = name('listName' => $listid);
my $in_viewName = name('viewName' => '');
my $in_rowLimit = name('rowLimit' => 99999);
my $call = $soap->GetListItems($in_listName, $in_viewName, $in_rowLimit);
quit(1, $call->faultstring()) if defined $call->fault();
return $call->dataof('//GetListItemsResult/listitems/data/row');
}
my $list_id = lists_getid('Shared Documents');
print "List ID is: $list_id\n";
my @items = lists_getitems($list_id);
foreach my $data (@items) {
my $attr = $data->attr;
print Dumper($attr);
}
print "END\n";
=============================================
Here is the error I got:
I also listed some reference I got from web for your reference.
- How to Call a .NET-based Web Service Using the SOAP::Lite Perl Library
- Make a SOAP client with Perl and SOAP::Lite
- Test NTLM installation
- Accessing a sharepoint using perl and webdav
Since the final goal is to use perl on Unix and Linux, we found LWP does not have NTLM implemented on Unix/Linux through CPAN. However, both wget and curl ( command line web clients ) support NTLM, and curl supports Kerberos. So we tried to use perl with wget to communicate with SharePoint.
Here is an example command from RHEL 5 command line that gets results back from the Lists web service:
wget --post-file /tmp/listrequest --header 'Content-Type: application/soap+xml; charset="utf-8"' --http-user='NA\mchiles' --http-password="putyourpwhere" http://sharepoint.qualcomm.com/_vti_bin/Lists.asmx
note that I put the file for the request in /tmp/listrequest.
If you save this xml body to this file, it should work
##
<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><GetListCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/"/></soap:Body></soap:Envelope>
##
We are still try to get more SharePoint functions done through perl and please let me know if we make some progress.