Morteza
Morteza

Reputation: 341

Team Foundation Server SDK 2012: Getting Credential Prompt

I am developing an application which needs to interact with a Team Foundation Server, basically retrieving some workitems. For doing so, I used the TeamFoundation Client assembly v11 which came along Visual Studio Team Explorer 2012. I want my application shows the network prompt so that the user can provide the credentials. I read this and this in which they proposed the following:

var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(uri, new UICredentialsProvider())
projectCollection.EnsureAuthenticated();

however, the mentioned "GetTeamProjectCollection" method is deprecated in TFS SDK 2012. I wonder how I can show the credential prompt in TFS SDK 2012?

Thank you.

Upvotes: 1

Views: 1267

Answers (1)

If you want the user to select the credentials then you would be better using the built in UI tools for that:

using (TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.NoProject, false))
{
    DialogResult result = tpp.ShowDialog();
    if (result == DialogResult.OK)
    {
        return tpp.SelectedTeamProjectCollection;
    }
    return null;
}

If you want to do this manually you can use the ability to pass credentials, or indeed impersonate credentials within TFS and create your own UI for asking for credentials.

There are a couple of other options:

Upvotes: 2

Related Questions