我试图为每个目标存储超过 1 个用户名和密码。问题是每次添加具有相同用户名但目标和密码不同的新凭据时,具有相同用户名的其他凭据都会被删除。
我的问题是如何在同一个目标下存储多个用户名和密码?
public class PasswordRepository
{
public string username;
public string temp;
LoggedIn li = new LoggedIn();
public void SavePassword(string password, string PasswordName)
{
using (var cred = new Credential())
{
cred.Password = password;
cred.Target = username;
cred.Username = PasswordName;
cred.Type = CredentialType.Generic;
cred.PersistanceType = PersistanceType.LocalComputer;
cred.Save();
}
temp = "";
}
public string GetPassword()
{
using (var cred = new Credential())
{
cred.Target = username;
cred.Load();
Debug.WriteLine(cred.Password +" "+cred.Username);
temp = cred.Password;
return cred.Password;
}
}
}