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