HttpWebRequest, impersonation and DefaultCredentials problem.

J

Jamie

I'm trying to create a HttpWebRequest object that uses the current logged in
user's credentials.

It's currently setup with:
<identity impersonate="true" /> in web.config
IIS - Windows Authentication
IIS - Anonymous access disabled

making the request like this:
HttpWebRequest webrequest =
(HttpWebRequest)WebRequest.Create("http://myserver/site/page.aspx);
webrequest.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse();


I've verified that impersonate is working correctly on the aspx page by
printing out:
System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();

It's also using windows authentication properly, i've verified that by
printing out: Page.User.Identity.Name.ToString();

It only seems to work when I browse to the page from the same system as the
webserver. When i go to another system
and browse to the web page i get a (401) unauthorized error message.

Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top