views:

52

answers:

0

The following code generates a 401 => Net::HTTPUnauthorized error.

From the log:


response-header: x-powered-by => ASP.NET
response-header: content-type => text/html  
response-header: www-authenticate => Negotiate, NTLM  
response-header: date => Mon, 02 Aug 2010 19:48:17 GMT  
response-header: server => Microsoft-IIS/6.0  
response-header: content-length => 1539  
status: 401

The Script is as follows:


require 'rubygems'  
require 'mechanize'  
require 'logger'  

agent = WWW::Mechanize.new { |a| a.log = Logger.new("mech.log") }  

agent.user_agent_alias = 'Windows IE 7'  

agent.basic_auth("username","password")   

page = agent.get("http://server/loginPage.asp")

I believe the reason for the 401 is that I need to be authenticating using NTLM, but I have been unable to find a good example of how to do this.