Access Windows Credentials in Credential Manager

11,717

There is a Nuget library called CredentialManagement http://nuget.org/packages/CredentialManagement/ from the answer here: Retrieve Credentials from Windows Credentials Store using C#

works perfectly

        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);
Share:
11,717
Paolo Tedesco
Author by

Paolo Tedesco

Worked mainly in C++, C# and python, in Windows and Unix environments. SOreadytohelp

Updated on July 08, 2022

Comments

  • Paolo Tedesco
    Paolo Tedesco almost 2 years

    Using the Windows.Security.Credentials.PasswordVault class, I can access the passwords stored under "Web Credentials" in the Windows Credential Manager:

    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);
            }
        }
    }
    

    I would like to know if there's a way to retrieve the credentials stored under "Windows Credentials" instead.