0

I have a sharepoint webpart running on sharepoint server 2010 site which serves as the team project portal since it is integrated with TFS 2010. The webpart successfully deploys to the site and I am able to see it.

Using the TfsConfigurationServer class I am able to connect to TFS and get a list of all the project collections. If I go 1 step further down I can get a list of all the team projects in each collection. My problem arises when I try to connect to the version control server for a collection. I want to connect to the version control server so I can get a list of the folders/files under that project collection.

    TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);
try
   {
     VersionControlServer versionControl = (VersionControlServer)teamProjectCollection.GetService(typeof(VersionControlServer));
     TeamProject tp = versionControl.GetTeamProject("MyTeamProject");
     RecursionType recursion = RecursionType.Full;
     ItemSet itemSet = tp.VersionControlServer.GetItems(tp.ToString(), recursion);
     Item[] items = itemSet.Items;
     foreach (Item item in items)
     {
        l = new Label();
        l.Text = item.ChangesetId.ToString();
        this.Controls.Add(l);
     }
   }
   catch (Exception ex)
   {
     ex.ToString();
   }

The above code fails on the first line after the Try block, the "versioncontrolserver" line. The error says "You are not allowed to change users when re-authenticating." Why is it trying to change users? The user account (mine) has access to both sharepoint and tfs. If I add a WindowsIdentity variable, and run in debug with a breakpoint, I can confirm the webpart runs under my user account. Since it fails on the versioncontrolserver line, it seems to be reauthenticating when it connects to the tfs system. If it's switching accounts, why would it? and what account is it trying to use?

Sir Crispalot
  • 4,792
  • 1
  • 39
  • 64
  • 1
    The convention is before calling the `VersionControlServer` line, you call `teamProjectCollection.EnsureAuthenticated()`. I doubt it will help, but you never know, there must be a reason people do it :) – DaveShaw Oct 25 '12 at 20:00
  • I have that line and it passes. The webpart is authenticated under the current account (mine). I need some way to pass that authenticated session to the version control server so it doesnt try reauthenticate with a different user account. – Justin Case Oct 25 '12 at 20:15
  • sounds like kerberos delegation using the WindowsIdentity.GetCurrent().Impersonate() method. – Betty Oct 26 '12 at 01:56

0 Answers0