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"}

In reply to Unable to pass domain in NTLM auth with LWP by xytras78

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.