更新 agentUser

命名空间:microsoft.graph

更新 agentUser 对象的属性。

权限

为此 API 选择标记为最低特权的权限。 只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。

权限类型 最低特权权限 更高特权权限
委派(工作或学校帐户) AgentIdUser.ReadWrite.IdentityParentedBy AgentIdUser.ReadWrite.All、User.ReadWrite.All
委派(个人 Microsoft 帐户) 不支持。 不支持。
应用程序 AgentIdUser.ReadWrite.IdentityParentedBy AgentIdUser.ReadWrite.All、User.ReadWrite.All

特定方案的权限

  • 个人Microsoft帐户必须绑定到Microsoft Entra租户,才能使用个人Microsoft帐户的 User.ReadWrite 委托权限更新配置文件。
  • 更新 employeeLeaveDateTime 属性:
    • 在委派方案中,管理员需要 全局管理员 角色;必须向应用授予 User.Read.All 和 User-LifeCycleInfo.ReadWrite.All 委托权限。
    • 在具有 Microsoft Graph 权限的仅限应用方案中,必须向应用授予 User.Read.All 和 User-LifeCycleInfo.ReadWrite.All 权限。
  • 更新 customSecurityAttributes 属性:
    • 在委派方案中,必须为管理员分配 属性分配管理员 角色,并且应用被授予 CustomSecAttributeAssignment.ReadWrite.All 权限。
    • 在具有 Microsoft Graph 权限的仅限应用方案中,必须向应用授予 CustomSecAttributeAssignment.ReadWrite.All 权限。
  • User-Mail.ReadWrite.All 是更新 otherMails 属性的最低特权权限。
  • User-PasswordProfile.ReadWrite.All 是更新 passwordProfile 属性的最低特权权限。
  • User-Phone.ReadWrite.All 是更新 businessPhone 和 mobilePhone 属性的最低特权权限。
  • User.EnableDisableAccount.All + User.Read.All 是更新 accountEnabled 属性的权限的最低特权组合。
  • 需要 User.ManageIdentities.All 才能更新 identities 属性。

HTTP 请求

PATCH /users/microsoft.graph.agentUser/{userId}

提示

还可以通过 PATCH /users/{id} 终结点更新代理用户, microsoft.graph.agentUser 而无需指定类型。

请求标头

名称 说明
Authorization 持有者 {token}。 必填。 详细了解 身份验证和授权。
Content-Type application/json. 必需。

请求正文

在请求正文中, 仅 提供要更新的属性的值。 请求正文中未包含的现有属性会保留其以前的值,或者根据对其他属性值的更改重新计算。

下表指定可更新的属性。

更新 agentUser 时,必须在请求正文中指定 #microsoft.graph.agentUser@odata.type。

