This documentation is archived and is not being maintained.
TfsConfigurationServer Constructor (RegisteredConfigurationServer, IdentityDescriptor)
Visual Studio 2013
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:
TfsConfigurationServer(
RegisteredConfigurationServer^ application,
IdentityDescriptor^ identityToImpersonate
)
Parameters
- application
- Type: Microsoft.TeamFoundation.Client::RegisteredConfigurationServer
The registered server that is running Team Foundation Server.
- identityToImpersonate
- 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], identity.Descriptor);
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Show: