# Friday, November 30, 2012

At work I can happily connect to my Azure-hosted Team Foundation Service. But I couldn't do it from home. It says it is looking up identity providers, but the live.com logon screen never shows up. I just see the dreaded TFS31003 error ("Either you have not entered the necessary credentials or your user account does not have permission to connect to Team Foundation Server ").

My home machines are Windows 8 and linked to my personal LiveIDs, not my work logon. Windows 8 likes to connect to lots of Skydrive and lots of other services, storing all those credentials. And Visual Studio picks those rather than allow me to add a new one. Deleting entries in the Windows credentials store didn't work.

How can I force Visual Studio to select the right logon?

In Visual Studio, View>Other Windows>Web Browser

In the browser, go to live.com, and log on.

On mine it automatically logged on with another of my logons, so I signed off, and then signed back in with the correct one.

Now when I tried to connect to the TFS service address, it works.

posted on Friday, November 30, 2012 6:07:20 PM (Romance Standard Time, UTC+01:00)  #    Comments [0]
# Thursday, January 05, 2012
 
//find the working folder for each TFS
var projectCollections = RegisteredTfsConnections.GetProjectCollections();
 
foreach (var registeredProjectCollection in projectCollections)
{
    Console.WriteLine("Project collection: {0} {1}", 
registeredProjectCollection.Name,
registeredProjectCollection.Uri.AbsoluteUri);     var projectCollection =         TfsTeamProjectCollectionFactory.GetTeamProjectCollection(registeredProjectCollection);     var versionControl = projectCollection.GetService<VersionControlServer>();     // get workspace     var workspace =         versionControl.QueryWorkspaces(null,                 System.Threading.Thread.CurrentPrincipal.Identity.Name,                 Environment.MachineName)                 .FirstOrDefault(x =>                      x.Folders.Length > 0 &&                     //if there is a Work Item Manager, we don't care                     x.Name != "WIM (" + Environment.MachineName + ")");     if(workspace == nullcontinue//no workspace for this server     //there's normally only one     WorkingFolder folder = workspace.Folders.First();     Console.WriteLine("Working folder {0}", folder.LocalItem); }

//old VS 2008 way //using (TeamFoundationServer tfsServer = new TeamFoundationServer(tfsServerName)) //{ //    // Get a reference to version control //    VersionControlServer versionControl = //        (VersionControlServer) tfsServer.GetService(typeof (VersionControlServer)); //    //.... //}
posted on Thursday, January 05, 2012 9:51:17 AM (Romance Standard Time, UTC+01:00)  #    Comments [0]
# Monday, September 20, 2010
Finding out all users on Team Foundation Server turns out to be pretty easy.
I found the answer at http://blogs.msdn.com/b/jmanning/archive/2006/05/02/588648.aspx

You need a reference to C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\Microsoft.TeamFoundation.dll plus the Microsoft.TeamFoundation.Client.dll and Microsoft.TeamFoundation.Common.dll

var server = new TeamFoundationServer(tfsUrl);
var groupSecurityService =
    (IGroupSecurityService)server.GetService(typeof(IGroupSecurityService));

var validUserSid =
    groupSecurityService.ReadIdentity(
        SearchFactor.AccountName,
        @"[Server]\Team Foundation Valid Users",
        QueryMembership.Expanded);

Identity[] identities =
    groupSecurityService.ReadIdentities(
        SearchFactor.Sid,
        validUserSid.Members,
        QueryMembership.None);

//exclude Administrators and system accounts
foreach (Identity id in identities.Where(x=>
    x.Type == IdentityType.WindowsUser &&
    x.Deleted == false &&
    !x.Description.StartsWith("Built-in account", StringComparison.OrdinalIgnoreCase) &&
    !string.IsNullOrEmpty(x.MailAddress) &&
    !x.AccountName.StartsWith("sys_", StringComparison.OrdinalIgnoreCase)))
{
        Debug.WriteLine(id.AccountName + " " + id.DisplayName);
}


posted on Monday, September 20, 2010 3:51:34 PM (Romance Daylight Time, UTC+02:00)  #    Comments [0]