為客戶取得所有使用者帳戶的清單
本文說明如何取得屬於其中一個客戶的所有使用者帳戶清單。
若要依識別碼查閱單一使用者帳戶,請參閱 依 識別碼取得使用者帳戶。
必要條件
認證,如合作夥伴中心驗證所述。 此案例僅支援使用「應用程式+使用者」認證來進行驗證。
客戶識別碼 (
customer-tenant-id
)。 如果您不知道客戶的識別碼,您可以在合作夥伴中心 中選取 [客戶 ] 工作區,然後從客戶清單中查看客戶,然後 從 [帳戶 ]。 在客戶的 [帳戶] 頁面上,在 [客戶帳戶資訊] 區段中尋找 Microsoft 識別碼 。 Microsoft 識別碼與客戶識別碼 (customer-tenant-id
) 相同。
GDAP 角色
您至少需要下列其中一個 GDAP 角色:
- 目錄讀取器
- 全域讀取者
- 使用者管理員
C#
若要擷取指定客戶的所有使用者帳戶集合:
呼叫 Users.Get 或 GetAsync 方法來擷取集合。
// IAggregatePartner partnerOperations;
// string selectedCustomerId;
// Get customer users collection.
var customerUsers = partnerOperations.Customers.ById(selectedCustomerId).Users.Get();
如需範例,請參閱下列各項:
- 範例: 主控台測試應用程式
- 專案: 合作夥伴中心 SDK 範例
- 類別: GetCustomerUserCollection.cs
REST 要求
要求語法
方法 | 要求 URI |
---|---|
GET | {baseURL} /v1/customers/{customer-tenant-id}/users HTTP/1.1 |
URI 參數
使用下列 URI 參數來識別正確的客戶。
名稱 | 類型 | 必填 | 描述 |
---|---|---|---|
customer-tenant-id | guid | Y | 此值是 GUID 格式的客戶 租使用者識別碼 ,可讓轉銷商篩選屬於轉銷商之指定客戶的結果。 |
要求標頭
如需詳細資訊,請參閱合作夥伴中心 REST 標頭。
要求本文
無。
要求範例
GET https://api.partnercenter.microsoft.com/v1/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/users HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 5d845377-5b7d-4cd4-98f6-19e5ae3faa81
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
X-Locale: en-US
Host: api.partnercenter.microsoft.com
REST 回應
如果成功,這個方法會傳回客戶的使用者帳戶集合。
回應成功和錯誤碼
每個回應都隨附 HTTP 狀態碼,會指出成功與否以及其他的偵錯資訊。 請使用網路追蹤工具來讀取此錯誤碼、錯誤類型和其他參數。 如需完整清單,請參閱合作夥伴中心的 REST 錯誤碼。
回應範例
HTTP/1.1 200 OK
Content-Length: 1030
Content-Type: application/json; charset=utf-8
MS-CorrelationId: aaaa0000-bb11-2222-33cc-444444dddddd
MS-RequestId: 5d845377-5b7d-4cd4-98f6-19e5ae3faa81
MS-CV: 6zmKqrSFB0+t7m3y.0
MS-ServerId: 101112616
Date: Wed, 21 Dec 2016 21:13:24 GMT
{
"totalCount": 2,
"items": [{
"usageLocation": "US",
"id": "a9ef48bb-8758-4590-a312-d4a47bfaded4",
"userPrincipalName": "Daniel@dtdemocspcustomer005.onmicrosoft.com",
"firstName": "Daniel",
"lastName": "Tsai",
"displayName": "Daniel Tsai",
"userDomainType": "none",
"state": "active",
"links": {
"self": {
"uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/users/a9ef48bb-8758-4590-a312-d4a47bfaded4",
"method": "GET",
"headers": []
}
},
"attributes": {
"objectType": "CustomerUser"
}
}, {
"id": "6e668259-1f09-479d-bcb8-d9b03e826b8d",
"userPrincipalName": "admin@dtdemocspcustomer005.onmicrosoft.com",
"firstName": "Daniel",
"lastName": "Tsai",
"displayName": "DT Demo CSP Customer 005",
"userDomainType": "none",
"state": "active",
"links": {
"self": {
"uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/users/6e668259-1f09-479d-bcb8-d9b03e826b8d",
"method": "GET",
"headers": []
}
},
"attributes": {
"objectType": "CustomerUser"
}
}
],
"links": {
"self": {
"uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/users",
"method": "GET",
"headers": []
}
},
"attributes": {
"objectType": "Collection"
}
}