You can see this if you click on the name of the logged-in user once the application is running and you have authenticated.
What if you want to extend this?
The first step is to find out what the attribute is called?
The easiest way to do this is to use the Graph Explorer.
Click "Use Demo Company" then "Get" then click on:
"https://graph.windows.net/GraphDir1.OnMicrosoft.com/users".
You'll get a list of the AAD schema attributes e.g if you want the user department, you'll see the name is "department".
In the VS project under "Models / HomeViewModels.cs" add another line e.g.
public string Department { get; set; }
Under "Views / Home / UserProfile.cshtml" add another line e.g.
This uses Razor syntax - you may have something different but you get the general idea.<td>Department</td> <td>@Model.department</td>
The key to this is under "Controllers / HomeController.cs" where:
UserProfile profile = JsonConvert.DeserializeObjectleverages the power of the JSON library to serialize the attributes you have defined.(responseString);
Job done.
Enjoy!
No comments:
Post a Comment