Creating a Microsoft Azure Graph Client for .net emit $ expand

I am trying to get a (paged) list of all users in a directory, with the manager property extension. When I run the following HTTP request, it works the way I want:

https://graph.windows.net/DOMAIN/users/?$expand=manager&api-version=2013-11-08 

However, I do not understand how to make the same request with the Azure AD Graph client. This is what I am trying:

 var userResult = _activeDirectoryClient.Users.Expand(x => x.Manager).ExecuteAsync().Result; 
+8
c # graph azure office365 azure-active-directory
source share
2 answers

I applied the following from the example at https://github.com/AzureADSamples/ConsoleApp-GraphAPI-DotNet/blob/master/GraphConsoleAppV3/Program.cs , please take a picture:

  List<IUser> usersList = null; IPagedCollection<IUser> searchResults = null; try { IUserCollection userCollection = activeDirectoryClient.Users; userResult = userCollection.ExecuteAsync().Result; usersList = searchResults.CurrentPage.ToList(); } catch (Exception e) { Console.WriteLine("\nError getting User {0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : ""); } if (usersList != null && usersList.Count > 0) { do { usersList = searchResults.CurrentPage.ToList(); foreach (IUser user in usersList) { Console.WriteLine("User DisplayName: {0} UPN: {1} Manager: {2}", user.DisplayName, user.UserPrincipalName, user.Manager); } searchResults = searchResults.GetNextPageAsync().Result; } while (searchResults != null); } else { Console.WriteLine("No users found"); } 
+4
source share

GraphClient does not yet implement all the functions in the Graph API.
New features are added to GraphClient over time and will be announced on the AAD team blog:

http://blogs.msdn.com/b/aadgraphteam/

And updates will be available in the nuget package (Microsoft Azure Active Directory GPU Client Library).

You can do whatever you need by making the Http calls to the url you have, and respond as Json like this:

 using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://graph.windows.net/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync("DOMAIN/users/?$expand=manager&api-version=2013-11-08"); if (response.IsSuccessStatusCode) { // TODO: Deserialize the response here... } } 
+2
source share

All Articles