Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  LWP::AUTHEN::NTLM (3)

.ds Aq ’


LWP::Authen::Ntlm - Library for enabling NTLM authentication (Microsoft) in LWP



 use LWP::UserAgent;
 use HTTP::Request::Common;
 my $url =;

 # Set up the ntlm client and then the base64 encoded ntlm handshake message
 my $ua = LWP::UserAgent->new(keep_alive=>1);
 $ua->credentials(, , "MyDomain\\MyUserCode", MyPassword);

 $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 didnt work!->" . $response->code . "\n"}


LWP::Authen::Ntlm allows LWP to authenticate against servers that are using the NTLM authentication scheme popularized by Microsoft. This type of authentication is common on intranets of Microsoft-centric organizations.

The module takes advantage of the Authen::NTLM module by Mark Bush. Since there is also another Authen::NTLM module available from CPAN by Yee Man Chan with an entirely different interface, it is necessary to ensure that you have the correct NTLM module.

In addition, there have been problems with incompatibilities between different versions of Mime::Base64, which Bush’s Authen::NTLM makes use of. Therefore, it is necessary to ensure that your Mime::Base64 module supports exporting of the encode_base64 and decode_base64 functions.


The module is used indirectly through LWP, rather than including it directly in your code. The LWP system will invoke the NTLM authentication when it encounters the authentication scheme while attempting to retrieve a URL from a server. In order for the NTLM authentication to work, you must have a few things set up in your code prior to attempting to retrieve the URL:
o Enable persistent HTTP connections

To do this, pass the keep_alive=>1 option to the LWP::UserAgent when creating it, like this:

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

o Set the credentials on the UserAgent object

The credentials must be set like this:

   $ua->credentials(, , "MyDomain\\MyUserCode", MyPassword);

Note that you cannot use the HTTP::Request object’s authorization_basic() method to set the credentials. Note, too, that the ’’ portion only sets credentials on the specified port AND it is case-sensitive (this is due to the way LWP is coded, and has nothing to do with LWP::Authen::Ntlm)


General queries regarding LWP should be made to the LWP Mailing List.

Questions specific to LWP::Authen::Ntlm can be forwarded to


Copyright (c) 2002 James Tillman. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


LWP, LWP::UserAgent, lwpcook.
Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 LWP::AUTHEN::NTLM (3) 2015-12-05

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.