问题
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.
回答1:
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 :)
来源:https://stackoverflow.com/questions/4277340/accessing-a-sharepoint-using-perl-and-webdav