Users - Create
在应用程序中创建用户
PUT https://{subdomain}.{baseDomain}/api/users/{userId}?api-version=2022-07-31
URI 参数
| 名称 | 在 | 必需 | 类型 | 说明 |
|---|---|---|---|---|
|
base
|
path | True |
string |
所有 Azure IoT Central 服务请求的基域。 |
|
subdomain
|
path | True |
string |
应用程序子域。 |
|
user
|
path | True |
string maxLength: 48pattern: ^[a-zA-Z0-9-_]*$ |
用户的唯一 ID。 |
|
api-version
|
query | True |
string |
要调用的 API 的版本。 |
请求正文
请求正文可以为下列任一内容:
| 名称 | 说明 |
|---|---|
|
ADGroup |
Active Directory 组用户定义。 |
|
Email |
电子邮件用户定义。 |
|
Service |
服务主体用户定义。 |
ADGroupUser
Active Directory 组用户定义。
| 名称 | 必需 | 类型 | 说明 |
|---|---|---|---|
| objectId | True |
string |
AD 组的 AAD 对象 ID。 |
| roles | True |
指定访问应用程序的权限的角色分配列表。 |
|
| tenantId | True |
string |
AD 组的 AAD 租户 ID。 |
| type | True |
string:
ad |
用户的类型。 |
EmailUser
电子邮件用户定义。
| 名称 | 必需 | 类型 | 说明 |
|---|---|---|---|
| True |
string |
用户的电子邮件地址。 |
|
| roles | True |
指定访问应用程序的权限的角色分配列表。 |
|
| type | True |
string:
|
用户的类型。 |
ServicePrincipalUser
服务主体用户定义。
| 名称 | 必需 | 类型 | 说明 |
|---|---|---|---|
| objectId | True |
string |
服务主体的 AAD 对象 ID。 |
| roles | True |
指定访问应用程序的权限的角色分配列表。 |
|
| tenantId | True |
string |
服务主体的 AAD 租户 ID。 |
| type | True |
string:
service |
用户的类型。 |
响应
| 名称 | 类型 | 说明 |
|---|---|---|
| 200 OK | User: |
成功 |
| Other Status Codes |
从 IoT Central 服务收到的错误响应。 标头 x-ms-error-code: string |
安全性
azure_auth
Azure Active Directory OAuth2 流
类型:
oauth2
流向:
implicit
授权 URL:
https://login.microsoftonline.com/common/oauth2/authorize
作用域
| 名称 | 说明 |
|---|---|
| user_impersonation | 模拟用户帐户 |
示例
| Add or update a service principal user |
| Add or update an email user |
Add or update a service principal user
示例请求
PUT https://appsubdomain.azureiotcentral.com/api/users/123?api-version=2022-07-31
{
"type": "servicePrincipal",
"tenantId": "027fdad7-cf0f-470a-a26a-272197813322",
"objectId": "65e13aac-1443-4c49-9d49-57b87197cfff",
"roles": [
{
"role": "c7be2c6b-797e-4551-bb24-33709f6b2e20"
},
{
"role": "c495eb57-eb18-489e-9802-62c474e5645c",
"organization": "seattle"
}
]
}
示例响应
{
"id": "123",
"type": "servicePrincipal",
"tenantId": "027fdad7-cf0f-470a-a26a-272197813322",
"objectId": "65e13aac-1443-4c49-9d49-57b87197cfff",
"roles": [
{
"role": "c7be2c6b-797e-4551-bb24-33709f6b2e20"
},
{
"role": "c495eb57-eb18-489e-9802-62c474e5645c",
"organization": "seattle"
}
]
}
Add or update an email user
示例请求
PUT https://appsubdomain.azureiotcentral.com/api/users/123?api-version=2022-07-31
{
"type": "email",
"roles": [
{
"role": "ca310b8d-2f4a-44e0-a36e-957c202cd8d4"
},
{
"role": "c495eb57-eb18-489e-9802-62c474e5645c",
"organization": "seattle"
}
],
"email": "bob@contoso.com"
}
示例响应
{
"type": "email",
"roles": [
{
"role": "ca310b8d-2f4a-44e0-a36e-957c202cd8d4"
},
{
"role": "c495eb57-eb18-489e-9802-62c474e5645c",
"organization": "seattle"
}
],
"email": "bob@contoso.com"
}
定义
| 名称 | 说明 |
|---|---|
|
ADGroup |
Active Directory 组用户定义。 |
|
Email |
电子邮件用户定义。 |
| Error |
响应错误定义。 |
|
Error |
错误的详细信息。 |
|
Role |
角色分配定义。 |
|
Service |
服务主体用户定义。 |
ADGroupUser
Active Directory 组用户定义。
| 名称 | 类型 | 说明 |
|---|---|---|
| id |
string |
用户的唯一 ID。 |
| objectId |
string |
AD 组的 AAD 对象 ID。 |
| roles |
指定访问应用程序的权限的角色分配列表。 |
|
| tenantId |
string |
AD 组的 AAD 租户 ID。 |
| type |
string:
ad |
用户的类型。 |
EmailUser
电子邮件用户定义。
| 名称 | 类型 | 说明 |
|---|---|---|
|
string |
用户的电子邮件地址。 |
|
| id |
string |
用户的唯一 ID。 |
| roles |
指定访问应用程序的权限的角色分配列表。 |
|
| type |
string:
|
用户的类型。 |
Error
响应错误定义。
| 名称 | 类型 | 说明 |
|---|---|---|
| error |
当前请求的错误详细信息。 |
ErrorDetails
错误的详细信息。
| 名称 | 类型 | 说明 |
|---|---|---|
| code |
string |
错误代码。 |
| message |
string |
错误消息详细信息。 |
| requestId |
string |
当前请求的相关 ID。 |
| time |
string (date-time-rfc1123) |
错误请求失败的时间。 |
RoleAssignment
角色分配定义。
| 名称 | 类型 | 说明 |
|---|---|---|
| organization |
string |
此角色分配的组织 ID。 |
| role |
string |
此角色分配的角色的 ID。 |
ServicePrincipalUser
服务主体用户定义。
| 名称 | 类型 | 说明 |
|---|---|---|
| id |
string |
用户的唯一 ID。 |
| objectId |
string |
服务主体的 AAD 对象 ID。 |
| roles |
指定访问应用程序的权限的角色分配列表。 |
|
| tenantId |
string |
服务主体的 AAD 租户 ID。 |
| type |
string:
service |
用户的类型。 |