0
votes
   var tfsCredentials = new TfsClientCredentials(new Microsoft.TeamFoundation.Client.WindowsCredential(), true);
                TfsTeamProjectCollection teamCollection = new TfsTeamProjectCollection(new Uri(DomainConstants.BASE_ADDRESS), tfsCredentials);
                return teamCollection;

I used this for authenticate to TFS from current windows loggedin user and get TfsTeamProjectCollection, It is worked fine when it run from visual studio (localhost), but when I deployed my project in Server it occurs an error

An error occurred while processing your request

on browser and error log

Message :TF30063: You are not authorized to access http://unicorntfs:8080/tfs/USP.
StackTrace : at Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequest() at Microsoft.TeamFoundation.Client.Channels.TfsHttpRequestChannel.Request(TfsMessage message, TimeSpan timeout) at Microsoft.TeamFoundation.Client.Channels.TfsHttpClientBase.Invoke(TfsClientOperation operation, Object[] parameters, TimeSpan timeout, Object[]& outputs)
at Microsoft.TeamFoundation.Server.Classification.ListProjects() at Microsoft.TeamFoundation.Proxy.CommonStructureService.ListProjects()
at UnicornRMS.TimeManagement.Services.TFSTimeManagementServiceImpl.GetAllProjectsByUser(TfsTeamProjectCollection projCollection) at UnicornRSM.WEB.Controllers.TimeManagement.TimeManagementController.Index(Int32 weekNo)

How can I authenticate to TFS from current windows loggedin user

Thanks

1
In localhost its worked fine for me, I got error only when deplyed in serverSankha Sumadhura

1 Answers

0
votes

If you are connecting to a TFS server on your domain then you can use NetworkCredential to authenticate:

var _credentials = new NetworkCredential(UserName, Password);

TfsTeamProjectCollection server = new TfsTeamProjectCollection(_tfsUri, _credentials);

server.EnsureAuthenticated();

Moreover, try to delete your IE cache and cookies on your deployed server, then try it again.


Update

This issue may related to double hop. Some similar questions for your reference: