As you are using Windows 8, the simplest way is to use the WinRT API. I think you are creating a desktop application (Console, WPF, WinForms), so you have to:
Add
<TargetPlatformVersion>8.0</TargetPlatformVersion>
to the csproj file.
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProjectGuid>{BEA97844-0370-40C1-A435-F95DC0DC0677}</ProjectGuid> <OutputType>Exe</OutputType> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <TargetPlatformVersion>8.0</TargetPlatformVersion>
Add a reference to
Windows
andSystem.Runtime
(look at the link below)- Use the PasswordVault class
var vault = new Windows.Security.Credentials.PasswordVault();
var credentials = vault.RetrieveAll();
foreach (PasswordCredential credential in credentials)
{
Console.WriteLine("{0} {1}", credential.Resource, credential.UserName);
}
Source: http://blogs.softfluent.com/post/2014/03/27/Acceder-a-API-WinRT-depuis-une-application-Desktop.aspx (French)
To get Windows and Generic credential: Encrypting credentials in a WPF application