TfsConfigurationServer Constructor (Uri, IdentityDescriptor)
Initializes a new instance of the TfsConfigurationServer object.
Namespace: Microsoft.TeamFoundation.Client
Assembly: Microsoft.TeamFoundation.Client (in Microsoft.TeamFoundation.Client.dll)
Syntax
声明
Public Sub New ( _
uri As Uri, _
identityToImpersonate As IdentityDescriptor _
)
public TfsConfigurationServer(
Uri uri,
IdentityDescriptor identityToImpersonate
)
public:
TfsConfigurationServer(
Uri^ uri,
IdentityDescriptor^ identityToImpersonate
)
new :
uri:Uri *
identityToImpersonate:IdentityDescriptor -> TfsConfigurationServer
public function TfsConfigurationServer(
uri : Uri,
identityToImpersonate : IdentityDescriptor
)
Parameters
- uri
Type: System.Uri
The universal resource identifier (URI) of the server that is running Team Foundation Server.
- identityToImpersonate
Type: Microsoft.TeamFoundation.Framework.Client.IdentityDescriptor
The identity to impersonate.
Remarks
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).
// 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 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