{"id":7337,"date":"2022-12-20T19:37:44","date_gmt":"2022-12-20T22:37:44","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/lwpauthenntlm-man3\/"},"modified":"2022-12-20T19:37:44","modified_gmt":"2022-12-20T22:37:44","slug":"lwpauthenntlm-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/lwpauthenntlm-man3\/","title":{"rendered":"LWP::Authen::Ntlm (man3)"},"content":{"rendered":"<h1 align=\"center\">LWP::Authen::Ntlm<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#USAGE\">USAGE<\/a><br \/> <a href=\"#AVAILABILITY\">AVAILABILITY<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">LWP::Authen::Ntlm \u2212 Library for enabling NTLM authentication (Microsoft) in LWP<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">use LWP::UserAgent; <br \/> use HTTP::Request::Common; <br \/> my $url = &#8216;http:\/\/www.company.com\/protected_page.html&#8217;; <br \/> # Set up the ntlm client and then the base64 encoded ntlm handshake message <br \/> my $ua = LWP::UserAgent\u2212>new(keep_alive=>1); <br \/> $ua\u2212>credentials(&#8216;www.company.com:80&#8217;, &#8221;, &#8220;MyDomain\\MyUserCode&#8221;, &#8216;MyPassword&#8217;); <br \/> $request = GET $url; <br \/> print &#8220;\u2212\u2212Performing request now&#8230;\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212n&#8221;; <br \/> $response = $ua\u2212>request($request); <br \/> print &#8220;\u2212\u2212Done with request\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212\u2212n&#8221;; <br \/> if ($response\u2212>is_success) {print &#8220;It worked!\u2212>&#8221; . $response\u2212>code . &#8220;n&#8221;} <br \/> else {print &#8220;It didn&#8217;t work!\u2212>&#8221; . $response\u2212>code . &#8220;n&#8221;}<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">LWP::Authen::Ntlm allows <small>LWP<\/small> to authenticate against servers that are using the <small>NTLM<\/small> authentication scheme popularized by Microsoft. This type of authentication is common on intranets of Microsoft-centric organizations.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The module takes advantage of the Authen::NTLM module by Mark Bush. Since there is also another Authen::NTLM module available from <small>CPAN<\/small> by Yee Man Chan with an entirely different interface, it is necessary to ensure that you have the correct <small>NTLM<\/small> module.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">In addition, there have been problems with incompatibilities between different versions of Mime::Base64, which Bush\u2019s 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.<\/p>\n<h2>USAGE <a name=\"USAGE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The module is used indirectly through <small>LWP,<\/small> rather than including it directly in your code. The <small>LWP<\/small> system will invoke the <small>NTLM<\/small> authentication when it encounters the authentication scheme while attempting to retrieve a <small>URL<\/small> from a server. In order for the <small>NTLM<\/small> authentication to work, you must have a few things set up in your code prior to attempting to retrieve the <small>URL:<\/small><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"52%\">\n<p>Enable persistent <small>HTTP<\/small> connections<\/p>\n<\/td>\n<td width=\"31%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">To do this, pass the &#8220;keep_alive=>1&#8221; option to the LWP::UserAgent when creating it, like this:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">my $ua = LWP::UserAgent\u2212>new(keep_alive=>1);<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"1%\">\n<p style=\"margin-top: 1em\">\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"66%\">\n<p style=\"margin-top: 1em\">Set the credentials on the UserAgent object<\/p>\n<\/td>\n<td width=\"17%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%; margin-top: 1em\">The credentials must be set like this:<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">$ua\u2212>credentials(&#8216;www.company.com:80&#8217;, &#8221;, &#8220;MyDomain\\MyUserCode&#8221;, &#8216;MyPassword&#8217;);<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Note that you cannot use the HTTP::Request object\u2019s <b>authorization_basic()<\/b> method to set the credentials. Note, too, that the \u2019www.company.com:80\u2019 portion only sets credentials on the specified port <small>AND<\/small> it is case-sensitive (this is due to the way <small>LWP<\/small> is coded, and has nothing to do with LWP::Authen::Ntlm)<\/p>\n<h2>AVAILABILITY <a name=\"AVAILABILITY\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">General queries regarding <small>LWP<\/small> should be made to the <small>LWP<\/small> Mailing List.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Questions specific to LWP::Authen::Ntlm can be forwarded to jtillman@bigfoot.com<\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">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.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><small>LWP<\/small> , LWP::UserAgent, lwpcook.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  LWP::Authen::Ntlm \u2212 Library for enabling NTLM authentication (Microsoft) in LWP <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3655,3007],"class_list":["post-7337","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-lwpauthenntlm","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7337"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7337\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}