R
Rodrigo Estrada
Hi all
I hope this is the right newsgroup. I'm having a hard time making a web request from an authenticated process. Here's the scenario
Managed WinForms component hosted in IE, the virtual Directory has Anonymous access disabled and only has Integrated Windows Authentication enabled. When I hit the URL I get challenged for credentials, once I input them I can see the page with my control. The control uses the class WebRequest to make an Http get request for information on the same virtual directory with Integrated Windows Authentication. If I use the following code, everything works as expected
WebRequest req
HttpWebResponse resp
NetworkCredential credential
req = WebRequest.Create("http://localhost/security/GetImage.aspx")
req.PreAuthenticate = true
credential = new NetworkCredential("user", "password", "domain")
req.Credentials = credential
resp = (HttpWebResponse)req.GetResponse()
In my scenario, I don't have access to domain, username and password information, so I have to use the credentials already used by my already authenticated process. In my search I've found that the following code would do the trick
WebRequest req
HttpWebResponse resp
req = WebRequest.Create("http://localhost/security/GetImage.aspx")
req.PreAuthenticate = true
req.Credentials = System.Net.CredentialCache.DefaultCredentials
resp = (HttpWebResponse)req.GetResponse()
But in this case I get an 401 Unauthorized error. Can anybody tell me if I'm doing something wrong and how to solve it
Many TIA
- Rodrigo
I hope this is the right newsgroup. I'm having a hard time making a web request from an authenticated process. Here's the scenario
Managed WinForms component hosted in IE, the virtual Directory has Anonymous access disabled and only has Integrated Windows Authentication enabled. When I hit the URL I get challenged for credentials, once I input them I can see the page with my control. The control uses the class WebRequest to make an Http get request for information on the same virtual directory with Integrated Windows Authentication. If I use the following code, everything works as expected
WebRequest req
HttpWebResponse resp
NetworkCredential credential
req = WebRequest.Create("http://localhost/security/GetImage.aspx")
req.PreAuthenticate = true
credential = new NetworkCredential("user", "password", "domain")
req.Credentials = credential
resp = (HttpWebResponse)req.GetResponse()
In my scenario, I don't have access to domain, username and password information, so I have to use the credentials already used by my already authenticated process. In my search I've found that the following code would do the trick
WebRequest req
HttpWebResponse resp
req = WebRequest.Create("http://localhost/security/GetImage.aspx")
req.PreAuthenticate = true
req.Credentials = System.Net.CredentialCache.DefaultCredentials
resp = (HttpWebResponse)req.GetResponse()
But in this case I get an 401 Unauthorized error. Can anybody tell me if I'm doing something wrong and how to solve it
Many TIA
- Rodrigo