分享方式:


為客戶檢視已刪除的使用者

依客戶標識碼取得客戶已刪除的 CustomerUser 資源清單。 您可以選擇性地設定頁面大小。 您必須提供篩選條件。

必要條件

刪除用戶帳戶時會發生什麼事?

當您刪除使用者帳戶時,用戶狀態會設定為「非使用中」。 30 天內,用戶帳戶及其相關聯的數據會清除並無法復原。 如果您想要在 30 天內還原已刪除的用戶帳戶,請參閱 為客戶還原已刪除的使用者。 一旦刪除並標示為「非使用中」,用戶帳戶就不會再傳回為使用者集合的成員(例如,使用 取得客戶所有使用者帳戶的清單)。 若要取得尚未清除的已刪除使用者清單,您必須查詢已設定為非使用中的用戶帳戶。

C#

若要擷取已刪除的使用者清單,請建構查詢,以篩選狀態設定為非使用中的客戶使用者。 首先,使用參數具現 化 SimpleFieldFilter 物件來建立篩選,如下列代碼段所示。 然後使用 BuildIndexedQuery 方法建立查詢 如果您不想要分頁結果,您可以改用 BuildSimpleQuery 方法。 接下來,使用 IAggregatePartner.Customers.ById 方法搭配客戶標識符來識別客戶。 最後,呼叫 Query 方法以傳送要求。

// IAggregatePartner partnerOperations;
// int customerUserPageSize;

// Create a filter for users whose status is inactive (i.e. deleted).
var filter = new SimpleFieldFilter("UserState", FieldFilterOperation.Equals, "Inactive");

// Build a paged query.
var simpleQueryWithFilter = QueryFactory.Instance.BuildIndexedQuery(customerUserPageSize, 0, filter);

// Send the request.
var customerUsers = partnerOperations.Customers.ById(selectedCustomerId).Users.Query(simpleQueryWithFilter);

範例控制台測試應用程式專案:合作夥伴中心 SDK 範例 類別:GetCustomerInactiveUsers.cs

REST 要求

要求語法

方法 要求 URI
GET {baseURL}/v1/customers/{customer-id}/users?size={size}&filter={filter} HTTP/1.1

URI 參數

建立要求時,請使用下列路徑和查詢參數。

名稱 類型​​ 必要 描述
customer-id guid Yes 此值是 GUID 格式的客戶識別碼,可識別客戶。
size int No 要一次顯示的結果數目。 這是選擇性參數。
篩選器 篩選器 Yes 篩選用戶搜尋的查詢。 若要擷取已刪除的使用者,您必須包含並編碼下列字串:{“Field”:“UserState”,“Value”:“Inactive”,“Operator”:“equals”}。

要求標頭

如需詳細資訊,請參閱合作夥伴中心 REST 標頭

要求本文

無。

要求範例

GET https://api.partnercenter.microsoft.com/v1/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/users?size=500&filter=%7B%22Field%22%3A%22UserState%22%2C%22Value%22%3A%22Inactive%22%2C%22Operator%22%3A%22equals%22%7D HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: c11feb95-55d2-45b6-9d1b-74b55d2221fb
MS-CorrelationId: 2b4ab588-f48c-4874-b479-a61895e107b2
X-Locale: en-US
Host: api.partnercenter.microsoft.com

REST 回應

如果成功,這個方法會在回應本文中傳回 CustomerUser 資源的集合

回應成功和錯誤碼

每個回應都隨附 HTTP 狀態碼,會指出成功與否以及其他的偵錯資訊。 請使用網路追蹤工具來讀取此錯誤碼、錯誤類型和其他參數。 如需完整清單,請參閱合作夥伴中心的 REST 錯誤碼

回應範例

HTTP/1.1 200 OK
Content-Length: 802
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 690b34ca-07c8-4f8a-ab13-f22a50594a43
MS-RequestId: 1187f9ad-02b4-4d96-b668-7cf3d289467b
MS-CV: 3TLmR9gz6EaCVCjR.0
MS-ServerId: 101112616
Date: Fri, 20 Jan 2017 19:13:14 GMT

{
    "totalCount": 1,
    "items": [{
            "usageLocation": "US",
            "id": "a45f1416-3300-4f65-9e8d-f123b397a4ea",
            "userPrincipalName": "e83763f7f2204ac384cfcd49f79f2749@dtdemocspcustomer005.onmicrosoft.com",
            "firstName": "Ferdinand",
            "lastName": "Filibuster",
            "displayName": "Ferdinand",
            "userDomainType": "none",
            "state": "inactive",
            "softDeletionTime": "2017-01-20T00:33:34Z",
            "links": {
                "self": {
                    "uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/users/a45f1416-3300-4f65-9e8d-f123b397a4ea",
                    "method": "GET",
                    "headers": []
                }
            },
            "attributes": {
                "objectType": "CustomerUser"
            }
        }
    ],
    "links": {
        "self": {
            "uri": "/customers/4d3cf487-70f4-4e1e-9ff1-b2bfce8d9f04/users?size=500&filter=%7B%22Field%22%3A%22UserStatus%22%2C%22Value%22%3A%22Inactive%22%2C%22Operator%22%3A%22equals%22%7D",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "Collection"
    }
}