主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

使用 Azure Active Directory

根据组显示名称从 Azure Active Directory 获取组 ID

  1. 使用您的 Azure® AD 凭据登录 Microsoft® Graph Explorer:

    https://developer.microsoft.com/en-us/graph/graph-explorer

  2. 选择 GET 作为您的 HTTP 查询方法。

  3. 在文本框中指定以下查询:

    https://graph.microsoft.com/v1.0/groups?$filter=startswith(displayName,'<groupname>')

    <groupname> 替换为您要检索其 ID 的组名。

  4. 点击运行查询按钮。响应包括与您指定的显示名称匹配的组列表。在 JSON 响应中查找 id 字段以找到该组的对象 ID。这是您的组 ID。

示例查询和 JSON 响应

查询:

https://graph.microsoft.com/v1.0/groups?$filter=startswith(displayName,'Finance')

JSON 响应示例:

{
  "value": [
    {
      "id": "12345678-9abc-def0-1234-56789abcdef0",
      "displayName": "Finance Team",
      "mail": "financeteam@example.com",
      ...
    },
    {
      "id": "abcdef12-3456-7890-abcd-ef1234567890",
      "displayName": "Finance Department",
      "mail": "financedepartment@example.com",
      ...
    }
  ]
}

在此示例中,id 属性("12345678-9abc-def0-1234-56789abcdef0""abcdef12-3456-7890-abcd-ef1234567890")是显示名称以 "Finance" 开头的组的组 ID。

Azure Active Directory 获取特定用户的所有组 ID

  1. 使用您的 Azure AD 凭据登录 Microsoft Graph Explorer:

    https://developer.microsoft.com/en-us/graph/graph-explorer

  2. 选择 GET 作为您的 HTTP 查询方法。

  3. 在文本框中指定以下查询:

    https://graph.microsoft.com/v1.0/users/<username>@<domain>/transitiveMemberOf

    <username>@<domain> 替换为您要检索其组 ID 的用户的用户名和域。

  4. 点击运行查询按钮。响应包括指定用户所属的目录对象列表。

    • 查找 @odata.type#microsoft.graph.groupsecurityEnabled 设置为 true 的对象。

    • 这些对象的 id 属性代表组 ID。

示例查询和 JSON 响应

查询:

https://graph.microsoft.com/v1.0/users/johndoe@example.com/transitiveMemberOf

JSON 响应示例:

{
  "value": [
    {
      "@odata.type": "#microsoft.graph.group",
      "id": "12345678-9abc-def0-1234-56789abcdef0",
      "displayName": "Group 1",
      "securityEnabled": true
    },
    {
      "@odata.type": "#microsoft.graph.group",
      "id": "abcdef12-3456-7890-abcd-ef1234567890",
      "displayName": "Group 2",
      "securityEnabled": false
    }
  ]
}

在此示例中,id 12345678-9abc-def0-1234-56789abcdef0 的组将 securityEnabled 设置为 true,使其成为用户的相关组 ID。

注意

该查询使用 transitiveMemberOf 来获取用户所属的所有组,包括嵌套组。在 MATLAB® Web App Server™ 中,配置 groupAttributeNamegroups 以匹配 Microsoft Graph API 响应中使用的属性。

另请参阅

主题

外部网站