title: Interaction with TFS 2015 (On-Premise)
body: <p>I am creating an export file with all TFS projects, users and their associated TFS Groups for a specific TFS Collection. (using ITeamProjectCollectionService, IIdentityManagementService)</p>
  
  <p>I noticed I receive also the disabled AD-users.  How can I filter the disabled AD-users out of this list? I have no direct access to the AD-environment.
  The Microsoft.TeamFoundation.Server.Identity does not contain this property.</p>
  
  <pre><code>        Uri configurationServerUri = new Uri(environmentConfig.Uri);
          TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(configurationServerUri);
          var tpcService = configurationServer.GetService&lt;ITeamProjectCollectionService&gt;();
          foreach (TeamProjectCollection tpc in tpcService.GetCollections())
          {
              var tfsProjectCollection = new TfsTeamProjectCollection(new Uri(environmentConfig.Uri + "/" + tpc.Name), environmentCredential);
  
              var vcs = tfsProjectCollection.GetService&lt;VersionControlServer&gt;();
              var sec = tfsProjectCollection.GetService&lt;IGroupSecurityService&gt;();
  
              var teamProjects = vcs.GetAllTeamProjects(false);
              foreach (var teamProject in teamProjects)
              {
                  var appGroups = sec.ListApplicationGroups(teamProject.ArtifactUri.AbsoluteUri);
  
                  foreach (var group in appGroups)
                  {
                      Identity[] groupMembers = sec.ReadIdentities(SearchFactor.Sid, new string[] { group.Sid }, QueryMembership.Expanded);
                      foreach (Identity member in groupMembers)
                      {
                          if (member.Members != null)
                          {
                              foreach (string memberSid in member.Members)
                              {
                                  Identity memberInfo = sec.ReadIdentity(SearchFactor.Sid, memberSid, QueryMembership.Expanded);
                                  if (memberInfo.Type != IdentityType.WindowsUser)
                                      continue;
  
                                  result.Add(new TfsPermission { Collection = tfsProjectCollection.Name, TeamProject = teamProject.Name,
                                      User = memberInfo.AccountName, Domain = memberInfo.Domain, Group = group.DisplayName });
                              }
                          }
                      }
                  }
              }
          }
  </code></pre>
  
  <p>Best regards,
  Jens</p>