By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,489 Members | 3,084 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,489 IT Pros & Developers. It's quick & easy.

NetworkCredential and WindowsIdentity

P: n/a
Hi All,

I'm trying to access a web page from C# code. Since I'm
behind a firewall/proxy, I creat a webproxy and
NetworkCredential to access the web page. It works fine.

In this way, I have to give the username and password for
creating the NetworkCredential object. Is there anyway
that I can get the NetworkCredential object from the
logged on user?

Basically the requirement is to supply the same credential
as of the logged in user to the web proxy.

Help!!

regards,
Prathiraj
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Prathiraj,

No, you can not. While you can get the username of the person that is
currently logged on, you can not get the password. You will have to get
this from the user themselves.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Prathiraj" <pr*******@hotmail.com> wrote in message
news:09****************************@phx.gbl...
Hi All,

I'm trying to access a web page from C# code. Since I'm
behind a firewall/proxy, I creat a webproxy and
NetworkCredential to access the web page. It works fine.

In this way, I have to give the username and password for
creating the NetworkCredential object. Is there anyway
that I can get the NetworkCredential object from the
logged on user?

Basically the requirement is to supply the same credential
as of the logged in user to the web proxy.

Help!!

regards,
Prathiraj

Nov 15 '05 #2

P: n/a
here is an example of usage of CredentialCache.DefaultCredentials

// Ensure Directory Security settings for default web site in IIS is
"Windows Authentication".
string url = "http://localhost";
// Create a 'HttpWebRequest' object with the specified url.
HttpWebRequest myHttpWebRequest =
(HttpWebRequest)WebRequest.Create(url);
// Assign the credentials of the logged in user or the user being
impersonated.
myHttpWebRequest.Credentials = CredentialCache.DefaultCredentials;
// Send the 'HttpWebRequest' and wait for response.
HttpWebResponse myHttpWebResponse =
(HttpWebResponse)myHttpWebRequest.GetResponse();
Console.WriteLine("Authentication successful");
Console.WriteLine("Response received successfully");
Nicholas Paldino [.NET/C# MVP] wrote:
Prathiraj,

No, you can not. While you can get the username of the person that is currently logged on, you can not get the password. You will have to get this from the user themselves.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Prathiraj" <pr*******@hotmail.com> wrote in message
news:09****************************@phx.gbl...
Hi All,

I'm trying to access a web page from C# code. Since I'm
behind a firewall/proxy, I creat a webproxy and
NetworkCredential to access the web page. It works fine.

In this way, I have to give the username and password for
creating the NetworkCredential object. Is there anyway
that I can get the NetworkCredential object from the
logged on user?

Basically the requirement is to supply the same credential
as of the logged in user to the web proxy.

Help!!

regards,
Prathiraj


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.