CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Access Sharepoint using HTTP::DAV getting 401 Unauthorized

 



islanderman
Novice

Oct 10, 2014, 7:26 AM

Post #1 of 1 (1949 views)
Access Sharepoint using HTTP::DAV getting 401 Unauthorized Can't Post

I'm trying to gain acccess to a sharepoint via perl on linux in order to put and get files and I keep getting a 401 Unauthorized error. I tried to use the SharePoint::SOAPHandler with CopyTree::VendorProof modules but got the dreaded 401 error. Then I'm attempting with HTTP::DAV and from what I've been reading there may be issues with the NTLM authentication. I included the keep-alive option but didn't work. To verify that the userid/password combo is working I get this script to work


use LWP::UserAgent;
use Authen::NTLM;
use HTTP::Request::Common;

my $url = 'https://operations.web.mywork.com/sites/CAPCOET3/';
my $user = 'MYDOMAIN\myuser'; # The auth module splits this on the '\'
my $pass = 'mypass';

my $ua = new LWP::UserAgent(keep_alive=>1);

$ua->credentials('operations.web.mywork.com:443', '', $user, $pass);

$request = GET $url;
$response = $ua->request($request);
if ($response->is_success) {print "It worked!->" . $response->code . "\n"}
else {print "It didn't work!->" . $response->code . "\n"}


the response is 'It worked!'. However this is the script for the http dav module that is not working:


use Authen::NTLM; ntlmv2(1);
use HTTP::DAV;
use HTTP::DAV::Comms;
HTTP::DAV::DebugLevel(3);

my $ua = HTTP::DAV::UserAgent->new( keep_alive => 1 );
$d = new HTTP::DAV( -useragent => $ua );
$url = "https://operations.web.mywork.com/sites/CAPCOET3/";

$d->credentials( -user=>'MYDOMAIN\myuser',-pass =>"mypass",
-url =>$url );

$d->open( -url=>"$url" )
or die("Couldnt open $url: " .$d->message . "\n");


Setting auth details for operations.web.mywork.com:443, default to 'MYDOMAIN\myuser', 'mypass'
new_resource: For https://operations.web.mywork.com/sites/CAPCOET3/, creating new resource
Using user/pass combo: MYDOMAIN\myuser mypass. For , https://operations.web.att.com/sites/CAPCOET3/
Using user/pass combo: MYDOMAIN\myuser mypass. For , https://operations.web.att.com/sites/CAPCOET3/
Using user/pass combo: MYDOMAIN\myuser mypass. For , https://operations.web.att.com/sites/CAPCOET3/
Using user/pass combo: MYDOMAIN\myuser mypass. For , https://operations.web.att.com/sites/CAPCOET3/
Using user/pass combo: MYDOMAIN\myuser mypass. For , https://operations.web.att.com/sites/CAPCOET3/
Using user/pass combo: MYDOMAIN\myuser mypass. For , https://operations.web.att.com/sites/CAPCOET3/
Using user/pass combo: MYDOMAIN\myuser mypass. For , https://operations.web.att.com/sites/CAPCOET3/
Couldnt open https://operations.web.att.com/sites/CAPCOET3/: Unauthorized. Negotiate


HELPPPPPP please...

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives