xytras78 has asked for the wisdom of the Perl Monks concerning the following question:
Monks,
I'm really hoping someone can help me with this as I'm about to bang my head against the wall in frustration. I'm trying to do what should be a simple LWP-UserAgent, but am running into a world of problems with the NTLM authorization.
Here's my scenario. I've got a user account in NewDomain. I'm trying to authenticate against a server in OldDomain. There is a full bi-directional trust between NewDomain and OldDomain. Using NTML auth in a browser works perfectly.
Using the code below, it works perfectly if I'm using a user account in OldDomain. When I ran a Wireshark capture on the traffic, what I found was that even though I'm specifying NewDomain in my code, the response I'm actually sending is OldDomain. OldDomain is issued as part of the NTLM challenge by the server. Why... and how... am I sending OldDomain when I've clearly specified NewDomain?
I'd really appreciate any pointers anyone could offer. I'm really at a loss here.
#!/usr/bin/perl -w use LWP::UserAgent; use HTTP::Request::Common; use LWP::Debug qw(+); use Authen::NTLM; use strict; use warnings; my $url = 'http://mywebserver.com/Path/Path2/MyFile.htm'; # Set up the ntlm client and then the base64 encoded ntlm handshake me +ssage my $ua = LWP::UserAgent->new(keep_alive=>1); my $host = 'mywebserver.com:80'; my $uname = 'NewDomain\User1'; my $psswd = 'test1234'; $ua->credentials("$host", '', "$uname", "$psswd"); 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"}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unable to pass domain in NTLM auth with LWP
by NetWallah (Canon) on Mar 02, 2017 at 17:15 UTC | |
by xytras78 (Initiate) on Mar 02, 2017 at 18:54 UTC |