my $Options = { user => 'UsernameIsHere', password => "***********", domain => 'ServerAddressIsHere.com/', timeout => 30, protocol => "https", AuthMethod => "NTLM", ##BrowserAgent => "MSIE 6.0; Windows NT 5.0", RequestMethod => "GET", ##DataDir => "/tmp", }; ##my $log = "/var/tmp/get_url.log"; ##my $DataDir = "/tmp"; my $ua = LWP::UserAgent->new(keep_alive=>'1'); ##agent=>'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)', ###################################### # First stage of NTLM authentication # ###################################### my $url = "http://ServerAddressIsHere.com/mbSDKService/MsgSDK.asmx/RunQuery?queryName=QueryNameIsHere"; ntlm_domain($Options->{'domain'}); ntlm_user($Options->{'user'}); ntlm_password($Options->{'password'}); my $Authorization = Authen::NTLM::ntlm(); my $header = HTTP::Headers->new( ##Content_Type => 'text/html', ##'WWW-Authenticate' => $Options->{'AuthMethod'} ); $header->header('Authorization' => "NTLM $Authorization"); my $request = HTTP::Request->new($Options->{'RequestMethod'} => $url, $header); my $res = $ua->request( $request ); ################################## # Second stage of authentication # ################################### ### challenge my $Challenge = $res->header('WWW-Authenticate'); $Challenge =~ s/^NTLM //g; $Authorization = Authen::NTLM::ntlm($Challenge); $header->header('Authorization' => "NTLM $Authorization"); $request = HTTP::Request->new($Options->{'RequestMethod'} => $url, $header); $res = $ua->request( $request ); ### ntlm reset for eventual connects with a different user #ntlm_reset(); if($res->is_success) { $data = $res->decoded_content(); } else { print "ERROR: Can not dump data from $url\nReturned code: " . $res->code . " (" . $res->status_line . ")\n"; exit; }