Setting HttpWebRequest Credentials to be current user

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,
 
R

richlm

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

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

Richard.
 
J

Jamie

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
 
J

Jamie

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
 
J

Jamie

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
 

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top