perlnewb123 has asked for the wisdom of the Perl Monks concerning the following question:

Here's my problem. Running perl script on aix, attempting to call a webservice that uses windows NTLM auth. I also have to go through a proxy that uses the same auth. How would I format this script to accomplish that?
#!/usr/bin/perl use LWP::Debug qw(+); use LWP::UserAgent; use HTTP::Request::Common; my $url = 'http://test.test.com/webservice'; my $ua = new LWP::UserAgent(keep_alive=>1); $ua->credentials('test.test.com:80', '', "test\\user", 'pass'); $request = GET $url; print "--Performing request now...-----------\n"; $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: ISA Proxy and LWP
by ikegami (Patriarch) on Oct 17, 2008 at 20:30 UTC
    Please show us the response you're getting. As previously discussed, this can be obtained using
    print $response->as_string();
      Here's what I get:
      LWP::UserAgent::new: () --Performing request now...----------- LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://test.test.com/webservices/tes +t.asmx?op=DecryptText?text=%FA%4%76%B%22%81%7E%0&key=TEST LWP::Protocol::http::request: () LWP::Protocol::http::request: Keep the http connection to test.test.co +m:80 LWP::UserAgent::request: Simple response: Unauthorized --Done with request------------------- It didn't work!->401
      Script is:
      #!/usr/bin/perl -w use lib "/u/user/libwww-perl-5.818/lib"; push(@INC, '/u/user/libwww-perl-5.818/lib'); use LWP::Debug qw(+); use LWP::UserAgent; use HTTP::Request::Common; my $url = 'http://test.test.com/webservices/test.asmx?op=DecryptText?t +ext=%FA%4%76%B%22%81%7E%0&key=TEST'; my $ua = new LWP::UserAgent(keep_alive=>1); $ua->credentials('test.test.com:80', 'test', "test\\user", 'pass'); $request = GET $url; print "--Performing request now...-----------\n"; $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" }
        What do you think "Unauthorized" means?
        That's not what I asked for.
        You should port ntlm_aps to perl or simply use it. LWP itself lacks of NTLM auth
Re: ISA Proxy and LWP
by perlnewb123 (Sexton) on Oct 17, 2008 at 18:12 UTC
    So im getting past the proxy, as it doesnt require auth with:
    $proxy = 'http://isapxy.bcbsfl.com:8080'; $ua->proxy(['http'], $proxy);
    But im still getting a 401 back from the URL.