title: Finding user in TFS Project programmatically
body: <p>We have more than one collection under one TFS server and each collection have more than one project. I want to be able to check if entered username is part of any project level group on TFS server.
  So far I am able to connect to TFS, and get all project names under the collection. I need help in finding the group name and then querying those groups to check if user is part of that group or not.</p>
  
  <p>Here is the code I tried - </p>
  
  <pre><code>static void Main(string[] args)
      {
          NetworkCredential netCred = new NetworkCredential(@"username", @"pwd");
          TfsConfigurationServer configServ = new TfsConfigurationServer(new Uri("https://my-tfs.schwab.com/tfs"), netCred);
  
          var tfsAllCols = new List&lt;KeyValuePair&lt;Guid, string&gt;&gt;();
          try
          {
              configServ.Authenticate();
              Console.WriteLine("Autheticated in server with ad creds...");
  
              ReadOnlyCollection&lt;CatalogNode&gt; colNodes = configServ.CatalogNode.QueryChildren(
                  new[] { CatalogResourceTypes.ProjectCollection },
                  false,
                  CatalogQueryOptions.None);
              foreach (CatalogNode node in colNodes)
              {
                  var colId = new Guid(node.Resource.Properties["InstanceId"]);
                  TfsTeamProjectCollection teamProjectCollection =
                      configServ.GetTeamProjectCollection(colId);
  
                  tfsAllCols.Add(new KeyValuePair&lt;Guid, string&gt;(colId, teamProjectCollection.Name));
  
              }
  
      //hardcoding the colname for testing
              TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("https://ruby-tfs.schwab.com/tfs/colname/"), netCred);
  
              tpc.EnsureAuthenticated();
  
              // Get the catalog of team project collections
              ReadOnlyCollection&lt;CatalogNode&gt; projNodes = tpc.CatalogNode.QueryChildren(
              new[] { CatalogResourceTypes.TeamProject },
              false, CatalogQueryOptions.None);
  
          }
          catch (Exception ex)
          {
  
              throw ex;
          }
  
          Console.ReadLine();
      }
  </code></pre>