获取客户的用户角色
获取附加到用户帐户的所有角色/权限的列表。 变体包括获取客户所有用户帐户的所有权限列表,以及获取具有给定角色的用户列表。
必备条件
合作伙伴中心身份验证中所述的凭据。 此方案只支持使用应用凭据和用户凭据进行身份验证。
客户 ID (
customer-tenant-id)。 如果不知道客户的 ID,则可以在合作伙伴中心仪表板中查找它。 从“合作伙伴中心”菜单中选择“CSP” ,然后选择“客户” 。 从客户列表中选择客户,然后选择“帐户” 。 在客户的“帐户”页上的“客户帐户信息” 部分查找 Microsoft ID。 Microsoft ID 与客户 ID (customer-tenant-id) 相同。
GDAP 角色:目录读取者、全局读取者、用户管理员、特权角色管理员、目录编写器
C#
若要检索指定客户的所有目录角色,请先检索指定的客户 ID。 然后,使用 IAggregatePartner.Customers 集合并调用 ById () 方法。 然后调用 DirectoryRoles 属性,后跟 Get () 或 **GetAsync () **方法。
// string selectedCustomerId;
// IAggregatePartner partnerOperations;
var directoryRoles = partnerOperations.Customers.ById(selectedCustomerId).DirectoryRoles.Get();
示例: 控制台测试应用。 Project:合作伙伴中心 SDK 示例类:GetCustomerDirectoryRoles.cs
若要检索具有给定角色的客户用户的列表,请先检索指定的客户 ID 和目录角色 ID。 然后,使用 IAggregatePartner.Customers 集合并调用 ById () 方法。 然后调用 DirectoryRoles 属性,然后调用 ById () 方法,然后调用 UserMembers 属性,后跟 Get () 或 GetAsync () 方法。
// string selectedCustomerId;
// IAggregatePartner partnerOperations;
// string selectedDirectoryRoleId;
var userMembers = partnerOperations.Customers.ById(selectedCustomerId).DirectoryRoles.ById(selectedDirectoryRoleId).UserMembers.Get();
示例: 控制台测试应用。 Project:PartnerSDK.FeatureSamples 类:GetCustomerDirectoryRoleUserMembers.cs
REST 请求
请求语法
| 方法 | 请求 URI |
|---|---|
| GET | {baseURL}/v1/customers/{customer-tenant-id}/users/{user-id}/directoryroles HTTP/1.1 |
| GET | {baseURL}/v1/customers/{customer-tenant-id}/directoryroles HTTP/1.1 |
| GET | {baseURL}/v1/customers/{customer-tenant-id}/directoryroles/{role-ID}/usermembers |
URI 参数
使用以下查询参数标识正确的客户。
| 名称 | 类型 | 必需 | 说明 |
|---|---|---|---|
| customer-tenant-id | guid | Y | 该值是 GUID 格式 的客户租户 ID, 允许经销商筛选属于经销商的给定客户的结果。 |
| user-id | guid | N | 该值是一个 GUID 格式 的用户 ID ,属于单个用户帐户。 |
| role-id | guid | N | 该值是一个 GUID 格式 的角色 ID ,属于角色类型。 可以通过在所有用户帐户中查询某个客户的所有目录角色来获取这些 ID。 (高于) 的第二种方案。 |
请求标头
有关详细信息,请参阅合作伙伴中心 REST 标头。
请求正文
请求示例
GET https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/users/<user-id>/directoryroles HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: b1317092-f087-471e-a637-f66523b2b94c
MS-CorrelationId: 8a53b025-d5be-4d98-ab20-229d1813de76
REST 响应
如果成功,此方法将返回与给定用户帐户关联的角色的列表。
响应的成功和错误代码
每个响应都带有一个 HTTP 状态代码,用于指示成功或失败以及其他调试信息。 请使用网络跟踪工具来读取此代码、错误类型和其他参数。 有关完整列表,请参阅错误代码。
响应示例
HTTP/1.1 200 OK
Content-Length: 31942
Content-Type: application/json
MS-CorrelationId: 8a53b025-d5be-4d98-ab20-229d1813de76
MS-RequestId: b1317092-f087-471e-a637-f66523b2b94c
Date: June 24 2016 22:00:25 PST
{
"totalCount": 2,
"items": [
{
"name": "Helpdesk Administrator",
"id": "729827e3-9c14-49f7-bb1b-9608f156bbb8",
"attributes": { "objectType": "DirectoryRole" }
},
{
"name": "User Account Administrator",
"id": "fe930be7-5e62-47db-91af-98c3a49a38b1",
"attributes": { "objectType": "DirectoryRole" }
}
],
"attributes": { "objectType": "Collection" }
}