CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2012
    Posts
    12

    Auto network credentials

    Hi!
    I'm writing a program that reads some data from a website to do some calculations and display the results on the GUI.
    The program works correctly without a proxy, but unfortunately it is going to be used mostly behind one.

    The computers where the program will be installed use network accounts (in a domain) and after opening the browser the window's account username/password combination is valid to surf.

    My problem is that I'm unable to do the same, that is get the cached username/password combo to connect to internet (using HttpWebRequest) without asking the user to type the required information (I tried to use NetworkCredentials, but the program still returns a 407 Authorization required error).

    How can I do that?

  2. #2
    Join Date
    Jan 2012
    Posts
    12

    Re: Auto network credentials

    Ok, it seems that what I want to do is not possible.
    The reason is security of information, it would be quite easy to steal login information from a user if the password was available.

    I ended up using a small form that pulls up the domain and username with
    PHP Code:
    WindowsIdentity wi System.Security.Principal.WindowsIdentity.GetCurrent(); 
    and than asks for the password.

    I currently check if the login information is correct with this:
    PHP Code:
    try
    {
       
    HttpWebRequest proxyTestRequest = (HttpWebRequest)WebRequest.Create(destWebPage);
       
    WebProxy testProxy = new WebProxy();
       
    testProxy.Address proxy.GetProxy(destWebPage);
       
    testProxy.Credentials = new NetworkCredential(proxyUserproxyPasswordproxyDomain);
       
    proxyTestRequest.Proxy testProxy;
       
    WebResponse myResponse proxyTestRequest.GetResponse();
       
    myResponse.Close();
    }
    catch (
    WebException we)
    {
       if (
    we.Status == WebExceptionStatus.RequestProhibitedByProxy)
       {
           
    //Rest of the code that opens a form as dialog, gets the login combination and stores it as proxyDomain, proxyUsername and proxyPassword
       
    }

    Is it a good way to do it or I should use something different? In this case what should I use?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured