在凭据管理器中访问 Windows 个凭据
Access Windows Credentials in Credential Manager
使用 Windows.Security.Credentials.PasswordVault
class,我可以访问 Windows 凭据管理器中 "Web Credentials" 下存储的密码:
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" 下的凭据。
有一个名为 CredentialManagement 的 Nuget 库 http://nuget.org/packages/CredentialManagement/
来自此处的答案: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);
使用 Windows.Security.Credentials.PasswordVault
class,我可以访问 Windows 凭据管理器中 "Web Credentials" 下存储的密码:
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" 下的凭据。
有一个名为 CredentialManagement 的 Nuget 库 http://nuget.org/packages/CredentialManagement/ 来自此处的答案: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);