I've been trying to access a TFS account (programatically using the TFS SDK) in order to get information such as the project names, work item names and developpment times for each work item.
I wasn't able to get project or work item information, but I was able to authenticate and access TFS using the class TfsTeamProjectCollection.
However, using the class TfsConfigurationServer, I was never able to authenticate to the server. This is a pity because the majority of examples I've seen in the web use this TfsConfigurationServer class.
The code that allows me to access TFS:
// Connect to Team Foundation Server.
NetworkCredential netCred = new NetworkCredential("myEmail@email.com", "myPassword");
BasicAuthCredential basicCred = new BasicAuthCredential(netCred);
TfsClientCredentials tfsCred = new TfsClientCredentials(basicCred);
tfsCred.AllowInteractive = false;
TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("https://tfs.gfi.pt:4430/tfs/gfi/"),tfsCred);
tpc.Authenticate(); // This one works, and when I enter tpc I can see I am correctly signed-in in TFS (I can for instance check my full name)
ITeamProjectCollectionService projCollect = tpc.GetService<ITeamProjectCollectionService>(); //returns null :(
I have 2 questions:
Regarding question #1, you can find some whys in Introducing the TfsConnection, TfsConfigurationServer and TfsTeamProjectCollection Classes. Shortly, you can have many user databases, i.e. Collection, managed by a single TFS instance, i.e. the Server.