使用Windows.Security.Credentials.PasswordVault
类,我可以访问存储在" Web凭证"在Windows凭据管理器中:
using System;
using Windows.Security.Credentials;
class Program {
static void Main(string[] args) {
PasswordVault vault = new PasswordVault();
foreach (var cred in vault.RetrieveAll()) {
cred.RetrievePassword();
Console.WriteLine("Resource: {0}", cred.Resource);
Console.WriteLine("UserName: {0}", cred.UserName);
Console.WriteLine("Password: {0}", cred.Password);
}
}
}
我想知道是否有办法检索存储在" Windows Credentials"代替。
答案 0 :(得分:4)
有一个名为CredentialManagement http://nuget.org/packages/CredentialManagement/的Nuget库 从答案:Retrieve Credentials from Windows Credentials Store using C#
完美运作
var cm = new Credential();
cm.Target = "mycredentialname";
if (!cm.Exists())
{
Console.WriteLine("cm is null");
}
cm.Load();
Console.WriteLine("Password: " + cm.Password);
Console.WriteLine("Username: " + cm.Username);