Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Azure by (13.1k points)

I was trying to create an application which is a role based authorization using Azure AD. Below is my code:

ActiveDirectoryClient client = AuthenticationHelper.GetActiveDirectoryClient();

var app = (await client.Applications.GetByObjectId("applicationObjectId").ExecuteAsync());

var servicePrincipal = await client.ServicePrincipals.GetByObjectId("servicePrincipalObjectId").ExecuteAsync();

var appRole = app.AppRoles.First(r => r.DisplayName == "my role");

var mygroup = (await client.Groups.ExecuteAsync()).CurrentPage.FirstOrDefault();

Can anyone help me what am I missing?

1 Answer

0 votes
by (26.7k points)
edited by

Basically, you need to change your pseudo code like the below one:

ActiveDirectoryClient client = AuthenticationHelper.GetActiveDirectoryClient();

var app = (await client.Applications.GetByObjectId("applicationObjectId").ExecuteAsync());

var servicePrincipal = await client.ServicePrincipals.GetByObjectId("servicePrincipalObjectId").ExecuteAsync();

var appRole = app.AppRoles.First(r => r.DisplayName == "my role");

var mygroup = (Group)(await client.Groups.ExecuteAsync()).CurrentPage.FirstOrDefault();

I hope this will help.

Want to become an Azure expert? join Azure Developer Training now!!

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...