Help us learn about your current experience with the documentation. Take the survey.

组级企业用户 API

  • Tier: Premium, Ultimate
  • Offering: GitLab.com

使用此 API 与企业用户账户进行交互。更多信息,请参阅 企业用户

此 API 端点仅适用于顶级组。用户不必是该组的成员。

前提条件:

  • 您必须在顶级组中拥有 Owner 角色。

列出所有企业用户

列出指定顶级组下的所有企业用户。

使用 pageper_page 分页参数 来筛选结果。

GET /groups/:id/enterprise_users

支持的属性:

属性 类型 必需 描述
id integer/string 顶级组的 ID 或 URL 编码路径
username string 返回具有指定用户名的用户。
search string 返回姓名、电子邮件或用户名匹配的用户。使用部分值以获得更多结果。
active boolean 仅返回活跃用户。
blocked boolean 仅返回被屏蔽的用户。
created_after datetime 返回在指定时间之后创建的用户。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ)。
created_before datetime 返回在指定时间之前创建的用户。格式:ISO 8601 (YYYY-MM-DDTHH:MM:SSZ)。
two_factor string 根据其双因素认证 (2FA) 注册状态返回用户。可能的值:enabled, disabled

示例请求:

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/enterprise_users"

示例响应:

[
  {
    "id": 66,
    "username": "user22",
    "name": "Sidney Jones22",
    "state": "active",
    "avatar_url": "https://www.gravatar.com/avatar/xxx?s=80&d=identicon",
    "web_url": "http://my.gitlab.com/user22",
    "created_at": "2021-09-10T12:48:22.381Z",
    "bio": "",
    "location": null,
    "public_email": "",
    "linkedin": "",
    "twitter": "",
    "website_url": "",
    "organization": null,
    "job_title": "",
    "pronouns": null,
    "bot": false,
    "work_information": null,
    "followers": 0,
    "following": 0,
    "local_time": null,
    "last_sign_in_at": null,
    "confirmed_at": "2021-09-10T12:48:22.330Z",
    "last_activity_on": null,
    "email": "user22@example.org",
    "theme_id": 1,
    "color_scheme_id": 1,
    "projects_limit": 100000,
    "current_sign_in_at": null,
    "identities": [
      {
        "provider": "group_saml",
        "extern_uid": "2435223452345",
        "saml_provider_id": 1
      }
    ],
    "can_create_group": true,
    "can_create_project": true,
    "two_factor_enabled": false,
    "external": false,
    "private_profile": false,
    "commit_email": "user22@example.org",
    "shared_runners_minutes_limit": null,
    "extra_shared_runners_minutes_limit": null,
    "scim_identities": [
      {
        "extern_uid": "2435223452345",
        "group_id": 1,
        "active": true
      }
    ]
  },
  ...
]

获取企业用户的详细信息

获取指定企业用户的详细信息。

GET /groups/:id/enterprise_users/:user_id

支持的属性:

属性 类型 必需 描述
id integer/string 顶级组的 ID 或 URL 编码路径
user_id integer 用户账户的 ID。

示例请求:

curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/enterprise_users/:user_id"

示例响应:

{
  "id": 66,
  "username": "user22",
  "name": "Sidney Jones22",
  "state": "active",
  "avatar_url": "https://www.gravatar.com/avatar/xxx?s=80&d=identicon",
  "web_url": "http://my.gitlab.com/user22",
  "created_at": "2021-09-10T12:48:22.381Z",
  "bio": "",
  "location": null,
  "public_email": "",
  "linkedin": "",
  "twitter": "",
  "website_url": "",
  "organization": null,
  "job_title": "",
  "pronouns": null,
  "bot": false,
  "work_information": null,
  "followers": 0,
  "following": 0,
  "local_time": null,
  "last_sign_in_at": null,
  "confirmed_at": "2021-09-10T12:48:22.330Z",
  "last_activity_on": null,
  "email": "user22@example.org",
  "theme_id": 1,
  "color_scheme_id": 1,
  "projects_limit": 100000,
  "current_sign_in_at": null,
  "identities": [
    {
      "provider": "group_saml",
      "extern_uid": "2435223452345",
      "saml_provider_id": 1
    }
  ],
  "can_create_group": true,
  "can_create_project": true,
  "two_factor_enabled": false,
  "external": false,
  "private_profile": false,
  "commit_email": "user22@example.org",
  "shared_runners_minutes_limit": null,
  "extra_shared_runners_minutes_limit": null,
  "scim_identities": [
    {
      "extern_uid": "2435223452345",
      "group_id": 1,
      "active": true
    }
  ]
}

为企业用户禁用双因素认证

为指定的企业用户禁用双因素认证 (2FA)。

PATCH /groups/:id/enterprise_users/:user_id/disable_two_factor

支持的属性:

属性 类型 必需 描述
id integer/string 顶级组的 ID 或 URL 编码路径
user_id integer 用户账户的 ID。

示例请求:

curl --request PATCH --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/:id/enterprise_users/:user_id/disable_two_factor"

如果成功,将返回 204 No content

其他可能的响应:

  • 400 Bad request: 未为指定用户启用 2FA。
  • 403 Forbidden: 已认证的用户不是 Owner。
  • 404 Not found: 找不到用户。