I am trying to store more than 1 username and password per target. The problem is every time a new credential is added with the same username but different targets and passwords, other credentials with the same username are deleted.
My question is how to store multiple usernames and passwords under the same target ?
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;
}
}
}