Sim*_*mon 5 c# impersonation tfs tfs2010
我试图通过模仿用户在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;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
它成功地获得了模仿身份,但却落空了
ImpersonatedTFS.EnsureAuthenticated();
Run Code Online (Sandbox Code Playgroud)
这两个帐户都设置了"代表他人发出请求"权限集.
您的用户在哪里设置了权限Make requests on behalf of others?是在项目集合级别(通过访问Team > Team Project Collection Settings > Security..)还是在 TFS 服务器级别(通过访问Team Foundation Administration Console > Application Tier > Security..)?
我认为你的问题是你只有在“服务器”级别模拟的权限,但你试图在集合中模拟。
这是 Taylor 在他的TFS 模拟简介博客文章中所说的内容:
此权限封装在每个团队项目集合和配置服务器内。这意味着如果用户 A 在 TPC1 上具有此权限,则在与 TPC2 或配置服务器通信时将不允许他模拟用户。同样,如果用户 B 在配置服务器上具有此权限,那么她在与任何团队项目集合交谈时将无法模拟用户。
| 归档时间: |
|
| 查看次数: |
3195 次 |
| 最近记录: |