In the course of trying to get LWP working with NTLM today, I spent some time "Super Searching" Perl Monks. Unfortunately, I did not find a foolproof solution. Nevertheless, I finally got everything working for me. Because this is the newest node I found dealing with NTLM, I thought I'd post my insights here in the hopes that some future searcher has more luck than I did.

The stumbling blocks for me weren't the code, which in the end worked right off the example in the synopsis. Instead, I got tripped up on...
  1. ... realizing I had to install the Authen::NTLM module. I checked my installation and saw I already had LWP::Authen::Ntlm, so I figured I was set to go. I don't know how it got there without Authen::NTLM, but LWP merrily ran my code without mentioning it didn't have the right modules to do the authentication.
  2. ... installing the correct module, namely Authen::NTLM by Mark Bush. A man named Yee Man Chan also has packages in the same namespace, for some reason. I am sure his solution is great, too, but it doesn't work with LWP ;-).
  3. ... patching the NTLM module. Judging by the last release date (2001-10-29), the module has been orphaned. When it didn't work for me, I figured Bill Gates might have changed the protocol, and I was up to my ears in unpacks trying to find the problem before I found this bug report (posted 2005-01-07, by the way, after the initial post in this thread). It proposes a change to one line of code, which I applied manually.

After that, the example code from the synposis ran flawlessly:
use LWP::UserAgent; use HTTP::Request::Common; my $url = 'http://www.company.com/protected_page.html'; # Set up the n +tlm client and then the base64 encoded ntlm handshake message my $ua = new LWP::UserAgent(keep_alive=>1); $ua->credentials('www.company.com:80', '', "MyDomain\\MyUserCode", 'My +Password'); $request = GET $url; print "--Performing request now...-----------\n"; $response = $ua->request($request); print "--Done with request-------------------\n"; if ($response->is_success) { print "It worked!->" . $response->code . "\n" } else { print "It didn't work!->" . $response->code . "\n" }
Anyway, I hope this can help someone else along the way.

In reply to Re^2: More NTLM by crashtest
in thread More NTLM by j.goor

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.