# Monday, September 25, 2006

Say you built an application that connects to TFS and you want a dialog box to appear if a user is not authorized to connect to TFS. To do this is quite simple.  There are two methods you might have seen when you are playing with the TeamFoundationServer object, Authenticate() and EnsureAuthenticated(). The difference between the two is Authenticate will always call the server and EnsureAuthenticated will only be called if the user has not already authenticated to the server. You should use the EnsureAuthenticated method as a performance point since you only want the call to go to the server if the user has not authenticated. Notice we are using the TeamFoundationServer constructor instead of the Factory; you can use the factory if you wish. The deciding point that you need to decide is if you want to reference the same object on subsequence calls and without the need to re-authenticate. Remember the factory method will return a cache instance of the object.

 

TeamFoundationServer tfs = new TeamFoundationServer(TFSServerName,new UICredentialsProvider());

tfs.EnsureAuthenticated();

 

If the user presses cancel on the dialog box then a UnauthorizedException will be thrown ,so handle it gracefully.

 

Ed K.

posted on Monday, September 25, 2006 9:47:25 PM (Central Standard Time, UTC-06:00)  #    Comments [0] Trackback
Related posts:
Enter the Coolest Team System Gadget Contest!
New Visual Studio Extensibility Book Available
New Position
Third-Party .NET Component Suite Comparison
IEventService: Filter Expressions, Event Types
Connect to TFS via Client Object Model
Tracked by:
"Music" (Music) [Trackback]
"May Camp 2006" (May Camp 2006) [Trackback]
"Calftryin.net" (Calftryin.net) [Trackback]
"Philip Morris agrees to buy Nabisco for $14.9 billion" (Philip Morris agrees to... [Trackback]
"1428_ministry - Calftryin.net" (1428_ministry - Calftryin.net) [Trackback]
"Toronto Wireless Community Network (TWCN)" (Toronto Wireless Community Network ... [Trackback]
"2002_06_24 - Departurebanish.com" (2002_06_24 - Departurebanish.com) [Trackback]
"Giochi di Luce" (Giochi di Luce) [Trackback]
"Events" (Events) [Trackback]
"Events" (Events) [Trackback]
"Mute_8977 - Calftryin.net" (Mute_8977 - Calftryin.net) [Trackback]
"Mannequin Madness" (Mannequin Madness) [Trackback]
"Gralty Automotive" (Gralty Automotive) [Trackback]
"main.htm" (main.htm) [Trackback]
"main.htm" (main.htm) [Trackback]
"ALL ABOUT CANADA" (ALL ABOUT CANADA) [Trackback]
"COMMISSIONERS’ CORNER" (COMMISSIONERS’ CORNER) [Trackback]
"3337_backlash - Departurebanish.com" (3337_backlash - Departurebanish.com) [Trackback]
"Humanist - Calftryin.net" (Humanist - Calftryin.net) [Trackback]
"May Camp 2006" (May Camp 2006) [Trackback]
"Aluminum 2000" (Aluminum 2000) [Trackback]
"Verreau_9420 - Calftryin.net" (Verreau_9420 - Calftryin.net) [Trackback]
"939_awards - Calftryin.net" (939_awards - Calftryin.net) [Trackback]
"NATURE HIKE" (NATURE HIKE) [Trackback]
"2004_02_11 - Calftryin.net" (2004_02_11 - Calftryin.net) [Trackback]
"3611_sixth - Calftryin.net" (3611_sixth - Calftryin.net) [Trackback]
"TIFFANY BOUDREAU PAX LODGE 2004" (TIFFANY BOUDREAU PAX LODGE 2004) [Trackback]
"8266_opposition - Calftryin.net" (8266_opposition - Calftryin.net) [Trackback]
"May Camp 2006" (May Camp 2006) [Trackback]
"Voluntary_2161 - Calftryin.net" (Voluntary_2161 - Calftryin.net) [Trackback]
"4029 - Calftryin.net" (4029 - Calftryin.net) [Trackback]
"IDEC" (IDEC) [Trackback]
"Murat - Calftryin.net" (Murat - Calftryin.net) [Trackback]
"6070 - Calftryin.net" (6070 - Calftryin.net) [Trackback]
"COMMISSIONERS’ CORNER" (COMMISSIONERS’ CORNER) [Trackback]
"main.htm" (main.htm) [Trackback]
"Thinking Day 2006" (Thinking Day 2006) [Trackback]
"SERVICE PROJECTS" (SERVICE PROJECTS) [Trackback]
"PREPARING FOR INSPECTION" (PREPARING FOR INSPECTION) [Trackback]
"The Camping Page" (The Camping Page) [Trackback]
"Training" (Training) [Trackback]
"Districts" (Districts) [Trackback]
"Reel Views - Angie" (Reel Views - Angie) [Trackback]
Comments are closed.