Roleassignments - Set Role Assignments
在资源上设置角色分配
PUT https://dev.azure.com/{organization}/_apis/securityroles/scopes/{scopeId}/roleassignments/resources/{resourceId}?api-version=7.1-preview.1
PUT https://dev.azure.com/{organization}/_apis/securityroles/scopes/{scopeId}/roleassignments/resources/{resourceId}?limitToCallerIdentityDomain={limitToCallerIdentityDomain}&api-version=7.1-preview.1
URI 参数
名称 | 在 | 必需 | 类型 | 说明 |
---|---|---|---|---|
resource
|
path | True |
string |
要为其分配角色的资源的 ID |
scope
|
path | True |
string |
分配的范围 ID |
organization
|
path |
string |
Azure DevOps 组织的名称。 |
|
api-version
|
query | True |
string |
要使用的 API 版本。 应将其设置为“7.1-preview.1”才能使用此版本的 API。 |
limit
|
query |
boolean |
请求正文
名称 | 类型 | 说明 |
---|---|---|
body |
要分配的角色 |
响应
名称 | 类型 | 说明 |
---|---|---|
200 OK |
成功的操作 |
安全性
oauth2
类型:
oauth2
流向:
accessCode
授权 URL:
https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
令牌 URL:
https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
作用域
名称 | 说明 |
---|---|
vso.security_manage | 授予读取、写入和管理安全权限的能力。 |
示例
Set Role assignments
示例请求
PUT https://dev.azure.com/_apis/securityroles/scopes/{scopeId}/roleassignments/resources/{resourceId}?api-version=7.1-preview.1
[
{
"roleName": "Administrator",
"userId": "4189bd2b-de9c-45de-a886-4e3d9c03f1f9"
}
]
示例响应
{
"count": 1,
"value": [
{
"identity": {
"displayName": "Your Identity Name",
"id": "cbb1d8ac-cee5-47c1-878a-e75c0e94ac89",
"uniqueName": "Your Identity Unique Name"
},
"role": {
"displayName": "Administrator",
"name": "Administrator",
"allowPermissions": 3,
"denyPermissions": 0,
"identifier": "distributedtask.serviceendpointrole.Administrator",
"description": "Administrator can use and manage the service connection.",
"scope": "distributedtask.serviceendpointrole"
},
"access": "assigned",
"accessDisplayName": "Assigned"
}
]
}
定义
名称 | 说明 |
---|---|
Identity |
|
Reference |
表示 REST 引用链接集合的类。 |
Role |
将角色指定为显式分配或继承的角色。 |
Role |
|
Security |
|
User |
IdentityRef
名称 | 类型 | 说明 |
---|---|---|
_links |
此字段包含有关图形主题的零个或多个相关链接。 可以调用这些链接来获取有关此图主题的其他关系或更多详细信息。 |
|
descriptor |
string |
描述符是在系统运行时引用图形主题的主要方式。 此字段将唯一标识帐户和组织中的同一图形主题。 |
directoryAlias |
string |
已弃用 - 可通过查询 IdentityRef“_links”字典的“self”条目中引用的 Graph 用户来检索 |
displayName |
string |
这是图形主题的非唯一显示名称。 若要更改此字段,必须在源提供程序中更改其值。 |
id |
string |
|
imageUrl |
string |
已弃用 - 在 IdentityRef“_links”字典的“头像”条目中可用 |
inactive |
boolean |
已弃用 - 可以通过查询 GraphUser“_links”字典的“membershipState”条目中引用的 Graph 成员身份状态来检索 |
isAadIdentity |
boolean |
已弃用 - 可以从描述符的主题类型推断 (描述符.IsAadUserType/Descriptor.IsAadGroupType) |
isContainer |
boolean |
已弃用 - 可以从描述符的主题类型推断 (描述符.IsGroupType) |
isDeletedInOrigin |
boolean |
|
profileUrl |
string |
已弃用 - 未在 ToIdentityRef 的大多数预先存在的实现中使用 |
uniqueName |
string |
已弃用 - 改用 Domain+PrincipalName |
url |
string |
此 URL 是此图主题的源资源的完整路由。 |
ReferenceLinks
表示 REST 引用链接集合的类。
名称 | 类型 | 说明 |
---|---|---|
links |
object |
链接的只读视图。 由于引用链接是只读的,因此我们只想将其公开为只读。 |
RoleAccess
将角色指定为显式分配或继承的角色。
值 | 说明 |
---|---|
assigned |
已显式设置访问权限。 |
inherited |
访问权限继承自更高范围。 |
RoleAssignment
名称 | 类型 | 说明 |
---|---|---|
access |
将角色指定为显式分配或继承的角色。 |
|
accessDisplayName |
string |
访问分配的用户友好说明。 |
identity |
向其分配角色的用户。 |
|
role |
分配给用户的角色。 |
SecurityRole
名称 | 类型 | 说明 |
---|---|---|
allowPermissions |
integer |
允许角色的权限。 |
denyPermissions |
integer |
角色被拒绝的权限。 |
description |
string |
角色定义的用户访问的说明 |
displayName |
string |
角色的用户友好名称。 |
identifier |
string |
角色的全局唯一标识符。 |
name |
string |
作用域中角色的唯一名称。 |
scope |
string |
返回 ParentScope 的 ID。 |
UserRoleAssignmentRef
名称 | 类型 | 说明 |
---|---|---|
roleName |
string |
分配的角色的名称。 |
uniqueName |
string |
给定角色分配的用户的标识符。 |
userId |
string |
给定角色分配的用户的唯一 ID。 |