2009-07-03 7 views
2

Ich versuche, ein Ruby-Skript zu erhalten, eine Datei aus einem Server herunterzuladen, aber ich bin ein 401,2 von IIS erhalten:Hilfe bekommen Net :: HTTP arbeitet mit Authentifizierung in Ruby

Sie dies nicht tun hat die Erlaubnis dieses Verzeichnis oder Seite mit den Anmeldeinformationen anzuzeigen, die Sie geliefert, weil Ihr Web-Browser ein WWW-Authenticate-Header-Feld senden, dass die Webserver nicht auf akzeptieren konfiguriert ist.

Ich habe überprüft, dass grundlegende Auth aktiviert ist. Gibt es etwas Besonderes, wie Ruby grundlegende Auth behandelt? Gibt es eine Möglichkeit für mich zu sehen, was der Server tatsächlich bekommt und was die Header sagen, ist akzeptabel?

Dies ist mein Code:

Net::HTTP.start(url, port) {|http| 
     req = Net::HTTP::Get.new('/file.txt') 
     req.basic_auth 'username', 'password' 
     response = http.request(req) 
     puts response.body 
    } 

Antwort

1

Snippet from the Microsoft website

HTTP 401.2: Verweigert aufgrund Serverkonfiguration Beschreibung

Der Client-Browser und IIS nicht auf einem Authentifizierungsprotokoll einigen konnten.

Häufige Gründe

* No authentication protocol (including anonymous) is selected in IIS. At least one authentication type must be selected. For more information, click the following article number to view the article in the Microsoft Knowledge Base: 
    253667 (http://support.microsoft.com/kb/253667/) Error message: HTTP 401.2 - Unauthorized: Logon failed due to server configuration with no authentication 
* Only Integrated authentication is enabled, and an older, non-Internet Explorer client browser tries to access the site. This happens because the client browser cannot perform Integrated authentication. To resolve this problem, use one of the following methods: 
     o Configure IIS to accept Basic authentication. This should only occur over SSL for security purposes. 
     o Use a client browser that can perform Integrated authentication. Internet Explorer and new versions of Netscape Navigator and Mozilla Firefox can perform Integrated authentication. 
* Integrated authentication is through a proxy. This happens because the proxy doesn't maintain the NTLM-authenticated connection and thus sends an anonymous request from the client to the server. Options to resolve this problem are as follows: 
     o Configure IIS to accept Basic authentication. This should only occur over SSL for security purposes. 
     o Don't use a proxy. 

Sie sollten auch versuchen, auf ruby-httpclient - Simple HTTPClient library for Ruby zu suchen, die NTLM Auth verwenden können.

+1

Ich denke, das ist die richtige URL für Ruby-httpclient jetzt: https://rubygems.org/gems/httpclient. – hughdbrown