8
votes

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.

1

1 Answers

5
votes

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;

Reference: http://blogs.msdn.com/b/aadgraphteam/archive/2014/12/12/announcing-azure-ad-graph-api-client-library-2-0.aspx