共用方式為


TfsConfigurationServer 建構函式 (Uri, IdentityDescriptor)

TfsConfigurationServer 初始化物件的新執行個體。

命名空間:  Microsoft.TeamFoundation.Client
組件:  Microsoft.TeamFoundation.Client (在 Microsoft.TeamFoundation.Client.dll 中)

語法

'宣告
Public Sub New ( _
    uri As Uri, _
    identityToImpersonate As IdentityDescriptor _
)
public TfsConfigurationServer(
    Uri uri,
    IdentityDescriptor identityToImpersonate
)

參數

  • uri
    型別:System.Uri
    伺服器通用資源識別項執行 Team Foundation Server(URI) 的。

例外狀況

例外狀況 條件
ArgumentNullException

當 uri 是空的

備註

若要使用這個建構函式的程式碼,這個處理序必須具有「代表其他人提出要求」權限。 如需模擬的詳細資訊,請參閱 Acting on Behalf of Another User (Impersonation)

// Connect to Team Foundation Server
//     server is the name of the server that is running the Team Foundation application-tier. 
//     port is the port that Team Foundation uses. The default port is 8080. 
//     vdir is the virtual path to the Team Foundation application. The default path is tfs. 
Uri tfsUri = (args.Length < 1) ? 
new Uri("http://server:port/vdir") : new Uri(args[0]); 

// Connect to the server without impersonation
TfsConfigurationServer baseUserConnection = new TfsConfigurationServer(tfsUri);

// Get the identity management service
IIdentityManagementService ims = baseUserConnection.GetService<IIdentityManagementService>();

// Get the identity to impersonate
TeamFoundationIdentity identity = ims.ReadIdentity(IdentitySearchFactor.AccountName, @"DOMAIN\user",
   MembershipQuery.None, ReadIdentityOptions.None); 

// Connect using the impersonated identity
TfsConfigurationServer impersonatedConnection = new TfsConfigurationServer(tfsuri, 
   identity.Descriptor);

.NET Framework 安全性

請參閱

參考

TfsConfigurationServer 類別

TfsConfigurationServer 多載

Microsoft.TeamFoundation.Client 命名空間

其他資源

從主控台應用程式連接到 Team Foundation Server

Acting on Behalf of Another User (Impersonation)