Setting HttpWebRequest Credentials to be current user

  • Thread starter Thread starter Jamie
  • Start date Start date
J

Jamie

I'm trying to create a HttpWebRequest object that uses the current logged in
users credentials. The site is using Windows Authentication, Anonymous
access is turned off.

Will the HttpWebRequest object use the current users credentials if i use
<identity impersonate="true" /> ? or do i have to set the Credentials
property of the web request? If i do, how do i set it to be the current
windows user logged into the application? I don't want to create a
NetworkCredential object where i would have to pass in the login and
password of the user.

Thanks,
 
e.g. myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials;

Look up System.Net on MSDN library for more info.

Richard.
 
Thanks. I tried that and thought it was working.. but it only seems to work
when i'm on 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.

It's currently setup with

<identity impersonate="true" /> in web.config

IIS - Windows Authentication

myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials
 
anybody? :(


Jamie said:
Thanks. I tried that and thought it was working.. but it only seems to work
when i'm on 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.

It's currently setup with

<identity impersonate="true" /> in web.config

IIS - Windows Authentication

myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials
 
anybody? :(


Jamie said:
Thanks. I tried that and thought it was working.. but it only seems to work
when i'm on 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.

It's currently setup with

<identity impersonate="true" /> in web.config

IIS - Windows Authentication

myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials
 
Back
Top