开发者

TFS SDK - Getting the network credential prompt

I am trying to get the network prompt so that user can provide the credentials. I saw this and I开发者_Python百科t does not help. Could somebody provide a more complete example? The goal is is to get this from a Word Add-in so that I can create work items in TFS from the function points mentioned in the word document. So, somebody writes the function points in a document, closes it and It would ask for the network credentials so that It can create work items in the TFS.


You want to use the UICredentialsProvider when connecting. Here's an example that shows how you would connect to a TFS 2010 Project Collection:

// Connect to a project collection by Uri
try
{
    var projectCollectionUri = new Uri("http://tfs2010:8080/tfs/MyCollection");
    var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(projectCollectionUri, new UICredentialsProvider())
    projectCollection.EnsureAuthenticated();
}
catch (TeamFoundationServerUnauthorizedException ex)
{
    // handle access denied
}
catch (TeamFoundationServiceUnavailableException ex)
{
    // handle service unavailable
}
catch (WebException ex)
{
    // handle other web exception
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