Programatically send TFS credentials through Azure connect

inewspunctro

New Member
My webapplication hosted on windows azure needs to communicate with TFS Serverwhen I login to my web app using live id,I want the logged in user to use my Team foundation server(TFS) credentials -username,password and domainto programatically authenticate and connect to our TFS server and create some work items.I configured my azure connect for the communication to happen between azure based Webapp and TFS server I need some code snippets that will help me authenticate to my TFS server and create some workitems on the TFS serverI use the following code to do this,but this never worked .Any suggestionsOr is there any other way I can send my user credentials with out hardcoding to my code ?Any better suggestions ?\[code\] public TfsTeamProjectCollection AuthenticateTFSAndGetWorkItemStore(out WorkItemStore workItemStore) { try { TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(this.TFSUri)); LoggingManager.Log("Start Authentication with TFS: {0}", LogLevel.DEBUG, DateTime.Now); // tpc.Authenticate(); ////---nEW START Uri URI = new Uri(this.TFSUri); ConnectByImplementingCredentialsProvider connect = new ConnectByImplementingCredentialsProvider(); ICredentials iCred = new NetworkCredential("myUserName", "myPassword", "xyz.mydomain.com"); connect.GetCredentials(new Uri(this.TFSUri), iCred); TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(new Uri(this.TFSUri), connect); configurationServer.EnsureAuthenticated(); LoggingManager.Log("End Authentication with TFS: {0}", LogLevel.DEBUG, DateTime.Now); LoggingManager.Log("Start Getting Workitem store: {0}", LogLevel.DEBUG, DateTime.Now); // workItemStore = tpc.GetService<WorkItemStore>(); workItemStore = configurationServer.GetService<WorkItemStore>(); //nEW LoggingManager.Log("End Getting Workitem store: {0}", LogLevel.DEBUG, DateTime.Now); tpc = workItemStore.TeamProjectCollection; return tpc; }using System.Net;using System;using Microsoft.TeamFoundation.Client;namespace Businesslayer{ public class ConnectByImplementingCredentialsProvider : ICredentialsProvider { public ICredentials GetCredentials(Uri uri, ICredentials iCredentials) { return new NetworkCredential("UserName","Password","Domain"); //??? is this correct ? should I pass actual username, password and domain name here } public void NotifyCredentialsAuthenticated(Uri uri) { throw new ApplicationException("Unable to authenticate"); } }}\[/code\]
 
Back
Top