user.create

描述

object user.create(object/array **users**)

此方法允许创建新的用户。

Description

object user.create(object/array **users**)

This method allows to create new users.

Parameters

(object/array) 要创建的用户.

该方法接受有 标准用户属性的用户。

属性类型说明
passwd
(required)
string用户密码。
usrgrps
(required)
array用户添加到的组。

用户组必须有存在的 usrgrpid 属性定义。
user_mediasarray为用户创建媒体。

Parameters

(object/array) Users to create.

Additionally to the standard user properties, the method accepts the following parameters.

ParameterTypeDescription
passwd
(required)
stringUser’s password.
usrgrps
(required)
arrayUser groups to add the user to.

The user groups must have the usrgrpid property defined.
user_mediasarrayMedias to create for the user.

返回值

(object)返回一个包含创建值的ID的对象映射 userids 属性。返回的ID的顺序与传递的用户的顺序相匹配。

Return values

(object) Returns an object containing the IDs of the created users under the userids property. The order of the returned IDs matches the order of the passed users.

示例

Examples

创建一个用户

创建一个新用户, 把用户加入用户组同时添加用户媒体。

Creating a user

Create a new user, add him to a user group and create a new media for him.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "user.create",
  4. "params": {
  5. "alias": "John",
  6. "passwd": "Doe123",
  7. "usrgrps": [
  8. {
  9. "usrgrpid": "7"
  10. }
  11. ],
  12. "user_medias": [
  13. {
  14. "mediatypeid": "1",
  15. "sendto": [
  16. "[email protected]"
  17. ],
  18. "active": 0,
  19. "severity": 63,
  20. "period": "1-7,00:00-24:00"
  21. }
  22. ]
  23. },
  24. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  25. "id": 1
  26. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "userids": [
  5. "12"
  6. ]
  7. },
  8. "id": 1
  9. }

参考

来源

CUser::create() in frontends/php/include/classes/api/services/CUser.php.