I am trying to access https://visualstudio.com (formerly known as https://tfs.visualstudio.com, http://www.tfspreview.com) from my Windows Service written on .NET.
I want to use the new basic authentication but I couldn't find a way to do it.
I found a lot of links to the blog post Team Foundation Service updates - Aug 27 but it is using the Team Explorer Everywhere Java client for TFS.
Is there a new version of the TFS .NET Object Model to support the basic authentication?
By the way I've successively logged in with the service account. This answer was very useful.
From the list of connectors, we select the “Visual Studio Team Services” item shown in the list below by clicking the “Add” button. Microsoft Teams will ask you to select the Team Services account you would like to use, team project and event type to receive notifications for.
To use this enhanced workflow, you'll need to opt into using your system's default web browser as the mechanism to add and reauthenticate Visual Studio accounts. Not using this workflow could trigger a degraded experience resulting in multiple additional authentication prompts when adding or reauthenticating Visual Studio accounts.
Versions of Visual Studio prior to 16.6 may have degraded authentication experiences when used with accounts that have enabled CA policies such as MFA, and are associated with two or more tenants. These issues can cause your instance of Visual Studio to prompt reauthentication multiple times per day.
When you enable Windows authentication, your web server becomes responsible for authenticating users. Typically, there are two different types of web servers that you use when creating and deploying an ASP.NET MVC application. First, while developing an MVC application, you use the ASP.NET Development Web Server included with Visual Studio.
First of all, you need to have at least Visual Studio 2012 Update 1 installed on your machine. It includes an updated Microsoft.TeamFoundation.Client.dll
assembly with the BasicAuthCredential
class.
Here's the code to do it, from Buck's blog post How to connect to Team Foundation Service.
using System;
using System.Net;
using Microsoft.TeamFoundation.Client;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
NetworkCredential netCred = new NetworkCredential(
"[email protected]",
"yourbasicauthpassword");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(
new Uri("https://YourAccountName.visualstudio.com/DefaultCollection"),
tfsCred);
tpc.Authenticate();
Console.WriteLine(tpc.InstanceId);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With