"Run as different user" Visual Studio, cannot clear cached TFS credentials
Asked Answered
M

5

12

Update I managed to solve it by getting my user granted permissions to remotely connect to the desktop using credential set 2 and thus being able to remove the stored credentials from Credential Manager.


I log onto my server with one set of credentials and open Visual Studio 2012 using "Run as different user" (Shift + Right-click) as I need a second set of credentials to deploy to my dev. env. SharePoint site.

I have previously done above and then connected to TFS using a third set of credentials, as the my user (second set credentials) didn't have access yet. Now my user have access and I wish to use these credentials instead.
TFS automatically logs me in with the third set credentials every time I open VS using "Run as different user" - However, if I open VS normally without using "Run as different user" I get prompted for login to the TFS.

I have tried checking the Windows credentials and there is nothing there. And I can't log onto the server using the second set credentials as only the first set can access the server with Remote Desktop.

So how do I "clear" cached TFS credentials when using "Run as different user"?

Mawkish answered 12/12, 2013 at 8:28 Comment(0)
M
18

Go to control panel > User Accounts > Manage Your Credentials > select your Team foundation Server and choose remove/edit - viola! Next time you go into Team Explorer you will be prompted for a new set of credentials.

Ref: http://blogs.msdn.com/b/visualstudioalm/archive/2012/08/29/clearing-the-credentials-for-connecting-to-a-team-foundation-server.aspx

Macomber answered 12/12, 2013 at 10:51 Comment(6)
Tried that, but my Credential Manager is empty.Mawkish
Whose credentials manager is empty? Yours, or the user you're actually running VS as?Michale
@EdwardThomson Mine. I can't log onto the server using remote desktop with the user I'm running VS as.Mawkish
@DanielZiga Perhaps your administrator can assist then. The credentials are stored in the credential manager for the user you ran VS as. (They couldn't be in your credential manager, then Visual Studio couldn't access them when running as the other user.)Michale
@EdwardThomson Thank you. They gave my user RDP permissions to the server and I managed to remove the credentials.Mawkish
For me, it doesn't show any thing in credential , i did it several time before, but this time any thing i did didn't worked out, i also add server URL, to fake it with wrong password, but it didn't worked out, it just keep on logging in :'(Caduceus
W
4

You can try clearing the cache manually here:
C:\Users[USERNAME]\AppData\Local\Microsoft\Team Foundation\5.0\Cache

You could also try using the /profile parameter and specifying the username's profile when you run it.

Runas /profile /user:[DOMAIN]\[administrator] "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe"

http://technet.microsoft.com/en-us/library/bb490994.aspx

Wescott answered 12/12, 2013 at 12:59 Comment(5)
Tried it, no difference :/Mawkish
Did you clear the cache under the otheruser\appdata as well or just under yours?Wescott
I did it for every single user under c:\UsersMawkish
We don't put usernames/passwords in the cache, we put them into the credential vault. Clearing the cache would have no effect.Michale
I am having this same issue. I have cleared all credentials from the Credential Vault. I have cleared the Team Foundation\5.0\cache completely. I have cleared IE passwords. What else?Comb
D
3

For me it was not username/PASSWORD, but the cached username that was the issue. And that IS stored in VersionControl.config in the cache. Whacking just that file was enough to get TFS to stop trying to connect with the old email.

Driest answered 26/4, 2015 at 16:57 Comment(1)
I found the file you are referring to under "C:\Users\{UserName}\AppData\Local\Microsoft\Team Foundation\{Ver}\Cache\Volatile\{SomeGUID}_http\VersionControl.config". I just renamed it to VersionControl.config.old, and everything worked great.Mississippian
T
0

I ran into this issue as well, but clearing out the AppData settings didn't help.

I had created a console application to connect to TFS and it prompted me for credentials the first time I ran it. After that, the credentials were stored and would supersede any other credentials I provided. I finally figured out that VS had added a registry entry in:

HKEY_CURRENT_USER\Software\Microsoft\VSCommon\14.0\ClientServices\TokenStorage\VisualStudio\VssApp

Deleting the key worked, but I also discovered that one can accomplish the same programmatically:

var clientCredentails = new VssClientCredentialStorage();

// URI of the target TFS server
var tfsUri = new Uri("https://[username].visualstudio.com/DefaultCollection/");

// Find the cached credentials
var federatedCredentials = clientCredentails.RetrieveToken(tfsUri, VssCredentialsType.Federated);

// Remove the credentials from the cache
clientCredentails.RemoveToken(tfsUri, federatedCredentials);
Typescript answered 30/9, 2016 at 17:48 Comment(0)
R
0

I had a similar problem where I needed to log into a local TFS as another account than my Windows account (found in Active Directory which TFS is connected to) - but I could not see any credentials in the manager.

The solution was to disconnect inside VS (Menu Team->Disconnect). Then create a Windows account in the Credentials Manager with the same user as my Windows user - but with a password that is incorrect. The URL/server was just "tfs" (no port etc).

When I start VS it fails the login to TFS and asks for correct password and username too. Then I can change this to another user and VS default to this the next time.

Rags answered 19/7, 2017 at 13:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.