Quantcast
Channel: Team Foundation Server - General forum
Viewing all articles
Browse latest Browse all 6687

What will be the correct way to connect to TFS server in Server plugins coding.

$
0
0

 public TFSAccess(string tfsUri, string username = null, string password = null)
        {
            TfsTeamProjectCollection tfs;

            if (username != null && username != string.Empty)
            {
                FederatedCredential credential = new SimpleWebTokenCredential(username, password);
                TfsClientCredentials clientCredentials = new TfsClientCredentials(credential);
                tfs = new TfsTeamProjectCollection(new Uri(tfsUri), clientCredentials);
            }
            else
            {
                tfs = new TfsTeamProjectCollection(new Uri(tfsUri));
            }

            store = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
     }

I am using the above code. Both loops works fine. I just wanted to ensure that this will work fine in production server. Do I need to add ensureAuthenticated(). Please comment on it.


Viewing all articles
Browse latest Browse all 6687