属性 类型 说明
accountEnabled Boolean 启用帐户时为 true,否则为 false。 创建代理用户时需要此属性。
assignedLicenses assignedLicense collection 分配给代理用户的许可证。 不可为 null。
businessPhones 字符串集合 代理用户的电话号码。 注意: 虽然这是一个字符串集合,但只能为此属性设置一个数字。
城市 String 代理用户所在的城市。
CompanyName String 代理用户与之关联的公司的名称。 此属性可用于描述外部代理用户来自的公司。 最大长度为 64 个字符。
country String 代理用户所在的国家/地区;例如, US 或 UK。
department String 代理用户所在的部门的名称。
displayName String 代理用户通讯簿中显示的名称。 创建代理用户时,此属性是必需的,在更新期间无法清除此属性。
employeeId String 组织分配给代理用户的员工标识符。 最大长度为 16 个字符。
employeeType String 捕获企业员工类型。 例如,Employee、Contractor、Consultant 或 Vendor。
givenName String 给定的名称 (代理用户的名字) 。
employeeHireDate DateTimeOffset 代理用户的雇用日期。 时间戳类型表示采用 ISO 8601 格式的日期和时间信息,始终采用 UTC 时区。 例如,2014 年 1 月 1 日午夜 UTC 为 2014-01-01T00:00:00Z。
employeeLeaveDateTime DateTimeOffset 代理用户离开或将离开组织的日期和时间。 时间戳类型使用 ISO 8601 格式表示日期和时间信息,并且始终采用 UTC 时间。 例如,2014 年 1 月 1 日午夜 UTC 为 2014-01-01T00:00:00Z。
employeeOrgData employeeOrgData 表示组织数据 (例如,与代理用户关联的部门和 costCenter) 。 更新 employeeOrgData 时包括这两个属性值;如果省略任何 ,系统会将它们设置为 null。
jobTitle String 代理用户的职务。
mail String 代理用户的 SMTP 地址, salesagent@contoso.com例如 。 对此属性的更改还会更新代理用户的 proxyAddresses 集合,以包含作为 SMTP 地址的值。 无法更新为 null。
mailNickname String 代理用户的邮件别名。 必须在创建代理用户时指定此属性。
mobilePhone String 代理用户的主要手机电话号码。
officeLocation String 代理用户营业地中的办公室位置。
otherMails 字符串集合 代理用户的其他电子邮件地址列表;例如: ["salesagent@contoso.com", "agentsales@fabrikam.com"]。 若要更新此属性,请传入你希望代理用户拥有的所有电子邮件地址;否则,现有值将被指定的值覆盖。 最多可以存储 250 个值,每个值的限制为 250 个字符。
postalCode String 代理用户的邮政地址的邮政编码。 邮政编码特定于代理用户的国家/地区。 在美国,此属性包含邮政编码。
preferredLanguage String 代理用户的首选语言。 应遵循 ISO 639-1 代码;例如,en-US。
state String 代理用户地址中的州或省。
streetAddress String 代理用户的营业地点的街道地址。
surname String 代理用户的姓氏 (姓氏或姓氏) 。
usageLocation String 两个字母的国家/地区代码(ISO 标准 3166)。 对于将分配许可证的代理用户是必需的,因为法律要求检查国家/地区服务的可用性。 示例包括: US、 JP和 GB。 不可为 null。
userPrincipalName String 用户主体名称 (代理用户的 UPN) 。 UPN 是基于 Internet 标准 RFC 822 的代理用户的 Internet 样式登录名称。 按照约定,这应映射到代理用户的电子邮件名称。 常规格式是 alias@domain,其中 domain 必须位于租户的已验证域集合中。 可从 组织 的 verifiedDomains 属性访问租户的已验证域。
注意:此属性不能包含重音字符。 仅支持使用以下字符:A - Z、a - z、0 - 9、 ' . - _ ! # ^ ~。 有关允许字符的完整列表,请参阅用户名策略。
userType String 可用于对目录中的用户类型进行分类的字符串值,例如MemberGuest。

由于 agentUser 资源支持 扩展,因此可以使用 PATCH 操作在现有 agentUser 实例中扩展的自定义属性中添加、更新或删除自己的特定于应用的数据。

管理扩展名和关联的数据

使用此 API 管理代理用户的目录、架构和开放扩展及其数据,如下所示:

  • 在现有代理用户的扩展中添加、更新和存储数据
  • 对于目录和架构扩展,通过将自定义扩展属性的值设置为 null来删除任何存储的数据。 对于开放扩展,请使用 删除开放扩展 API。

响应

如果成功,此方法在响应正文中返回响应 200 OK 代码和更新的 agentUser 对象。

示例

请求

以下示例显示了一个请求。

PATCH https://graph.microsoft.com/v1.0/users/microsoft.graph.agentUser/{userId}
Content-Type: application/json

{
  "@odata.type": "#microsoft.graph.agentUser",
  "accountEnabled": true,
  "assignedLicenses": [
    {
      "@odata.type": "microsoft.graph.assignedLicense"
    }
  ],
  "businessPhones": [
    "+1 425 555 0109"
  ],
  "city": "Seattle",
  "companyName": "Contoso",
  "country": "United States",
  "department": "Sales",
  "displayName": "Sales Agent",
  "employeeId": "12345",
  "employeeType": "Agent",
  "givenName": "Sales",
  "employeeHireDate": "2024-01-15T00:00:00Z",
  "employeeLeaveDateTime": null,
  "employeeOrgData": {
    "@odata.type": "microsoft.graph.employeeOrgData",
    "division": "Sales Division",
    "costCenter": "1234"
  },
  "jobTitle": "Sales Agent",
  "mail": "salesagent@contoso.com",
  "mailNickname": "SalesAgent",
  "mobilePhone": "+1 425 555 0110",
  "officeLocation": "18/2111",
  "otherMails": [
    "salesagent@contoso.com"
  ],
  "postalCode": "98052",
  "preferredLanguage": "en-US",
  "state": "WA",
  "streetAddress": "9256 Towne Center Dr., Suite 400",
  "surname": "Agent",
  "usageLocation": "US",
  "userPrincipalName": "salesagent@contoso.com",
  "userType": "Member"
}

