Reputation: 4324
User's manager object is always null when i try to retrieve a user. But i get "objectId", which is the corresponding manager(user) GUID. I can use this GUID to get Manager from API calls or from https://graphexplorer.cloudapp.net but not from Graph Client using C# (even with 2.1.0 version: https://www.nuget.org/packages/Microsoft.Azure.ActiveDirectory.GraphClient).
Can someone guide me on this? Thanks in advance.
Upvotes: 8
Views: 2279
Reputation: 4324
I just need to add Expand(x=> x.Manager) while getting users.(version: 2.1.0)
Example:
var users = activeDirectoryClient.Users
.Where(user => user.UserPrincipalName.Equals(searchString)).Expand(m => m.Manager)
.ExecuteAsync().Result.CurrentPage.ToList();
var manager = user[index].Manager as User;
Upvotes: 6