Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Graph API C# Client - Unable to get user's Manager object

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.

like image 393
Ranadheer Reddy Avatar asked Dec 24 '15 13:12

Ranadheer Reddy


People also ask

Is Microsoft Graph API deprecated?

Azure Active Directory (Azure AD) Graph is deprecated and will be retired at any time after June 30, 2023, without advance notice, as we announced in September, 2022.

What is Graph API in Azure?

The Microsoft Graph API is a RESTful web API that enables you to access Microsoft Cloud service resources. After you register your app and get authentication tokens for a user or service, you can make requests to the Microsoft Graph API.

Is the Microsoft Graph API free?

We have some datasets available for free or are currently free in preview while other datasets are charged. Microsoft Graph Data Connect offers datasets across multiple different Microsoft 365 products and services.

Is Graph API same as GraphQL?

CosmosDB Graph API is a query language to manage and query "CosmosDB graph database". Graph database unlike traditional databases, store information in the form of a graph (i.e., vertices and edges). GraphQL on the other hand is a query language for a user API.


1 Answers

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

like image 74
Ranadheer Reddy Avatar answered Oct 30 '22 11:10

Ranadheer Reddy