响应

以下示例显示了相应的响应。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 200 OK
Content-Type: application/json

{
  "@odata.type": "#microsoft.graph.agentUser",
  "id": "929393ae-1e1d-159f-0d83-29f7df42e7b9",
  "signInActivity": {
    "@odata.type": "microsoft.graph.signInActivity"
  },
 "cloudLicensing": {
      "@odata.type": "microsoft.graph.cloudLicensing.userCloudLicensing"
    },
    "accountEnabled": "Boolean",
    "ageGroup": null,
    "assignedLicenses": [
      {
        "@odata.type": "microsoft.graph.assignedLicense"
      }
    ],
    "assignedPlans": [
      {
        "@odata.type": "microsoft.graph.assignedPlan"
      }
    ],
    "authorizationInfo": null,
    "businessPhones": [
      "String"
    ],
    "city": "String",
    "companyName": "String",
    "consentProvidedForMinor": null,
    "country": "String",
    "createdDateTime": "String (timestamp)",
    "creationType": "String",
    "department": "String",
    "displayName": "String",
    "employeeHireDate": "String (timestamp)",
    "employeeId": "String",
    "employeeOrgData": {
      "@odata.type": "microsoft.graph.employeeOrgData"
    },
    "employeeType": "String",
    "employeeLeaveDateTime": "String (timestamp)",
    "faxNumber": "String",
    "givenName": "String",
    "identities": [
      {
        "@odata.type": "microsoft.graph.objectIdentity"
      }
    ],
    "imAddresses": [
      "String"
    ],
    "infoCatalogs": [
      "String"
    ],
    "isLicenseReconciliationNeeded": "Boolean",
    "isManagementRestricted": "Boolean",
    "isResourceAccount": "Boolean",
    "jobTitle": "String",
    "lastPasswordChangeDateTime": null,
    "legalAgeGroupClassification": null,
    "licenseAssignmentStates": [
      {
        "@odata.type": "microsoft.graph.licenseAssignmentState"
      }
    ],
    "mail": "String",
    "mailNickname": "String",
    "mobilePhone": "String",
    "onPremisesDistinguishedName": null,
    "onPremisesExtensionAttributes": null,
    "onPremisesImmutableId": null,
    "onPremisesLastSyncDateTime": null,
    "onPremisesProvisioningErrors": null,
    "onPremisesSecurityIdentifier": null,
    "onPremisesSipInfo": null,
    "onPremisesSyncEnabled": null,
    "onPremisesDomainName": null,
    "onPremisesSamAccountName": null,
    "onPremisesUserPrincipalName": null,
    "otherMails": [
      "String"
    ],
    "passwordPolicies": null,
    "passwordProfile": null,
    "officeLocation": "String",
    "postalCode": "String",
    "preferredDataLocation": "String",
    "preferredLanguage": "String",
    "provisionedPlans": [
      {
        "@odata.type": "microsoft.graph.provisionedPlan"
      }
    ],
    "proxyAddresses": [
      "String"
    ],
    "refreshTokensValidFromDateTime": "String (timestamp)",
    "securityIdentifier": "String",
    "serviceProvisioningErrors": [
      {
        "@odata.type": "microsoft.graph.serviceProvisioningXmlError"
      }
    ],
    "showInAddressList": "Boolean",
    "signInSessionsValidFromDateTime": "String (timestamp)",
    "state": "String",
    "streetAddress": "String",
    "surname": "String",
    "usageLocation": "String",
    "userPrincipalName": "String",
    "externalUserState": null,
    "externalUserStateChangeDateTime": null,
    "userType": "String",
    "identityParentId": "String",
    "mailboxSettings": {
      "@odata.type": "microsoft.graph.mailboxSettings"
    },
    "aboutMe": "String",
    "birthday": "String (timestamp)",
    "interests": [
      "String"
    ],
    "mySite": "String",
    "pastProjects": [
      "String"
    ],
    "preferredName": "String",
    "responsibilities": [
      "String"
    ],
    "schools": [
      "String"
    ],
    "skills": [
      "String"
    ]
  }