1LWP::Authen::Ntlm(3) User Contributed Perl Documentation LWP::Authen::Ntlm(3)
2
3
4
6 LWP::Authen::Ntlm - Library for enabling NTLM authentication (Micro‐
7 soft) in LWP
8
10 use LWP::UserAgent;
11 use HTTP::Request::Common;
12 my $url = 'http://www.company.com/protected_page.html';
13
14 # Set up the ntlm client and then the base64 encoded ntlm handshake message
15 my $ua = new LWP::UserAgent(keep_alive=>1);
16 $ua->credentials('www.company.com:80', '', "MyDomain\\MyUserCode", 'MyPassword');
17
18 $request = GET $url;
19 print "--Performing request now...-----------\n";
20 $response = $ua->request($request);
21 print "--Done with request-------------------\n";
22
23 if ($response->is_success) {print "It worked!->" . $response->code . "\n"}
24 else {print "It didn't work!->" . $response->code . "\n"}
25
27 "LWP::Authen::Ntlm" allows LWP to authenticate against servers that are
28 using the NTLM authentication scheme popularized by Microsoft. This
29 type of authentication is common on intranets of Microsoft-centric
30 organizations.
31
32 The module takes advantage of the Authen::NTLM module by Mark Bush.
33 Since there is also another Authen::NTLM module available from CPAN by
34 Yee Man Chan with an entirely different interface, it is necessary to
35 ensure that you have the correct NTLM module.
36
37 In addition, there have been problems with incompatibilities between
38 different versions of Mime::Base64, which Bush's Authen::NTLM makes use
39 of. Therefore, it is necessary to ensure that your Mime::Base64 module
40 supports exporting of the encode_base64 and decode_base64 functions.
41
43 The module is used indirectly through LWP, rather than including it
44 directly in your code. The LWP system will invoke the NTLM authentica‐
45 tion when it encounters the authentication scheme while attempting to
46 retrieve a URL from a server. In order for the NTLM authentication to
47 work, you must have a few things set up in your code prior to attempt‐
48 ing to retrieve the URL:
49
50 · Enable persistent HTTP connections
51
52 To do this, pass the "keep_alive=>1" option to the LWP::UserAgent
53 when creating it, like this:
54
55 my $ua = new LWP::UserAgent(keep_alive=>1);
56
57 · Set the credentials on the UserAgent object
58
59 The credentials must be set like this:
60
61 $ua->credentials('www.company.com:80', '', "MyDomain\\MyUserCode", 'MyPassword');
62
63 Note that you cannot use the HTTP::Request object's authoriza‐
64 tion_basic() method to set the credentials. Note, too, that the
65 'www.company.com:80' portion only sets credentials on the specified
66 port AND it is case-sensitive (this is due to the way LWP is coded,
67 and has nothing to do with LWP::Authen::Ntlm)
68
69 If you run into trouble and need help troubleshooting your problems,
70 try enabling LWP debugging by putting this line at the top of your
71 code:
72
73 use LWP::Debug qw(+);
74
75 You should get copious debugging output, including messages from
76 LWP::Authen::Ntlm itself.
77
79 General queries regarding LWP should be made to the LWP Mailing List.
80
81 Questions specific to LWP::Authen::Ntlm can be forwarded to jtill‐
82 man@bigfoot.com
83
85 Copyright (c) 2002 James Tillman. All rights reserved. This program is
86 free software; you can redistribute it and/or modify it under the same
87 terms as Perl itself.
88
90 LWP, LWP::UserAgent, lwpcook.
91
92
93
94perl v5.8.8 2004-04-06 LWP::Authen::Ntlm(3)