简体   繁体   中英

How to use different accounts to connect to TFS in VS 2015 and VS 2017?

I have connected to TFS in VS 2015 with a credential say 'username2015' and it works fine. Now when I configure the same TFS in VS 2017, it uses the existing credential 'username2015'. But my problem is I want to use a different credential say 'username2017' when connecting to TFS in VS 2017.

In other words, I am looking for a way to use different accounts to connect to TFS in VS 2015 and VS 2017.

If you Shift + right click on Visual Studio exe it gives option to "Run As Different User". Once you select it then you can give credentials of other user which you want to use. See screenshot below.

在此处输入图片说明

I've already used a TFS username "username2015" when connecting to my client's TFS in Team -> Manage Connections in VS 2015. Now in VS 2017, I want to use another username 'username2017' to connect to same TFS.

Firstly make sure the username2017 is added in TFS, see Quickstart: Add users to a team project or specific team

If it's the FIRST TIME connecting to same TFS with VS 2017 under current windows user account, then you can use username2017 directly in VS 2017 ( Team Explorer -> Manage Connections ), it will popup the login dialog box for you to sign-in, nothing different with VS 2015.

But if you have ever connected to the TFS with other tfs accounts in VS 2017, then it will automatically use your previous logged-on tfs user account from Windows Sign-on services and check if you are able to login to selected TFS Server. That means it will automatically connect to TFS with the pervious tfs account if the account is still available. If the password changed, then it will popup the dialog to let you enter the new password to sing-in again.

So, in your scenario if you have ever connected to the TFS with VS2017 under current user account (windows account to run VS ), then you can try to below ways to run VS2017 as another user :

  • Run as different user as Pankaj mentioned above.
  • Command to run Visual Studio as another user:

    cd C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE

    runas /netonly /user:<account> devenv.exe

    Enter the user password, then Team Explorer > Manage Connections

  • Logoff windows user, then logon with another windows user, open VS -> Connect to TFS with another tfs user.

If you insist on using different tfs accounts to connect the same TFS server in VS under the same windows account, then you can try to remove the tfs related credentials from Credential Manager , clean VS and TFS caches etc... But based on my test, it's difficult to take effect.

You can reference my answers in other threads:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM