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. 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 request
Get the manager:
GET /me/manager
GET /users/{id | userPrincipalName}/manager
Get the management chain:
GET /users?$expand=manager
GET /users/{id | userPrincipalName}/?$expand=manager($levels=n)
Optional query parameters
This method supports the $select and $expandOData query parameters to help customize the response.
Note:
The n value of $levels can be max (to return all managers) or a number between 1 and 1000.
When the $levels parameter is not specified, only the immediate manager is returned.
You can specify $select inside $expand to select the individual manager's properties. The $levels parameter is required: $expand=manager($levels=max;$select=id,displayName).
$levels parameter is only supported on a single user (/users/{id} or me endpoints) and not on the entire list of users.
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
result, err := graphClient.UsersById("user-id").Manager().Get(context.Background(), nil)
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestResult = $graphServiceClient->usersById('user-id')->manager()->get();
GET https://graph.microsoft.com/v1.0/me?$expand=manager($levels=max;$select=id,displayName)&$select=id,displayName&$count=true
ConsistencyLevel: eventual
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
new QueryOption("$count", "true")
};
var user = await graphClient.Me
.Request( queryOptions )
.Header("ConsistencyLevel","eventual")
.Expand("manager($levels=max;$select=id,displayName)")
.Select("id,displayName")
.GetAsync();
Import-Module Microsoft.Graph.Users
# A UPN can also be used as -UserId.
Get-MgUser -UserId $userId -ExpandProperty "manager(`$levels=max;`$select=id,displayName)" -Property "id,displayName" -CountVariable CountVar -ConsistencyLevel eventual
<?php
// THIS SNIPPET IS A PREVIEW FOR THE KIOTA BASED SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($requestAdapter);
$requestConfiguration = new MeRequestBuilderGetRequestConfiguration();
$queryParameters = new MeRequestBuilderGetQueryParameters();
$queryParameters->expand = ["manager($levels=max;$select=id,displayName)"];
$queryParameters->select = ["id","displayName"];
$queryParameters->count = true;
$headers = [
'ConsistencyLevel' => 'eventual',
];
$requestConfiguration->queryParameters = $queryParameters;
$requestConfiguration->headers = $headers;
$requestResult = $graphServiceClient->me()->get($requestConfiguration);