Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SharePoint/NTLM authentication using Perl, 401 Unauthorized, Credentials for 'Domain\User' failed

Status
Not open for further replies.

IVJP

Programmer
Jul 21, 2014
11
0
0
US
I am unable to authenticate to a SharePoint site using NTLM authentication, getting 401 Unauthorized, Credentials for 'Domain\User' failed. My password is correct, but I think I might be having an issues with headers or handshaking with the site. Please help!!

LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET LWP::UserAgent::_need_proxy: Not proxied
LWP::protocol::http::request: ()
LWP::protocol::http::request: Keep the http connection to sharepoint.website.net:80
LWP::UserAgent::request: Simple response: Unauthorized
LWP::Authen::Ntlm::authenticate: authenticate() has been called
LWP::Authen::Ntlm::authenticate: In first phase of NTLM authentication
[highlight #FCE94F]401 Unauthorized[/highlight]FAILED!!!!!
Date: Wed, 30 Jul 2014 20:04:58 GMT
Server: Microsoft-IIS/7.5
NTLM
Content-Length: 0
Client-Date: Wed, 30 Jul 2014 20:04:58 GMT
Client-Peer: XXX.XX.XX.XXX:80
Client-Response-Num: 4
[highlight #FCE94F]Client-Warning: Credentials for 'Domain\User' failed before[/highlight]MicrosoftSharePointTeamServices: 14.0.0.7113
SPRequestGuid: dedwdwdd380-dwe-wedwea-824d-ceb5dwdwdwb5
X-MS-InvokeApp: 1; RequireReadOnly
X-Powered-By: ASP.NET
 
if you still have a problem with it please share some more light, as for example the script with which you are trying to connect

``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI
 
thanks, here is my script - this is still not working:

#!/usr/bin/env perl

use strict;
use warnings;


use LWP::Debug qw(+);
use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Request::Common;
use Authen::NTLM;
use Authen::Ntlm;

ntlmv2(1);

my $ua = new LWP::UserAgent(keep_alive => '300',
ssl_opts => { verify_hostname => 1 },);


my $url = ' # website I am trying to hit


my $cookie_jar = HTTP::Cookies->new(
file => "/tmp/cookies.jira",
autosave => 1,
);

my $request = HTTP::Request->new('GET', $url);

$ua->cookie_jar( $cookie_jar );
$ua->credentials("sharepointsite.net:80", "", "DOMAIN\\USER","PASSWORD"); # user password not disclosed

$ua->agent("Mozilla/6.0");



print "--Performing request now...------------------\n";

my $response = $ua->request($request);


print "--Done with request---------------------------\n";

if( $response->is_success) {

print 'Error: ', $response->status_line, "\n";
print "===== Request Headers =====\n";
print $response->headers->as_string;
print "\n===== Response Headers ====\n";
print $response->headers->as_string;
print "\n===== Response Content ====\n";
print $response->content;

} else {

print 'Error: ', $response->status_line, "\n";
print "===== Request Headers =====\n";
print $response->headers->as_string;
print "\n===== Response Headers ====\n";
print $response->headers->as_string;
print "\n===== Response Content ====\n";
print $response->content;
exit 1;
}
 
Also wanted to point out that my ad account gets locked...
 
I made up the website since its internal. It is an example of what I am trying to hit
 
Not sure if this is the right place to post this, but maybe someone can help with a similar issue. I'm trying to copy files from a linux server to a sharepoint. I've got the connection working on the display of the sharepoint. There is 1 file out there to view. But I get a 401 Unauthorized on the copy. Why would I be successful on the display but not the copy?



#!/usr/bin/perl

use Authen::NTLM qw(ntlmv2);
use Data::Dumper;
use SharePoint::SOAPHandler;
use CopyTree::VendorProof;
use CopyTree::VendorProof::LocalFileOp;

delete $ENV{'https_proxy'};

my $sharepointobj = SharePoint::SOAPHandler ->new;
my $localfileobj = CopyTree::VendorProof::LocalFileOp ->new;

$sharepointobj->sp_creds_domain('operations.web.myworksite.com:443');
$sharepointobj->sp_creds_user('MYDOMAIN\myuserid');
$sharepointobj->sp_creds_password('Mypassword');
$sharepointobj->sp_authorizedroot('
my $cpobj = CopyTree::VendorProof ->new;

print Dumper $sharepointobj->fdls('', 'Shared Documents');

$cpobj -> src('/opt/app/Reports/Excel/Reports_TABS1007.xlsx', $localfileobj);
$cpobj -> dst('Shared Documents/Reports_TABS1007.xlsx', $sharepointobj);
$cpobj -> cp;

print Dumper $sharepointobj->fdls('', 'Shared Documents');


Response:
$VAR1 = 'Shared Documents/Reports_TABS1006.xlsx';
$VAR2 = 'Shared Documents/Forms';
401 Unauthorized at /opt/app/perl/lib/perl5/SharePoint/SOAPHandler.pm line 374.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top