How to access the stored credentials (PasswordVault?) on Win7 and Win8?
Asked Answered
M

3

10

I just discovered that Win8 has a section on the Control Panel called User Accounts and Family Safely with Credential Manager. I'd like to access the credentials stored in there (not to retrieve the passwords but to use them as tokens for a login). So, basically, I'd like to get a piggy-back ride on already installed software.

The closest to a solution has been suggested in this discussion and it's not that close.

  1. Where do I find the assembly for Windows.Security.Credentials.PasswordVault? I've been googling for two hours but I only get information on app development while I'll be targeting desktop.

  2. Is there a way to resolve access to the pre-stored credentials for both Win7 and Win8? I fear a little bit that the vault facility has been drastically remodeled in Win8, making it impossible to target both platforms at once.

Mobster answered 11/2, 2013 at 13:50 Comment(4)
The assembly for PasswordVault resides in Windows.winmd.Subclavian
I have nothing staring with Windows when I try to add references to an assembly. What could be wrong?!Mobster
In the Reference Manager, do you see a section called Windows, just between COM and Browse?Subclavian
@AlexFilipovici Nope... I've got: .NET / COM / Projects / Browse / Recent. That's all.Mobster
S
7

How to: Add or Remove References By Using the Reference Manager says:

In the desktop projects the Core tab doesn’t appear by default. You can add the Windows Runtime by opening the shortcut menu for the project node, choosing Unload Project, adding the following snippet, and re-opening the project (on the project node choose Reload Project). When you invoke the Reference Manager dialog box, the Core tab appears.

<PropertyGroup>
    <TargetPlatformVersion>8.0</TargetPlatformVersion>
</PropertyGroup>

Make sure to check the Windows box on this tab. You should then be able to use WinRT elements.

Subclavian answered 11/2, 2013 at 14:24 Comment(3)
This is not going to fly for Win7, is it?Mobster
Unfortunately, no. Probably, you'll get an exception at runtime: System.PlatformNotSupportedException: Operation is not supported on this platform.Subclavian
for win8 and full how-to details see codeproject.com/Articles/457335/…Dermatophyte
J
6

I came across the same issue and found out that there is no simple answer anywhere.

This is what I found:

  1. You need to unload the project and add the TargetPlatformVersion as mentioned above.
  2. Add the reference: C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral\Annotated\Windows.winmd
  3. Also add the reference: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll
Jesusitajet answered 10/6, 2015 at 20:13 Comment(0)
P
3

You can use wrapped Credential Management package. It's an open-source project. I checked it in Windows 7 and it works right.

In order to save your data use following code:

    Credential saved = new Credential("username", "password", "MyApp", CredentialType.Generic);
    saved.PersistanceType = PersistanceType.LocalComputer;
    saved.Save();

And to load your data use:

    Credential credential = new Credential { Target = "MyApp", Type = CredentialType.Generic };
    credential.Load();
Peppers answered 30/11, 2014 at 10:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.