I recently threw the attached auth module together in order to enable NTLM
authentication with my IIS servers.  It's not perfect (in fact, I've still
got a problem where it actually takes 2 auth attempts for it to work on my
servers, so I had to modify the check for failure to allow 1 retry!).  But,
it is indeed better than what I had, which was nothing.

If you guys would like to use it as a starting point for an NTLM.pm for the
main LWP distro, you're welcome to it.  Note:  It uses Authen::NTLM, which
is not object oriented at this time.  There's an object oriented NTLM module
on CPAN called Authen::Perl::NTLM, but I had trouble getting it to work.

Let me know if you have any questions, or if my code sucks.  I've put an
example that explains how to test it out below.
 <<NTLM.pm>> 

------------------------------------
James Tillman
Advanced Systems Design
FDLE Webmaster
850-410-8415
[EMAIL PROTECTED]


------------------------------------------

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

my $url = 'http://mysite.com/Administration';
my $user = 'Domain\User'; # The auth module splits this on the '\'
my $pass = 'password';

# Set up the ntlm client and then the base64 encoded ntlm handshake message
my $ua = new LWP::UserAgent(keep_alive=>1);

# This is required to store the credentials, note that the realm is empty
$ua->credentials('mysite.com:80', '', $user, $pass);

# I run the request a few times to make sure there's no problem with
#  subsequent accesses
$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"}

$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"}


$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"}


Attachment: NTLM.pm
Description: Binary data

Reply via email to