in reply to Re: ISA Proxy and LWP
in thread ISA Proxy and LWP

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

Replies are listed 'Best First'.
Re^3: ISA Proxy and LWP
by Anonymous Monk on Oct 18, 2008 at 01:28 UTC
    What do you think "Unauthorized" means?
      Nice... I know what it means dude. Im passing the right creds, for some reason ntlm isnt working. Ive updated the mod too.
Re^3: ISA Proxy and LWP
by ikegami (Patriarch) on Oct 18, 2008 at 02:37 UTC
    That's not what I asked for.
      That's the response im getting back from the webservice. 401. I know im using the right creds, etc. Looking on other groups, etc, a lot of people have this same problem. Also tried running this with Mechanize:
      use HTTP::Request::Common; use Data::Dumper; use WWW::Mechanize; use MIME::Base64; my $url = 'http://test.test.com/webservices/test.asmx?; my $Domain = 'test'; my $UserName = 'test\\user'; my $Password = "pass"; my $agent = WWW::Mechanize->new(); my @args = ( Authorization => "Basic " . MIME::Base64::encode( $UserName . ':' . $Password ) ); $agent->credentials( 'http://test.test.com' , $Domain, $UserName, $Pas +sword ); my $results = $agent->get( $url, @args ); print Dumper($results);
      Results:
      $VAR1 = bless( { '_protocol' => 'HTTP/1.1', '_content' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTM +L 4.01//EN " "http://www.w3.org/TR/html4/strict.dtd"> <HTML><HEAD><TITLE>You are not authorized to view this page</TITLE> <META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-12 +52"> <STYLE type="text/css"> BODY { font: 8pt/12pt verdana } H1 { font: 13pt/15pt verdana } H2 { font: 8pt/12pt verdana } A:link { color: red } A:visited { color: maroon } </STYLE> </HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD> <h1>You are not authorized to view this page</h1> You do not have permission to view this directory or page using the cr +edentials that you supplied because your Web browser is sending a WWW-Authentica +te header field that the Web server is not configured to accept. <hr> <p>Please try the following:</p> <ul> <li>Contact the Web site administrator if you believe you should be ab +le to view this directory or page.</li> <li>Click the <a href="javascript:location.reload()">Refresh</a> butto +n to try a gain with different credentials.</li> </ul> <h2>HTTP Error 401.2 - Unauthorized: Access is denied due to server co +nfiguratio n.<br>Internet Information Services (IIS)</h2> <hr> <p>Technical Information (for support personnel)</p> <ul> <li>Go to <a href="http://go.microsoft.com/fwlink/?linkid=8180">Micros +oft Produc t Support Services</a> and perform a title search for the words <b>HTT +P</b> and <b>401</b>.</li> <li>Open <b>IIS Help</b>, which is accessible in IIS Manager (inetmgr) +, and search for topics titled <b>About Security</b>, <b>Authentication +</b>, and <b>About Custom Error Messages</b>.</li> </ul> </TD></TR></TABLE></BODY></HTML> ', '_rc' => 401, '_headers' => bless( { 'x-powered-by' => 'ASP.NET', 'client-response-num' => 1, 'date' => 'Sat, 18 Oct 2008 03 +:02:01 GMT ', 'client-peer' => '172.xx.xx.xx +:80', 'content-length' => '1656', 'client-warning' => 'Unsupport +ed authent ication scheme \'ntlm\'', 'client-date' => 'Sat, 18 Oct +2008 03:02 :02 GMT', 'content-type' => [ 'text/html +', 'text/html +; charset= Windows-1252' ], 'www-authenticate' => [ 'Negot +iate', 'NTLM' ], 'server' => 'Microsoft-IIS/6.0 +', 'title' => 'You are not author +ized to vi ew this page' }, 'HTTP::Headers' ), '_msg' => 'Unauthorized', '_request' => bless( { '_content' => '', '_uri' => bless( do{\(my $o = +'http://test.test.com/webservices/test.asmx?')}, 'URI::http' ), '_headers' => bless( { 'user-a +gent' => ' WWW-Mechanize/1.3401', 'accept +-encoding' => 'gzip', 'author +ization' = > 'Basic YmNic2ZsXHN2Yy1pc2R3ZXNwOlI4bjJCMnRjaA== ' }, 'HTTP: +:Headers' ), '_method' => 'GET' }, 'HTTP::Request' ) }, 'HTTP::Response' ); C:\>

        That's the response im getting back from the webservice

        No, that's the status code of the response. I showed you (twice!) how to print the response.

        The Data::Dumper output isn't as readable as ->as_string, but it also holds the info I was seeking:

        'www-authenticate' => [ 'Negotiate', 'NTLM' ],

        LWP only supports basic and digest authentication, but the server is asking for NTLM authentication. I'd start by checking out the module the Anonymous Monk mentioned.

Re^3: ISA Proxy and LWP
by petr999 (Acolyte) on Oct 18, 2008 at 12:59 UTC
    You should port ntlm_aps to perl or simply use it. LWP itself lacks of NTLM auth