Remove any entry from web credentials portion of credential manager programmatically

2.9k Views Asked by At

I am developing a WPF desktop application that will only allow 3 metro apps to be used by any user i.e. FB, Skype, Viber. As soon as user End His Session via my application I have to remove the credentials used by the user to login to these apps. I found that these metro apps store there credentials related info in "Web Credentials" portion of Credential Manager. I want to remove these enteries programmatically using C# so that when any other user opens the metro application via my application he sees the login screen.

3

There are 3 best solutions below

0
On BEST ANSWER

I would want to tell the method that i used to clear web credentials.

  1. Stop Credential Manager Service from application running with admin privileges.
  2. Delete all files with extensions .vcrd and .vsch in local users's Local\Microsoft\Vault.
  3. Start Credential Manager Service.

Note: For Point 2, application must run in specific user privilege because each user has his own profile.

0
On

Try this code :

        NetworkCredential networkCredential = new NetworkCredential("username", "password");

        WebRequest webRequest = HttpWebRequest.Create("http://www.contoso.com/");
        webRequest.Credentials = networkCredential;

        CredentialCache credentialCache = new CredentialCache();
        credentialCache.Add(new Uri("http://www.contoso.com/"), "Basic", networkCredential);

        webRequest.Credentials = credentialCache;

        credentialCache.Remove(webRequest.RequestUri, "Basic");
0
On

Look at VaultCMD, built into Windows.