文档首页> 统一身份认证服务 IAM> API参考> API> IAM用户管理> 管理员创建IAM用户(推荐)
更新时间:2024-04-01 GMT+08:00
分享

管理员创建IAM用户(推荐)

功能介绍

该接口可以用于管理员创建IAM用户。

该接口可以使用全局区域的Endpoint和其他区域的Endpoint调用。IAM的Endpoint请参见:地区和终端节点

调试

您可以在API Explorer中调试该接口。

URI

POST /v3.0/OS-USER/users

请求参数

表1 请求Header参数

参数

是否必选

参数类型

描述

Content-Type

String

该字段内容填为“application/json;charset=utf8”。

X-Auth-Token

String

访问令牌,承载用户的身份、权限等信息。

token所需权限请参见授权项

表2 请求Body参数

参数

是否必选

参数类型

描述

user

Object

IAM用户信息。

表3 user

参数

是否必选

参数类型

描述

name

String

IAM用户名,长度1~64之间,只能包含如下字符:大小写字母、空格、数字或特殊字符(-_.)且不能以数字或空格开头。

domain_id

String

IAM用户所属的账号ID,获取方式请参见:获取账号、IAM用户、项目、用户组、区域、委托的名称和ID

password

String

IAM用户密码。

email

String

IAM用户邮箱,需符合邮箱格式,长度小于等于255位。

areacode

String

国家码。必须与手机号同时存在。中国大陆为“0086”。

phone

String

IAM用户手机号,纯数字,长度小于等于32位。必须与国家码同时存在。

enabled

Boolean

是否启用IAM用户。true为启用,false为停用,默认为true。

pwd_status

Boolean

IAM用户首次登录是否重置密码,默认需要重置。

xuser_type

String

IAM用户在外部系统中的类型。长度小于等于64位。xuser_type如果存在,则需要与同一租户中的xaccount_type、xdomain_type校验,须与xuser_id同时存在。xuser_type取值当前仅支持TenantIdp。

说明:

外部系统指与华为云对接的外部企业管理系统,xaccount_type、xaccount_id、xdomain_type、xdomain_id、xuser_type、xuser_id等参数值,无法在华为云获取,请咨询企业管理员。

xuser_id

String

IAM用户在外部系统中的ID。长度小于等于128位,须与xuser_type同时存在。使用API设置外部身份ID后,由于时延IAM控制台暂无法实时显示,请稍后刷新查看。

说明:

外部系统指与华为云对接的外部企业管理系统,xaccount_type、xaccount_id、xdomain_type、xdomain_id、xuser_type、xuser_id等参数值,无法在华为云获取,请咨询企业管理员。

access_mode

String

IAM用户访问方式。

  • default:默认访问模式,编程访问和管理控制台访问。
  • programmatic:编程访问。
  • console:管理控制台访问。

description

String

IAM用户描述信息。

响应参数

表4 响应Body参数

参数

参数类型

描述

user

Object

IAM用户信息。

表5 user

参数

参数类型

描述

status

Integer

IAM用户状态信息。

pwd_status

Boolean

IAM用户首次登录是否重置密码。

xuser_id

String

IAM用户在外部系统中的ID。

说明:

外部系统指与华为云对接的外部企业管理系统,xaccount_type、xaccount_id、xdomain_type、xdomain_id、xuser_type、xuser_id等参数值,无法在华为云获取,请咨询企业管理员。

xuser_type

String

用户在外部系统中的类型。

说明:

外部系统指与华为云对接的外部企业管理系统,xaccount_type、xaccount_id、xdomain_type、xdomain_id、xuser_type、xuser_id等参数值,无法在华为云获取,请咨询企业管理员。

access_mode

String

IAM用户访问方式。

  • default:默认访问模式,编程访问和管理控制台访问。
  • programmatic:编程访问。
  • console:管理控制台访问。

description

String

IAM用户描述信息。

name

String

IAM用户名,长度1~32之间,只能包含如下字符:大小写字母、空格、数字或特殊字符(-_.)且不能以数字或空格开头。

phone

String

IAM用户手机号,纯数字,长度小于等于32位。必须与国家码同时存在。

is_domain_owner

Boolean

IAM用户是否为账号管理员

domain_id

String

IAM用户所属账号ID。

enabled

Boolean

是否启用IAM用户。true为启用,false为停用,默认为true。

areacode

String

国家码。中国大陆为“0086”。

email

String

IAM用户邮箱。

create_time

String

IAM用户创建时间。

说明:

UTC时间,格式为 YYYY-MM-DDTHH:mm:ss.ssssssZ,日期和时间戳格式参照 ISO-8601,如:2023-06-28T08:56:33.710000Z。

xdomain_id

String

运营主体的客户编码。

xdomain_type

String

运营主体。

id

String

IAM用户ID。长度为32字符。

password_expires_at

String

密码过期时间,“null”表示密码不过期。

说明:

UTC时间,格式为 YYYY-MM-DDTHH:mm:ss.ssssssZ,日期和时间戳格式参照 ISO-8601,如:2023-06-28T08:56:33.710000Z。

请求示例

管理员创建一个名为“IAMUser”的IAM用户,用户的邮箱地址是IAMEmail@huawei.com,手机号码是008612345678910,使用默认访问模式,可以编程访问和管理控制台访问。

POST https://iam.myhuaweicloud.com/v3.0/OS-USER/users
{
    "user": {
        "domain_id": "d78cbac186b744899480f25...",
        "name": "IAMUser",
        "password": "IAMPassword@",
        "email": "IAMEmail@huawei.com",
        "areacode": "0086",
        "phone": "12345678910",
        "enabled": true,
        "pwd_status": false,
        "xuser_type": "",
        "xuser_id": "",
        "access_mode" : "default",
        "description": "IAMDescription"
    }
}

响应示例

状态码为 201 时:

创建成功。

{
    "user": {
        "pwd_status": false,
        "xuser_id": "",
        "xuser_type": "",
        "access_mode" : "default",
        "description": "IAMDescription",
        "name": "IAMUser",
        "phone": "12345678910",
        "is_domain_owner": false,
        "enabled": true,
        "domain_id": "d78cbac186b744899480f25bd...",
        "areacode": "0086",
        "email": "IAMEmail@huawei.com",
        "create_time": "2020-01-06T08:05:16.000000",
        "xdomain_id": "",
        "xdomain_type": "",
        "id": "07664aec578026691f00c003a..."
    }
}

返回值

返回值

描述

201

创建成功。

400

参数无效。

401

认证失败。

403

没有操作权限。

404

未找到相应的资源。

405

不允许的方法。

409

资源冲突。

413

请求体过大。

500

内部服务错误。

503

服务不可用。

错误码

请参考错误码

分享:

    相关文档

    相关产品