【问题标题】:TFS 2010 - Why am I getting "TF30063 You are not authorized to access.." error when impersonating?TFS 2010 - 为什么我在模拟时收到“TF30063 You are not authorized to access..”错误?
【发布时间】:2012-01-11 16:17:54
【问题描述】:

我试图通过模拟用户在 TFS2010 中创建一个错误,但总是得到

"TF30063 You are not authorized to access.."

我首先使用服务帐户进行身份验证,然后尝试模拟一个单独的用户帐户。我可以使用任一帐户以编程方式和在 Web UI 中成功创建工作项。但是,当我尝试使用模拟帐户(无论哪种方式)创建工作项时,我总是会收到此错误。我的代码是:

public int Save(List<KeyValuePair<string, string>> values, ticketType type,string user)
    {
        // get the Uri to the project collection to use
        Uri  tfsuri = new Uri("http://94.23.12.119:8085/tfs");            

        // get a reference to the team project collection (authenticate as generic service account)
        using (var tfs = new TfsTeamProjectCollection(tfsuri, new System.Net.NetworkCredential("username", "password", "servername")))
        {
            tfs.EnsureAuthenticated();

            //Now get the details of the user we want to impersonate
            TeamFoundationIdentity identity = GetImpersonatedIdentity(tfsuri,tfs,user);

            //Now connect as the impersonated user
            using (TfsTeamProjectCollection ImpersonatedTFS = new TfsTeamProjectCollection(tfsuri, identity.Descriptor))
            {
                ImpersonatedTFS.EnsureAuthenticated();
                var workItemStore = GetWorkItemStore(ImpersonatedTFS);

                // create a new work item
                WorkItem wi = new WorkItem(GetWorkItemType(type, workItemStore));
                {
                    //Values are supplied as a KVP - Field Name/Value
                    foreach (KeyValuePair<string,string> kvp in values)
                    {
                        if (wi.Fields.Contains(kvp.Key))
                        {
                            wi.Fields[kvp.Key].Value = kvp.Value;
                        }
                    }

                    ValidationResult = wi.Validate();                       
                }

                if (ValidationResult.Count == 0)
                {

                    wi.Save();
                    return wi.Id;
                }
                else
                { 
                    return 0;
                }
            }
        }

    }

成功获取了冒充身份,但失败了

ImpersonatedTFS.EnsureAuthenticated();

两个帐户都具有“代表他人提出请求”权限集。

【问题讨论】:

  • 你要跳多少跳才能到达 tfs?在多个节点 X->Y->Z 的情况下,框 Y 上的服务可能能够模拟框 X 上的调用者的 ID。但是,它可能无权将该模拟传递给另一个上的服务框 Z。
  • 据我所知只有一跳。

标签: c# tfs impersonation


【解决方案1】:

首先让我先澄清一件事。您的应用程序似乎是一个服务器应用程序,在这种情况下,使用EnsureAuthenticated(). 没有任何价值,这只是帮助 UI/桌面客户端的性能调整技巧。

现在回到您的主要问题: - 如果您的应用程序在本地访问时按预期工作,但在远程访问时失败,请继续阅读,否则这不是您的解决方案。

失败的原因是需要将 SPN 添加到 Active Directory 上的服务帐户中。必须进行 Kerberos 身份验证。

这是 TFS 团队需要解释的事情,因为许多开发人员会在专注于它手头的工作时忘记它。希望这会有所帮助。

要了解有关 SPN 和 Kerberos 基础的更多信息,请查看以下资源:

我希望这会有所帮助。

谢谢!

【讨论】:

    【解决方案2】:

    您的用户在哪里设置了Make requests on behalf of others 权限?是在项目集合级别(通过Team &gt; Team Project Collection Settings &gt; Security.. 访问)还是在TFS 服务器级别(通过Team Foundation Administration Console &gt; Application Tier &gt; Security.. 访问)?

    我认为您的问题是您只有在“服务器”级别模拟的权限,但您试图在集合中模拟。

    这是 Taylor 在他的 Introducing TFS Impersonation 博客文章中所说的:

    此权限封装在每个团队项目集合中 并在配置服务器中。这意味着如果用户 A 有 TPC1 上的这个权限他将不能冒充用户 与 TPC2 或配置服务器通信时。同样,如果用户 B 在配置服务器上拥有此权限她将无法 在与任何团队项目集合交谈时冒充用户

    【讨论】:

      猜你喜欢
      • 2014-03-21
      • 2022-12-29
      • 2020-05-17
      • 1970-01-01
      • 2014-11-09
      • 1970-01-01
      • 1970-01-01
      • 2021-11-23
      • 1970-01-01
      相关资源
      最近更新 更多