我一直在环顾四周,我发现有一些REST API请求加载安全组和当前身份:
tfs/DefaultCollection/Test/_api/_identity/ReadIdentitiesPageJson?__v=5
例如,在打开Team Foundation Server的警报设置页面时调用它。
现在我无法弄清楚哪个客户端TFS对象接收到该API调用产生JSON,因为我需要获取当前身份GUID才能使用自定义工作项跟踪控件创建警报。
我的问题是哪个客户端对象包含这样的值?
以下是上述HTTP请求返回的示例JSON:
{
"identities": [{
"IdentityType": "group",
"FriendlyDisplayName": "Build Administrators",
"DisplayName": "[Test]\\Build Administrators",
"SubHeader": "[Test]",
"TeamFoundationId": "881e0467-b2c5-467c-b145-a2c5a0966463",
"Errors": [],
"Warnings": [],
"IsWindowsGroup": false,
"Description": "Members of this group can create, modify and delete build definitions and manage queued and completed builds.",
"Scope": "Test",
"MemberCountText": "0 members",
"IsTeam": false,
"IsProjectLevel": true
}, {
"IdentityType": "group",
"FriendlyDisplayName": "Contributors",
"DisplayName": "[Test]\\Contributors",
"SubHeader": "[Test]",
"TeamFoundationId": "9da39547-51c0-41a8-a1f5-88e3936f0736",
"Errors": [],
"Warnings": [],
"IsWindowsGroup": false,
"Description": "Members of this group can add, modify, and delete items within the team project.",
"Scope": "Test",
"MemberCountText": "0 members",
"IsTeam": false,
"IsProjectLevel": true
}, {
"IdentityType": "group",
"FriendlyDisplayName": "Project Administrators",
"DisplayName": "[Test]\\Project Administrators",
"SubHeader": "[Test]",
"TeamFoundationId": "f0611ae0-3048-4bee-bffe-91bf84921052",
"Errors": [],
"Warnings": [],
"IsWindowsGroup": false,
"Description": "Members of this group can perform all operations in the team project.",
"Scope": "Test",
"MemberCountText": "0 members",
"IsTeam": false,
"IsProjectLevel": true
}, {
"IdentityType": "group",
"FriendlyDisplayName": "Project Valid Users",
"DisplayName": "[Test]\\Project Valid Users",
"SubHeader": "[Test]",
"TeamFoundationId": "0a969c95-452c-43c2-84ae-b59be9be0d3e",
"Errors": [],
"Warnings": [],
"IsWindowsGroup": false,
"Description": "Members of this group have acess to the team project.",
"Scope": "Test",
"MemberCountText": "6 members",
"IsTeam": false,
"IsProjectLevel": true,
"RestrictEditingMembership": true
}, {
"IdentityType": "group",
"FriendlyDisplayName": "Readers",
"DisplayName": "[Test]\\Readers",
"SubHeader": "[Test]",
"TeamFoundationId": "e61e08fa-ead6-46b1-87a6-a90610b70ba0",
"Errors": [],
"Warnings": [],
"IsWindowsGroup": false,
"Description": "Members of this group have access to the team project.",
"Scope": "Test",
"MemberCountText": "0 members",
"IsTeam": false,
"IsProjectLevel": true
}, {
"IdentityType": "team",
"FriendlyDisplayName": "Test Team",
"DisplayName": "[Test]\\Test Team",
"SubHeader": "[Test]",
"TeamFoundationId": "5985029c-5cc6-4f07-ad2f-c5bcf687804c",
"Errors": [],
"Warnings": [],
"IsWindowsGroup": false,
"Description": "The default project team.",
"Scope": "Test",
"MemberCountText": "0 members",
"IsTeam": true,
"IsProjectLevel": true
}, {
"IdentityType": "user",
"FriendlyDisplayName": "mfidemraizer",
"DisplayName": "mfidemraizer",
"SubHeader": "win7vm-dev\\mfidemraizer",
"TeamFoundationId": "a595782b-afac-46d0-a800-8245d13bb25b",
"Errors": [],
"Warnings": [],
"Domain": "win7vm-dev",
"AccountName": "mfidemraizer",
"IsWindowsUser": true,
"MailAddress": ""
}],
"hasMore": false,
"totalIdentityCount": 7
}
我需要"TeamFoundationId": "a595782b-afac-46d0-a800-8245d13bb25b"
值。
答案 0 :(得分:2)
我终于找到了一些东西。我希望它有所帮助。
我认为 TFS.Host.TfsContext.getDefault().currentIdentity
带来了您需要的当前用户身份。
此外,还有一些在当前的 TFSContext ,TFS.Host.TfsContext.getDefault()
下可用,例如: .currentUser (显示名称)和<强> .currentTeam 强>
答案 1 :(得分:1)
每当我需要知道当前经过身份验证的用户GUID时,我最终都会对整个tfs/DefaultCollection/Test/_api/_identity/ReadIdentitiesPageJson?__v=5
REST API资源执行HTTP / GET请求。
目前,它解决了我的问题!