171 lines
4.8 KiB
HTML
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"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
LWP::Authen::Ntlm - Library for enabling NTLM authentication (Microsoft) in LWP
|
|
<A NAME="lbAC"> </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->new(keep_alive=>1);
|
|
$ua->credentials('<A HREF="http://www.company.com">www.company.com</A>:80', '', "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 didn't work!->" . $response->code . "\n"}
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </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"> </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">•<DD>
|
|
Enable persistent <FONT SIZE="-1">HTTP</FONT> connections
|
|
|
|
|
|
<P>
|
|
|
|
|
|
To do this, pass the ``keep_alive=>1'' option to the LWP::UserAgent when creating it, like this:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
my $ua = LWP::UserAgent->new(keep_alive=>1);
|
|
|
|
</PRE>
|
|
|
|
|
|
<DT id="2">•<DD>
|
|
Set the credentials on the UserAgent object
|
|
|
|
|
|
<P>
|
|
|
|
|
|
The credentials must be set like this:
|
|
|
|
|
|
<P>
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
$ua->credentials('<A HREF="http://www.company.com">www.company.com</A>:80', '', "MyDomain\\MyUserCode", '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"> </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"> </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"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
<FONT SIZE="-1">LWP</FONT>, LWP::UserAgent, lwpcook.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </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>
|