Share via


Connecting to a Team Foundation Server

To connect to a Team Foundation server, you must construct a TeamFoundationServer object. Use the TeamFoundationServerFactory class to create an instance of a TeamFoundationServer object. When the factory creates a TeamFoundationServer object, it caches an instance of the object. This ensures that subsequent calls to the factory return the same instance. All Team Foundation services share the same TeamFoundationServer object. Using the same object prevents multiple prompts for credentials.

Connecting to the Object

The following example code shows you how to connect to the object. The TeamFoundationServerFactory method signatures match those of the TeamFoundationServer constructors. By default, if you provide only the server's name, the caller's Windows credentials are used. As shown in the example code, you can also specify non-default credentials. For more information about non-default credentials, see Authenticating Team Foundation Server Users.

public static class TeamFoundationServerFactory
 {
  public static TeamFoundationServer GetServer(string name)
  public static TeamFoundationServer GetServer(string name, ICredentials credentials)
  public static TeamFoundationServer GetServer(string name, ICredentialsProvider credentialsProvider)
 }

The name of the Team Foundation server can be specified as either a URI or a friendly name.

See Also

Concepts

Essentials

Connecting to a Team Foundation Server

Authenticating Team Foundation Server Users

Working with Team Foundation Server Properties

Working with Team Foundation Server Services