2016-09-20 68 views

回答

1

目前無法通過Rest API實現此功能。如果你真的想以編程方式做。您可以使用客戶端API。

您可以嘗試使用IIdentityManagementService.ReadIdentity()IIdentityManagementService.AddMemberToApplicationGroup()將Windows用戶添加到TFS組,即使這些Windows用戶還不知道TFS。

這是通過指定ReadIdentityOptions.IncludeReadFromSource選項來完成的。

下面是添加一個Windows用戶VSALM\BarryFabrikam Fiber Web Team(TFS集團),在FabrikamFiber團隊項目,在http://vsalm:8080/tfs/FabrikamFiberCollection(也適用於服務器級別)

using Microsoft.TeamFoundation.Client; 
using Microsoft.TeamFoundation.Framework.Client; 
using Microsoft.TeamFoundation.Framework.Common; 
using System; 

namespace ConsoleApplication1 
{ 
    class Program 
     { 
     static void Main(string[] args) 
     { 
      var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://vsalm:8080/tfs/FabrikamFiberCollection")); 

      var ims = tpc.GetService<IIdentityManagementService>(); 

      var tfsGroupIdentity = ims.ReadIdentity(IdentitySearchFactor.AccountName, 
                "[FabrikamFiber]\\Fabrikam Fiber Web Team", 
                MembershipQuery.None, 
                ReadIdentityOptions.IncludeReadFromSource);    

      var userIdentity = ims.ReadIdentity(IdentitySearchFactor.AccountName, 
                "VSALM\\Barry", 
                MembershipQuery.None, 
                ReadIdentityOptions.IncludeReadFromSource); 

      ims.AddMemberToApplicationGroup(tfsGroupIdentity.Descriptor, userIdentity.Descriptor); 
     } 
    } 
} 
的例子
相關問題