3

a similar question was asked in question 494120, but IMHO was not really answered...

I want to upload files to a sharepoint using perl/WebDAV (from a Win32 host). To achive this, I need to authenticate with KERBEROS on the server. After googling for hours and trying different approaches, I'm not able to open a connection. Current code is this:

my $agent = HTTP::DAV::UserAgent->new(keep_alive=>1);  
$agent->agent('Agent');  
$agent->timeout(1000);  
my $d = HTTP::DAV->new(-useragent => $agent);  
$d->credentials( -user=>$user,-pass =>$pass, -url =>$url);  
$d->open( -url=>$url ) or die("Couldn't open $url: " .$d->message . "\n");  

When doing the $d->open(...), I always get "Couldn't open $url: Unauthorized. Negotiate". So, obviously the basic authentication doesn't work.

Could anyone point me to the right path, please? I am not fixed to using WebDAV, any other mechanism would fit me as well. Just want to get it working...


Edit 1
When using LWP along with Authen::NTLM (as suggested by Madhur) also doesn't work. It results in a 500 internal server error on IIS as well as on Apache. Since the same error occurs on two different web servers (with two different NTLM implementations) I guess that there's gotta be a problem in the Authen::NTLM module.

Looking at the implementation of Authen::NTLM it seems to me that the code is kinda reverse engineered and neither implemented based on a specification nor is it really configurable. What turns up the question why the specification wasn't used to implement the module...

Is using NTLM along with Perl such an exotic use case?


Edit 2
Based on Madhur's suggestion, I tried accessing the Sharepoint with Curl. This works. But sniffing the NTLM messages of Curl and those sent by Perl shows me, that the message format is somehow different.

Community
  • 1
  • 1
eckes
  • 64,417
  • 29
  • 168
  • 201

1 Answers1

0

Instead of using WebDAV. I would suggest you use out of the box web services.

This gives overview on how to use sharepoint web services in PERL:

http://www.squish.net/log/2008/10/11/perl-sharepoint/

http://shareperl.blogspot.com/

And this is the .NET code to upload the file using web service: http://www.oriolardevol.com/Article/Details/3

Converting it to PERL code is left to you as its been years since I used PERL :)

Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124
  • Thanks for your answer. Unfortunately, using `LWP` along with `Authen::NTLM` causes a `500 internal server error` on IIS as well as on Apache. I assume that there's an error in the `Authen::NTLM`-implementation... – eckes Jan 10 '11 at 19:41
  • I have few suggestions, may be useful: 1. Try using debug option use LWP::Debug qw(+); 2. Can you use Curl to handle the authentication http://en.wikipedia.org/wiki/CURL 3. check out http://stackoverflow.com/questions/1013721/how-do-i-integrate-ntlm-authentication-with-perls-soaplite-module 4. http://www.perlmonks.org/?node_id=719995 – Madhur Ahuja Jan 11 '11 at 07:54
  • @eckes: Ok. Firstly I don't know how this @user works. Couldn't find it in FAQ as well. Frankly, I don't know about CURL or PERL. I am sharepoint guy. If CURL works for you, go ahead and use it. Ping me incase you have any question on sharepoint or its related usage. – Madhur Ahuja Jan 11 '11 at 09:14
  • @Madhur: the reason why I want to use Perl is that I've got a build script written in Perl for some software. When building succeeds, I'd like to upload the newly generated version to my Sharepoint, check it in, and adjust a link that points to the latest version. This workflow IMHO cannot be done using Curl... – eckes Jan 11 '11 at 09:19
  • @eckes: If its on Windows platform, you can just build and call any executable which will do sharepoint job. Don't necessarily use PERL for sharepoint just because build script is in PERL. – Madhur Ahuja Jan 11 '11 at 09:22
  • @Madhur: yes, of course. But I don't want to switch tools. I want to have the build-label-upload cycle in one tool and don't want to go away from my Perl build script. +1 for your efforts. – eckes Jan 11 '11 at 09:46
  • @eckes: You are really not switching the tool. From the perl script you will be just calling command line executable, which can be just simple powershell script to do the job.... – Madhur Ahuja Jan 11 '11 at 09:59
  • @Madhur: do you have any examples handy how to access a remote sharepoint using powershell? Everything I find seems to assume that the powershell stuff runs on a machine where sharepoint is installed (using `Microsoft.Sharepoint.dll`)... – eckes Jan 11 '11 at 10:59
  • 1
    @eckes: We will call the sharepoint web service from powershell and not the sharepoint object model. See: http://sharepoint.microsoft.com/Blogs/zach/Lists/Posts/Post.aspx?ID=9 – Madhur Ahuja Jan 11 '11 at 11:05
  • @Madhur: awarding the bounty to you. Although it didn't solve my perl problem, you put me on another way to go. Thanks. – eckes Jan 12 '11 at 17:02