authentication failed while connecting to tfs using tfs api

后端 未结 3 1083
遇见更好的自我
遇见更好的自我 2021-01-23 22:28

I am facing a strange issue.I want to connect tfs server using tfs api programmitcally. Even after giving proper authentcaion crediatials it is failing.But if I do it manually b

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-23 22:57

    A simple way to do this is to add the "Syetem.Net" namespace to your code and then use the "CredentialCache" object. Using "DefaultCredentials" will Authenticate with the credentials of the active user.

    // connect to the collection
    using (TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection("http://server:8080/tfs/DefaultCollection", CredentialCache.DefaultCredentials))
                { 
                    //Do Stuff here 
                }
    

提交回复
热议问题