2

I am developing a program in C# and I am having a problem with Windows credentials.

I need the program return me the user name and password.

using (WebClient client = new WebClient())
{
   string[] user = Convert.ToString(WindowsIdentity.GetCurrent().Name).Split('\\');

   string userName = user[1];

   label1.Text = userName.ToString();
   label2.Text = passwd.ToString();

   //client.Credentials = new NetworkCredential(userName, "1234"); //1234 = password
   //client.DownloadFile("http://**intranet**/servicosuporte/Documentos%20Partilhados/assistente_remoto.zip", @"C:\assistremoto.zip");
}
4

1 回答 1

13

您无法以这种方式访问​​用户的密码。密码是不可逆的,并且是散列的。这是一种单向操作。

如果要使用用户的现有凭据,可以使用:

System.Net.CredentialCache.DefaultNetworkCredentials //for network

System.Net.CredentialCache.DefaultCredentials //for local
于 2013-06-27T19:28:30.627 回答