web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

How to fetch user details from Azure active directory from D365 Plugin/JS using Graph API or any other Option?

(0) ShareShare
ReportReport
Posted on by 592

I need to auto fill the contact form based on the email and get the User details from the Azure active directory by Email.

I have the same question (0)
  • Suggested answer
    Ankit Sabharwal Profile Picture
    on at

    Hy Bhabani,

    Hope this post finds you well. You can use Graph API : https://graph.microsoft.com/v1.0/users in order to achieve above requirement.

    You can use C# code in plugin in order to call this api. As this API will also require the token authentication.  You can refer following URL : https://developer.microsoft.com/en-us/graph/gallery/?filterBy=Samples,C%23

    for samples.

    In addition to it , https://developer.microsoft.com/en-us/graph/graph-explorer is the graph explorer for all the Graph api's you can use.

    Hope this helps.

    Best regards,

    Ankit

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Suggested answer
    Ankit Sabharwal Profile Picture
    on at

    I have used Graph PI for getting the SKU's with below code:-

    private static void getLicenses()

           {

               string serviceUrl = "graph.microsoft.com";

               AuthenticationContext authContext = new AuthenticationContext("login.microsoftonline.com/3b57d5b1-2f5b-4dbd-825b-1c716bcd5494");

               ClientCredential credential = new ClientCredential(clientId, secret);

               AuthenticationResult result = authContext.AcquireTokenAsync(serviceUrl, credential).Result;

               string accessToken = result.AccessToken;

               using (HttpClient client = new HttpClient())

               {

                   client.DefaultRequestHeaders.Add("Authorization", $"Bearer {accessToken}");

                   client.BaseAddress = new Uri("graph.microsoft.com");

                   client.Timeout = new TimeSpan(0, 2, 0);  //2 minutes

                   client.DefaultRequestHeaders.Add("OData-MaxVersion", "4.0");

                   client.DefaultRequestHeaders.Add("OData-Version", "4.0");

                   client.DefaultRequestHeaders.Accept.Add(

                       new MediaTypeWithQualityHeaderValue("application/json"));

                   //createAccount(client);

                   var response = client.GetAsync("/v1.0/subscribedSkus",

                           HttpCompletionOption.ResponseHeadersRead).Result;

                   if (response.IsSuccessStatusCode)

                   {

                       //Get the response content and parse it.  

                       JObject body = JObject.Parse(response.Content.ReadAsStringAsync().Result);

                   }

               }

           }

    // Client Id and Secret Id : These can be fetched when regisering an application in Azure acricve directory: docs.microsoft.com/.../quickstart-register-app

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 108 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans