2009-07-03 4 views
2

내가 서버를 파일을 다운로드 할 루비 스크립트를 얻기 위해 노력하고있어,하지만 난 IIS에서 401.2을 얻고에서 인증 작업 :도움말 얻기 순 :: HTTP 루비

당신은하지 않습니다 웹 브라우저가 웹 서버가 동의 에 구성되지 않은하는 WWW 인증 헤더 필드를 전송하기 때문에 사용자가 제공 한 자격 증명을 사용하여 이 디렉터리 또는 페이지를 볼 수있는 권한이 있습니다.

기본 인증을 사용할 수 있는지 확인했습니다. Ruby가 기본 인증을 처리하는 방법에 특별한 것이 있습니까? 서버가 실제로 무엇을 얻고 헤더가 받아 들일 수 있는지를 알 수있는 방법이 있습니까?

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 
    } 

답변

1

Snippet from the Microsoft website

HTTP 401.2 : 인증 프로토콜에 동의하지 않을 수있는 서버 구성 설명

클라이언트 브라우저와 IIS에 의해 거부

이 내 코드입니다.

일반적인 이유

* 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. 

또한 NTLM의 인증을 사용할 수 있습니다 ruby-httpclient - Simple HTTPClient library for Ruby보고 시도해야합니다.

+1

저는 이것이 ruby-httpclient에 대한 올바른 URL이라고 생각합니다 : https://rubygems.org/gems/httpclient. – hughdbrown