2013-03-19 7 views
1

오래 전 .NET Framework 2.0에서 VB로 개발 된 레거시 HTTP 클라이언트 응용 프로그램이 있습니다. 최근에 새 프록시 서버가 우리 네트워크에 도입되어 VB 응용 프로그램이 "407 프록시 인증 필요"오류를 만나기 시작했습니다.NTLM 인증 프록시 전달

프록시에 NTLM 인증이 필요하며 프로그램에서이를 고려하지 않았습니다.

일부 웹 리소스를 검색 한 후 다음 코드를 작성했습니다.

Dim proxy As New System.Net.WebProxy("http://my.proxy.com:81") 
proxy.Credentials = System.Net.CredentialCache.DefaultCredentials 
proxy.UseDefaultCredentials = true 
webreq.Proxy = proxy 

하지만 여전히 407 오류가 표시됩니다. 사용자가 Windows 도메인에 로그인하고 있습니다.

나는 (그러나 유사한) 다른 방법을 시도했지만 성공하지 못합니다.

누구나 내가 놓칠 수있는 점을 지적 할 수 있습니까?

보안 정책 설정으로 인해 작동하지 않을 가능성이 있습니까?

네트워크 관리자에게 문의 할 수는 있지만 응용 프로그램 개발에 익숙하지 않아서 내가 어떤 질문을해야할지 모르겠다.

도움을 주시면 감사하겠습니다.

답변

0

나는 이것에 대한 해결책을 찾고있다. 아마도 보안과 관련이 있습니다. 인트라넷 보안 영역에 있습니까? http://www.codinghorror.com/blog/2005/04/aspnet-ntlm-authentication---is-it-worth-it.html

다음에서 찾았습니다. http://bytes.com/topic/net/answers/544841-ntlm-authentication-how 시작되었지만 문제가 있습니다.

public string SendRequest() 
     // run the request and return a string response 
     { 
      string FinalResponse = ""; 
      string Cookie = ""; 

      NameValueCollection collHeader = new NameValueCollection(); 

      HttpWebResponse webresponse; 

      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI); 

      request.KeepAlive = true; 
      request.Timeout = 10000; 
      request.Method = "POST"; 
      request.AllowAutoRedirect = false; 
      request.Proxy = WebProxy.GetDefaultProxy(); 

      string addr = "http://" + ProxyServer + ":" + String.Format("{0:D}", ProxyPort); 
      Uri u = new Uri(addr); 

      CredentialCache wrCache = new CredentialCache(); 
      wrCache.Add(u, "Negotiate", System.Net.CredentialCache.DefaultNetworkCredentials); 

      request.Proxy.Credentials = wrCache; 

      try 
      { 
       byte[] bytes = Encoding.ASCII.GetBytes(Request); 
       request.ContentLength = bytes.Length; 

       Stream oStreamOut = request.GetRequestStream(); 
       oStreamOut.Write(bytes, 0, bytes.Length); 
       oStreamOut.Close(); 

       webresponse = (HttpWebResponse)request.GetResponse(); 
       if (null == webresponse) 
       { 
        FinalResponse = "No Response from " + URI; 
       } 
       else 
       { 
        Encoding enc = System.Text.Encoding.GetEncoding(1252); 
        StreamReader rdr = new StreamReader(webresponse.GetResponseStream(),enc); 
        FinalResponse = rdr.ReadToEnd(); 
       } 

      }//End of Try Block 

      catch (WebException e) 
      { 
       // some kind of error.. 
       if (407 == (int)e.Status) 
       { 
       } 

       throw CatchHttpExceptions(FinalResponse = e.Message); 
      } 
      catch (System.Exception e) 
      { 
       throw new Exception(FinalResponse = e.Message); 
      } 
      finally 
      { 
       // BaseHttp = null; 
      } 
      return FinalResponse; 
     } //End of SendRequestTo method