TfsConfigurationServer Constructor (RegisteredConfigurationServer, IdentityDescriptor)

Initializes a new instance of the TfsConfigurationServer object by using the registration information on the local computer, and impersonating an identity from IIdentityManagementService.

Namespace:  Microsoft.TeamFoundation.Client
Assembly:  Microsoft.TeamFoundation.Client (in Microsoft.TeamFoundation.Client.dll)

Public Sub New ( _
	application As RegisteredConfigurationServer, _
	identityToImpersonate As IdentityDescriptor _


Type: Microsoft.TeamFoundation.Client.RegisteredConfigurationServer

The registered server that is running Team Foundation Server.

Type: Microsoft.TeamFoundation.Framework.Client.IdentityDescriptor

The identity to impersonate.

You can get the registered configuration servers by using RegisteredTfsConnections.GetConfigurationServers.

To run code that uses this constructor, the process must have the "Make requests on behalf of others" permission. For more information about impersonation, see Connect to Team Foundation Server from a Console Application.

// 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],