memberOf を一覧表示するList memberOf
名前空間: microsoft.graphNamespace: microsoft.graph
ユーザーがダイレクト メンバーになっているグループとディレクトリ ロールを取得します。Get groups and directory roles that the user is a direct member of.
アクセス許可Permissions
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可」を参照してください。One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.
アクセス許可の種類Permission type | アクセス許可 (特権の小さいものから大きいものへ)Permissions (from least to most privileged) |
---|---|
委任 (職場または学校のアカウント)Delegated (work or school account) | Directory.Read.All、Directory.ReadWrite.All、Directory.AccessAsUser.AllDirectory.Read.All, Directory.ReadWrite.All, Directory.AccessAsUser.All |
委任 (個人用 Microsoft アカウント)Delegated (personal Microsoft account) | サポートされていません。Not supported. |
アプリケーションApplication | Directory.Read.All、Directory.ReadWrite.AllDirectory.Read.All, Directory.ReadWrite.All |
アプリケーションが directoryObject 型のコレクションを返す関係をクエリするときに、特定の派生型 (デバイスなど) を読み取るアクセス許可がない場合、その型のメンバーが返されますが、情報は限られます。When an application queries a relationship that returns a directoryObject type collection, if it does not have permission to read a certain derived type (like device), members of that type are returned but with limited information. この動作により、アプリケーションは、Directory.* 権限が付与されたアクセス許可のセットに依存するのではなく、必要な最小限のアクセス許可を要求できます。With this behaviour applications can request the least privileged permissions they need, rather than rely on the set of Directory.* permissions. 詳細については、「アクセスできないメンバー オブジェクトについて、限定された情報が返される」を参照してください。For details, see Limited information returned for inaccessible member objects.
HTTP 要求HTTP request
GET /me/memberOf
GET /users/{id | userPrincipalName}/memberOf
オプションのクエリ パラメーターOptional query parameters
このメソッドは、応答をカスタマイズするための$search
、$count
、および$filter
を含むOData クエリ パラメーターをサポートします。This method supports the OData query parameters to help customize the response, including $search
, $count
, and $filter
. また、OData キャストも有効です。たとえば、ユーザーが属する directoryRoles のみを取得することができます。OData cast is also enabled, for example, you can cast to get just the directoryRoles the user is a member of. displayName プロパティで$search
を使用できます。You can use $search
on the displayName property. このリソースのアイテムを追加または更新すると、 $count
と $search
クエリ パラメーターを共に使用するように特別にインデックスが作成されます。When items are added or updated for this resource, they are specially indexed for use with the $count
and $search
query parameters. アイテムを追加または更新してから、インデックスで使用できるようになるまでに少し時間がかかる場合があります。There can be a slight delay between when an item is added or updated and when it is available in the index.
要求ヘッダーRequest headers
ヘッダーHeader | 値Value |
---|---|
AuthorizationAuthorization | ベアラー {トークン}。必須。Bearer {token}. Required. |
ConsistencyLevelConsistencyLevel | 最終的。eventual. このヘッダーおよび$count は、$search 、$filter 、$orderby 、または OData キャスト クエリ パラメーターを使用する場合に必要です。This header and $count are required when using the $search , $filter , $orderby , or OData cast query parameters. 最新の状態に更新されていない可能性があるインデックスを使用しています。It uses an index that might not be up-to-date with recent changes to the object. |
要求本文Request body
このメソッドには、要求本文を指定しません。Do not supply a request body for this method.
応答Response
成功した場合、このメソッドは 200 OK
応答コードと、応答本文で directoryObject オブジェクトのコレクションを返します。If successful, this method returns a 200 OK
response code and collection of directoryObject objects in the response body.
例Examples
例 1: ユーザーがダイレクト メンバーになっているグループ、ディレクトリ ロール、および管理単位を取得するExample 1: Get groups, directory roles, and administrative units that the user is a direct member of
要求Request
要求の例を次に示します。The following is an example of the request.
GET https://graph.microsoft.com/v1.0/users/{id}/memberOf
応答Response
応答の例を次に示します。The following is an example of the response.
注: 読みやすくするために、ここに示す応答オブジェクトは短縮されている場合があります。実際の呼び出しからは、すべてのプロパティが返されます。Note: The response object shown here might be shortened for readability. All the properties will be returned from an actual call.
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"@odata.type": "#microsoft.graph.group",
"displayName": "All Users",
"mailEnabled": false,
"securityEnabled": true
}
]
}
例 2: ユーザーがダイレクト メンバーになっているグループ、ディレクトリ ロール、および管理単位の数のみを取得するExample 2: Get only a count of all groups, directory roles, and administrative units that the user is a direct member of
要求Request
以下は、要求の例です。Here is an example of the request.
GET https://graph.microsoft.com/v1.0/users/{id}/memberOf/$count
ConsistencyLevel: eventual
応答Response
応答の例を次に示します。The following is an example of the response.
注: 読みやすくするために、ここに示す応答オブジェクトは短縮されている場合があります。実際の呼び出しからは、すべてのプロパティが返されます。Note: The response object shown here might be shortened for readability. All the properties will be returned from an actual call.
HTTP/1.1 200 OK
Content-type: text/plain
例 3: OData キャストを使用して、グループ メンバーシップ数のみを取得するExample 3: Use OData cast to get only a count of group membership
要求Request
要求の例を次に示します。The following is an example of the request.
GET https://graph.microsoft.com/v1.0/users/{id}/memberOf/microsoft.graph.group/$count
ConsistencyLevel: eventual
応答Response
応答の例を次に示します。The following is an example of the response.
HTTP/1.1 200 OK
Content-type: text/plain
例 4: $search および OData キャストを使用して、表示名に「tier」の文字が含まれるグループのメンバーシップを取得する (返されたオブジェクトの数も含む)Example 4: Use $search and OData cast to get membership in groups with display names that contain the letters 'tier' including a count of returned objects
要求Request
要求の例を次に示します。The following is an example of the request.
GET https://graph.microsoft.com/v1.0/users/{id}/memberOf/microsoft.graph.group?$count=true&$orderby=displayName&$search="displayName:tier"&$select=displayName,id
ConsistencyLevel: eventual
応答Response
応答の例を次に示します。The following is an example of the response.
注: 読みやすくするために、ここに示す応答オブジェクトは短縮されている場合があります。実際の呼び出しからは、すべてのプロパティが返されます。Note: The response object shown here might be shortened for readability. All the properties will be returned from an actual call.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#groups(displayName,id)",
"@odata.count":7,
"value":[
{
"displayName":"Contoso-tier Query Notification",
"id":"11111111-2222-3333-4444-555555555555"
}
]
}
例 5: $filter および OData キャストを使用して、「a」で始まる表示名のグループを取得する (返されたオブジェクトの数も含む)Example 5: Use $filter and OData cast to get groups with a display name that starts with 'a' including a count of returned objects
要求Request
要求の例を次に示します。The following is an example of the request.
GET https://graph.microsoft.com/v1.0/users/{id}/memberOf/microsoft.graph.group?$count=true&$orderby=displayName&$filter=startswith(displayName, 'a')
ConsistencyLevel: eventual
応答Response
応答の例を次に示します。The following is an example of the response.
注: 読みやすくするために、ここに示す応答オブジェクトは短縮されている場合があります。実際の呼び出しからは、すべてのプロパティが返されます。Note: The response object shown here might be shortened for readability. All the properties will be returned from an actual call.
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#groups",
"@odata.count":76,
"value":[
{
"displayName":"AAD Contoso Users",
"mail":"AADContoso_Users@contoso.com",
"mailEnabled":true,
"mailNickname":"AADContoso_Users",
"securityEnabled":true
}
]
}