共用方式為


TfsConfigurationServer 建構函式 (RegisteredConfigurationServer, IdentityDescriptor)

TfsConfigurationServer 初始化物件的新執行個體使用與本機電腦上扮演識別的登入資訊從 IIdentityManagementService

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

語法

'宣告
Public Sub New ( _
    application As RegisteredConfigurationServer, _
    identityToImpersonate As IdentityDescriptor _
)
public TfsConfigurationServer(
    RegisteredConfigurationServer application,
    IdentityDescriptor identityToImpersonate
)

參數

備註

您可以使用 RegisteredTfsConnections.GetConfigurationServers,您可以從註冊的設定伺服器。

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

// Get the servers registered on this computer
RegisteredConfigurationServer[] servers = RegisteredTfsConnections.GetConfigurationServers();

// Connect to the first one in the array without impersonation
TfsConfigurationServer baseUserConnection = new TfsConfigurationServer(servers[0]);

// 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(servers[0], 
   identity.Descriptor);

.NET Framework 安全性

請參閱

參考

TfsConfigurationServer 類別

TfsConfigurationServer 多載

Microsoft.TeamFoundation.Client 命名空間

其他資源

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

Acting on Behalf of Another User (Impersonation)