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");
}
You are unable to access a user's password in this way. Passwords are not reversible, and are hashed. This is a one-way operation.
If you want to use the user's existing credentials, you can use:
System.Net.CredentialCache.DefaultNetworkCredentials //for network
and
System.Net.CredentialCache.DefaultCredentials //for local
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.