Ok, Here are my examples:
Number one does not work (using LWP):
#!perl;
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request::Common;
my $url = "<some url to an asp page on a protected site here>";
# Set up the ntlm client and then the base64 encoded ntlm handshake me
+ssage
my $ua = new LWP::UserAgent(keep_alive=>1);
$ua->credentials('<host:port here>', '', "<domain\\uid here>", '<pdw h
+ere>');
my $request = GET $url;
print "--Performing request now...-----------\n";
my $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"
}
</code>
Here's number two:
#!perl;
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request::Common;
use Authen::NTLM qw(nt_hash lm_hash);
my $my_pass = "<pwd here>";
my $client = new_client Authen::NTLM(lm_hash($my_pass), nt_hash($my_pa
+ss));
# How does the ntlm functions tie in with Lwp methods?
my $ua = LWP::UserAgent->new(keep_alive=>1);
$ua->proxy('http','<proxy name here>');
my $resp = $ua->request(GET "http://www.perl.com");
my $htmcode = $resp->{_content};
print "here comes the output...\n$htmcode\n";
(I guess the uid will be automatically retrieved using a domain server) -> this ons doesn't work either btw...
I have a number three but that one's under construction. I got the example from this very site, but I guess it doesn't come from a monk but from some lone passenger... (the code uses DBI and DBI::Oracle and there's a lot of crap in it *and it doen't use strict or warnings* which one should use always, even in an example!!!
Ergo: Who can prove to this soon-to-be-disappointed-novice-monk that the guys who actually took the time to write modules for NTLM authentication did it to solve the NTLM problem in stead of just killing their time writing stuf that won't work anyway...?
To me, the first who can actually show me this, truely has seen the light, if not: he *IS* the light!
For the record: These are all "solution's" that people came up with for the same question as mine.
Thans in advance!
John
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.