【问题标题】:Access Windows Credentials in Credential Manager在凭据管理器中访问 Windows 凭据
【发布时间】:2015-03-23 15:36:31
【问题描述】:

使用 Windows.Security.Credentials.PasswordVault 类,我可以访问存储在 Windows 凭据管理器中“Web 凭据”下的密码:

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 凭据”下的凭据。

【问题讨论】:

  • 要在桌面应用程序中添加对 Windows.Security 的引用,请在此处查看:stackoverflow.com/questions/14813370/…
  • Windows 不存储实际密码,它通常是某种类型的密码哈希。获取用户明文 Windows 密码的唯一方法是在用户在登录期间键入它时捕获它。为此,您需要编写一个 Windows 凭据提供程序。
  • @MohitA:我在这里谈论的是完全不同的东西。我想检索 我存储在 Windows 凭据下的凭据管理器中的密码,我不想嗅探其他用户的密码。
  • 此解决方案在 IIS 中对您有用吗?

标签: c# security credential-manager


【解决方案1】:

有一个名为 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);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-15
    • 1970-01-01
    • 2011-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多