分享方式:


為客戶建立使用者帳戶

為您的客戶建立新的用戶帳戶。

必要條件

  • 認證,如合作夥伴中心驗證所述。 此案例僅支援使用「應用程式+使用者」認證來進行驗證。

  • 客戶識別碼 (customer-tenant-id)。 如果您不知道客戶的識別碼,您可以在合作夥伴中心查閱從合作夥伴中心首頁選取 [客戶] 工作區。 從 [客戶] 列表中選取客戶,然後選取 [ 帳戶]。 在客戶的 [帳戶] 頁面上,在 [客戶帳戶詳細數據] 區段中尋找 Microsoft 識別符。 Microsoft 識別碼與客戶識別碼 (customer-tenant-id) 相同。

  • 用戶網域不能是同盟網域。

GDAP 角色

您至少需要下列其中一個 GDAP 角色:

  • 使用者管理員
  • 目錄寫入者

C#

若要為客戶取得新的使用者帳戶:

  1. 使用相關的使用者資訊建立新的 CustomerUser 物件。

  2. 使用您的 IAggregatePartner.Customers 集合,並呼叫 ById() 方法。

  3. 呼叫 Users 屬性,後面接著 Create 方法。

// string selectedCustomerId;
// IAggregatePartner partnerOperations;
// var SelectedCustomer;

var userToCreate = new CustomerUser()
{
    PasswordProfile = new PasswordProfile() { ForceChangePassword = true, Password = "Password!1" },
    DisplayName = "TestDisplayName",
    FirstName = "TestFirstName",
    LastName = "TestLastName",
    UsageLocation = "US",
    UserPrincipalName = Guid.NewGuid().ToString("N") + "@" + selectedCustomer.CompanyProfile.Domain.ToString()
};

User createdUser = partnerOperations.Customers.ById(selectedCustomerId).Users.Create(userToCreate);

範例控制台測試應用程式專案:P artnerSDK.FeatureSamples 類別:CustomerUserCreate.cs

REST 要求

要求語法

方法 要求 URI
POST {baseURL}/v1/customers/{customer-tenant-id}/users HTTP/1.1

URI 參數

使用下列查詢參數來識別正確的客戶。

名稱 類型​​ 必要 描述
customer-tenant-id guid Y 此值是 GUID 格式的客戶 租用戶識別碼。它可讓轉銷商篩選屬於轉銷商之指定客戶的結果。
user-id guid 值是 GUID 格式 的使用者識別碼 ,屬於單一用戶帳戶。

要求標頭

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

要求本文

無。

要求範例

POST https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/users HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: b1317092-f087-471e-a637-f66523b2b94c
MS-CorrelationId: 8a53b025-d5be-4d98-ab20-229d1813de76
{
      "usageLocation": "country/region code",
      "userPrincipalName": "userid@domain.onmicrosoft.com",
      "firstName": "First",
      "lastName": "Last",
      "displayName": "User name",
      "immutableId": "Some unique ID",
      "passwordProfile":{
                 password: "abCD123*",
                 forceChangePassword: true
      },
      "attributes": {
        "objectType": "CustomerUser"
      }
}

REST 回應

如果成功,這個方法會傳回用戶帳戶,包括 GUID。

回應成功和錯誤碼

每個回應都隨附 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

{
  "usageLocation": "country/region code",
  "id": "4b10bf41-ab11-40e3-8c53-cd67849b50de",
  "userPrincipalName": "userid@domain.onmicrosoft.com",
  "firstName": "First",
  "lastName": "Last",
  "displayName": "User name",
  "immutableId": "Some unique ID",
  "passwordProfile": {
    "forceChangePassword": true,
    "password": "abCD123*"
  },
  "lastDirectorySyncTime": null,
  "userDomainType": "none",
  "state": "active",
  "softDeletionTime": null,
  "attributes": {
    "objectType": "CustomerUser"
  }
}