VS remembers TFS credentials even after clearing c

2019-08-08 23:19发布

I wrote a small Winform program that connects to TFS. My problem is that i always succeed to connect to TFS, even when i write the wrong credentials, still, in debug mode i see that my actual credentials are used.

I saw a similar question here and did exactly as suggested, deleted my TFS credentials from Credential Manager, still no luck(Yes, i did exit and re-open VS). I also logged out ot TFS itself and removed the connection on visual studio. Also, i deleted the cache folder as suggested here.

my code looks something like that:

folderPath=@"$/TFS_PATH";

cred = new NetworkCredential(ConfigurationManager.AppSettings["user"], ConfigurationManager.AppSettings["pass"]);

tfs = new TeamFoundationServer("CollectionPath", cred);

tfs.EnsureAuthenticated();

MessageBox.Show("tfs.EnsureAuthenticated() succeeded");

Some explantions for the code:

cred is an instance of NetworkCredential

tfs is an instance of TeamFoundationServer

The username and password are in app.config. Somehow, it completely ignores it, and uses my real credentials.

Does anyone know what else can i do? My goal is to enable the TFS connection from any computer/server by the username and password that are stored in app.config ONLY, not depend on the credentials that are stored on the machine iteself already.

Thanks

2条回答
Luminary・发光体
2楼-- · 2019-08-08 23:37

The problem was that i wasn't properly disconnected from VS. Removing the connection wasn't enough. I needed to verify that i signed out: Open VS, click on "Connect to Team Foundation..." and then click "sign out" on the bottom left in the popup window. That's it.

查看更多
聊天终结者
3楼-- · 2019-08-08 23:39

There were two credentials that you had to remove. One under "Windows Credentials", and another under "Generic Credentials".

It automatically uses the crendentials of the windows user that is logged-in.

You should run Visual Studio using the crendetials which you want to use to connect to TFS. See https://social.msdn.microsoft.com/Forums/vstudio/en-US/a239a959-1c01-4592-a754-f6fc7d5a9b94/change-user-when-i-connect-to-team-foundation-server?forum=tfsgeneral for more details.

查看更多
登录 后发表回答