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)
Syntax
'Declaração
Public Sub New ( _
application As RegisteredConfigurationServer, _
identityToImpersonate As IdentityDescriptor _
)
public TfsConfigurationServer(
RegisteredConfigurationServer application,
IdentityDescriptor identityToImpersonate
)
public:
TfsConfigurationServer(
RegisteredConfigurationServer^ application,
IdentityDescriptor^ identityToImpersonate
)
new :
application:RegisteredConfigurationServer *
identityToImpersonate:IdentityDescriptor -> TfsConfigurationServer
public function TfsConfigurationServer(
application : RegisteredConfigurationServer,
identityToImpersonate : IdentityDescriptor
)
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.
Remarks
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 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 Security
- 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.
See Also
Reference
TfsConfigurationServer Overload
Microsoft.TeamFoundation.Client Namespace
Other Resources
Connect to Team Foundation Server from a Console Application