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(proxyUser, proxyPassword, proxyDomain);
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?