here is an example of usage of CredentialCache .DefaultCredent ials
// 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 myHttpWebReques t =
(HttpWebRequest )WebRequest.Cre ate(url);
// Assign the credentials of the logged in user or the user being
impersonated.
myHttpWebReques t.Credentials = CredentialCache .DefaultCredent ials;
// Send the 'HttpWebRequest ' and wait for response.
HttpWebResponse myHttpWebRespon se =
(HttpWebRespons e)myHttpWebRequ est.GetResponse ();
Console.WriteLi ne("Authenticat ion successful");
Console.WriteLi ne("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.co m
"Prathiraj" <pr*******@hotm ail.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
NetworkCredenti al to access the web page. It works fine.
In this way, I have to give the username and password for
creating the NetworkCredenti al object. Is there anyway
that I can get the NetworkCredenti al 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