man-pages/man3/LWP::Authen::Ntlm.3pm.html
2021-03-31 01:06:50 +01:00

171 lines
4.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of LWP::Authen::Ntlm</TITLE>
</HEAD><BODY>
<H1>LWP::Authen::Ntlm</H1>
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2019-11-29<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
LWP::Authen::Ntlm - Library for enabling NTLM authentication (Microsoft) in LWP
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
use LWP::UserAgent;
use HTTP::Request::Common;
my $url = '<A HREF="http://www.company.com/protected_page.html';">http://www.company.com/protected_page.html';</A>
# Set up the ntlm client and then the base64 encoded ntlm handshake message
my $ua = LWP::UserAgent-&gt;new(keep_alive=&gt;1);
$ua-&gt;credentials('<A HREF="http://www.company.com">www.company.com</A>:80', '', &quot;MyDomain\\MyUserCode&quot;, 'MyPassword');
$request = GET $url;
print &quot;--Performing request now...-----------\n&quot;;
$response = $ua-&gt;request($request);
print &quot;--Done with request-------------------\n&quot;;
if ($response-&gt;is_success) {print &quot;It worked!-&gt;&quot; . $response-&gt;code . &quot;\n&quot;}
else {print &quot;It didn't work!-&gt;&quot; . $response-&gt;code . &quot;\n&quot;}
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
LWP::Authen::Ntlm allows <FONT SIZE="-1">LWP</FONT> to authenticate against servers that are using the
<FONT SIZE="-1">NTLM</FONT> authentication scheme popularized by Microsoft. This type of authentication is
common on intranets of Microsoft-centric organizations.
<P>
The module takes advantage of the Authen::NTLM module by Mark Bush. Since there
is also another Authen::NTLM module available from <FONT SIZE="-1">CPAN</FONT> by Yee Man Chan with an
entirely different interface, it is necessary to ensure that you have the correct
<FONT SIZE="-1">NTLM</FONT> module.
<P>
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.
<A NAME="lbAE">&nbsp;</A>
<H2>USAGE</H2>
The module is used indirectly through <FONT SIZE="-1">LWP,</FONT> rather than including it directly in your
code. The <FONT SIZE="-1">LWP</FONT> system will invoke the <FONT SIZE="-1">NTLM</FONT> authentication when it encounters the
authentication scheme while attempting to retrieve a <FONT SIZE="-1">URL</FONT> from a server. In order
for the <FONT SIZE="-1">NTLM</FONT> authentication to work, you must have a few things set up in your
code prior to attempting to retrieve the <FONT SIZE="-1">URL:</FONT>
<DL COMPACT>
<DT id="1">&bull;<DD>
Enable persistent <FONT SIZE="-1">HTTP</FONT> connections
<P>
To do this, pass the ``keep_alive=&gt;1'' option to the LWP::UserAgent when creating it, like this:
<P>
<PRE>
my $ua = LWP::UserAgent-&gt;new(keep_alive=&gt;1);
</PRE>
<DT id="2">&bull;<DD>
Set the credentials on the UserAgent object
<P>
The credentials must be set like this:
<P>
<PRE>
$ua-&gt;credentials('<A HREF="http://www.company.com">www.company.com</A>:80', '', &quot;MyDomain\\MyUserCode&quot;, 'MyPassword');
</PRE>
<P>
Note that you cannot use the HTTP::Request object's <B>authorization_basic()</B> method to set
the credentials. Note, too, that the '<A HREF="http://www.company.com">www.company.com</A>:80' portion only sets credentials
on the specified port <FONT SIZE="-1">AND</FONT> it is case-sensitive (this is due to the way <FONT SIZE="-1">LWP</FONT> is coded, and
has nothing to do with LWP::Authen::Ntlm)
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>AVAILABILITY</H2>
General queries regarding <FONT SIZE="-1">LWP</FONT> should be made to the <FONT SIZE="-1">LWP</FONT> Mailing List.
<P>
Questions specific to LWP::Authen::Ntlm can be forwarded to <A HREF="mailto:jtillman@bigfoot.com">jtillman@bigfoot.com</A>
<A NAME="lbAG">&nbsp;</A>
<H2>COPYRIGHT</H2>
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.
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
<FONT SIZE="-1">LWP</FONT>, LWP::UserAgent, lwpcook.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="3"><A HREF="#lbAB">NAME</A><DD>
<DT id="4"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="5"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="6"><A HREF="#lbAE">USAGE</A><DD>
<DT id="7"><A HREF="#lbAF">AVAILABILITY</A><DD>
<DT id="8"><A HREF="#lbAG">COPYRIGHT</A><DD>
<DT id="9"><A HREF="#lbAH">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:47 GMT, March 31, 2021
</BODY>
</HTML>