为客户重置用户密码

重置密码类似于更新客户现有用户帐户中的其他详细信息。

先决条件

  • 合作伙伴中心身份验证中所述的凭据。 此方案只支持使用应用凭据和用户凭据进行身份验证。

  • 客户 ID (customer-tenant-id)。 如果不知道客户的 ID,可以在合作伙伴中心查找它。 从合作伙伴中心主页中选择“客户”工作区。 从 “客户”列表中选择客户,然后选择“ 帐户”。 在客户的“帐户”页上,在“客户帐户详细信息”部分查找 Microsoft ID。 Microsoft ID 与客户 ID (customer-tenant-id) 相同。

GDAP 角色

至少需要以下 GDAP 角色之一:

  • 用户管理员
  • 特权身份验证管理员

C#

若要重置指定客户用户的密码,请先检索指定的客户 ID 和目标用户。 然后,创建一个新的 CustomerUser 对象,该对象包含现有客户的信息,但使用新的 PasswordProfile 对象。 然后,使用 IAggregatePartner.Customers 集合并调用 ById() 方法。 然后调用 Users 属性、ById() 方法,然后调用 Patch 方法。

// IAggregatePartner partnerOperations;
// string selectedCustomerId;
// CustomerUser specifiedUser;

var selectedCustomer = partnerOperations.Customers.ById(selectedCustomerId).Get();
var userToUpdate = new CustomerUser()
   {
      PasswordProfile = new PasswordProfile() { ForceChangePassword = true, Password = "newPassword" },
      DisplayName = "Roger Federer",
      FirstName = "Roger",
      LastName = "Federer",
      UsageLocation = "US",
      UserPrincipalName = Guid.NewGuid().ToString("N") + "@" + selectedCustomer.CompanyProfile.Domain.ToString()
   };

// update customer user information
User updatedCustomerUserInfo = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(specifiedUser.Id).Patch(userToUpdate);

示例

控制台测试应用项目:PartnerSDK.FeatureSamples :CustomerUserUpdate.cs

REST 请求

请求语法

方法 请求 URI
PATCH {baseURL}/v1/customers/{customer-tenant-id}/users/{user-id}/resetpassword HTTP/1.1

URI 参数

使用以下查询参数标识正确的客户。

名称 类型 必需 说明
customer-tenant-id Guid Y 该值是 GUID 格式 的客户租户 ID ,允许经销商筛选属于经销商的给定客户的结果。
user-id Guid Y 该值是属于单个用户帐户的 GUID 格式 的用户 ID

请求标头

有关详细信息,请参阅合作伙伴中心 REST 标头

请求示例

PATCH https://api.partnercenter.microsoft.com/v1/customers/<customer-tenant-id>/users/<user-id>/resetpassword HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: b1317092-f087-471e-a637-f66523b2b94c
MS-CorrelationId: 8a53b025-d5be-4d98-ab20-229d1813de76
{
     "passwordProfile":{
        password: "Renew456*",
        forceChangePassword: true
      },

      "attributes": {
        "objectType": "CustomerUser"
      }
}

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
{
  "usageLocation": "AX",
  "id": "95794928-9abe-4548-8b43-50ffc20b9404",
  "userPrincipalName": "aaaa4@abcdefgh1234.onmicrosoft.com",
  "firstName": "aaaa4",
  "lastName": "aaaa4",
  "displayName": "aaaa4",
  "passwordProfile": {
    "forceChangePassword": false,
    "password": "Renew456*"
  },
  "lastDirectorySyncTime": null,
  "userDomainType": "none",
  "state": "active",
  "softDeletionTime": null,
  "links": {
    "self": {
      "uri": "/customers/eebd1b55-5360-4438-a11d-5c06918c3014/users/95794928-9abe-4548-8b43-50ffc20b9404",
      "method": "GET",
      "headers": [

      ]
    }
  },
  "attributes": {
    "objectType": "CustomerUser"
  }
}