【问题标题】:How to get TFS user groups and users in particular group using TFS API?如何使用 TFS API 获取 TFS 用户组和特定组中的用户?
【发布时间】:2012-06-19 04:25:57
【问题描述】:

我想在 DropDown 中列出 TFS 用户组,并且根据用户组的选择,我需要使用 TFS API 填充该特定组中的用户。

【问题讨论】:

    标签: tfs


    【解决方案1】:

    这个页面有几个例子:http://blogs.microsoft.co.il/blogs/shair/archive/2009/01/14/tfs-api-part-4-get-tfs-user-list-mail-sid-account-domain.aspx

    最后一个例子可能是最相关的。

    IGroupSecurityService gss = (IGroupSecurityService)server.GetService(typeof(IGroupSecurityService));
    Identity[] UserId = gss.ReadIdentities(SearchFactor.Sid, SIDS.Members, QueryMembership.None);
    

    【讨论】:

      【解决方案2】:
      // Connect to the team project collection.
      TfsConfigurationServer tfsServer = m_tfsServer;
      Guid collectionGuid = m_collectionGuid;
      TfsTeamProjectCollection tpc = tfsServer.GetTeamProjectCollection(collectionGuid);
      
      // Get the group security service.
      var gss = tpc.GetService<IGroupSecurityService2>();
      
      // Retrieve each user's SID.
      Identity sids = gss.ReadIdentity(SearchFactor.AccountName, "[My Team Project]\\Contributors", QueryMembership.Expanded);
      
      // Resolve to named identities.
      Identity[] users = gss.ReadIdentities(SearchFactor.Sid, sids.Members, QueryMembership.None);
      

      【讨论】:

        猜你喜欢
        • 2016-07-09
        • 2021-11-27
        • 2021-05-21
        • 1970-01-01
        • 1970-01-01
        • 2013-01-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多