0

I have a web application that pre-populates a form with the users info where applicable. For populating the users name, I have used the ClaimsPrincipal to return the info as below:

    Private Sub WebApp_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim cp As ClaimsPrincipal = ClaimsPrincipal.Current
        txtName.Text = cp.FindFirst(ClaimTypes.GivenName).Value & " " & cp.FindFirst(ClaimTypes.Surname).Value
    End Sub

I also need to return the users Job Title and Department. How can I access the Azure AD Profile in code behind? I've looked at this thread and it looks as if it's pointing towards the Graph API, but am not sure if this would allow me to access it in the Code Behind or how I can even do this.

RazorKillBen
  • 561
  • 2
  • 20
  • The exact way are: `1. First you have to obtain token then` `2. Call Grpah API`. You could execute this query `https://graph.microsoft.com/v1.0/users?$select=displayName,jobTitle,department` that would fetch your required information. Feel free to ask further query if you have any thanks. – Md Farid Uddin Kiron Jul 29 '20 at 13:58
  • Thanks for the reply @MdFaridUddinKiron - how can I do this in code behind with the API response? I want to place the returned value into an ``. – RazorKillBen Jul 29 '20 at 14:09
  • Yes you can call that API, and bind that response to a class property then bind to your textbox. I guess you are using aspx web form. – Md Farid Uddin Kiron Jul 29 '20 at 15:06

0 Answers0