I'm attempting to use Perl and the Win32::LWP code to access a web page using Microsoft Sharepoint/IIS, and am running into Authentication issues, specifically an "Unauthorized 401.2" error. After a couple of weeks of web and book searching for the right answer, here I am. More than anything I'm hoping to get a better understanding of the output I'm seeing. This seems to be a popular problem, I've seen other cases of people trying and failing with this, but no "so this is how this works!" solutions yet. I'm told by the Website Admin the site is using standard NT authentication. I've tried the different Auth schemes I've seen suggested, without success. For example:
$browser->credentials ( 'foo.com:80', '', 'DOMAIN\username' => 'passwd' (with our without DOMAIN) );
Which still gives the 401.2 error. As well as the style:
$req->authorization_basic('userid', 'passwd');
Key parts of the debugging output include:
LWP::UserAgent::_need_proxy: Not proxied
So looks like proxy problems aren't involved?
LWP::UserAgent::request: Simple response: Unauthorized GET http://foo.bar.com/default.aspx User-Agent: libwww-perl/5.806
I take this to mean it tried a simple get, which failed, so it tried to send an AUTH header. The User-Agent tells me that my version of Perl is current - is that correct? I've also tried setting the UserAgent to something like "User-Agent: User-Agent: Mozilla/4.0 (compatible; MSIE 5.12; Mac_PowerPC)" without change to the result. The debugging output continues with:
HTTP/1.1 401 Unauthorized Date: Thu, 03 Jan 2008 01:31:57 GMT Server: Microsoft-IIS/6.0 WWW-Authenticate: NTLM Content-Length: 1656 Content-Type: text/html Content-Type: text/html; charset=Windows-1252 Client-Date: Thu, 03 Jan 2008 01:31:58 GMT Client-Peer: (IP snipped):80 Client-Response-Num: 1 Client-Warning: Unsupported authentication scheme 'ntlm' MicrosoftSharePointTeamServices: 6.0.2.8103 Title: You are not authorized to view this page X-Powered-By: ASP.NET
The "Title:" error segment threw me at first, thinking I had the userid wrong, but doublechecked that and it was good. The "Client-Warning" line has me confused; I was under the impression that the "credentials" style syntax I used *was* "NTLM" style. A couple more revelent messages from the output:
You do not have permission to view this directory or page using the cr +edentials that you supplied because your Web browser is sending a WWW +-Authenticate header field that the Web server is not configured to a +ccept.
and:
HTTP Error 401.2 - Unauthorized: Access is denied due to server config +uration. Internet Information Services (IIS)
So that's that -- the server *seems* to be telling me its using NTLM auth, the client seems to be trying to auth against it, but isn't telling the server what it wants to see. Does anyone have more insight into exactly what the debug output is telling me, and what might make this work? Thank you for your time!

In reply to Win32::LWP 401.2 problem by snoopy_co

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.