Using the Azure Active Directory Graph Client, I can successfully query the AD for its user roles with the ff. code:
var activeDirectoryClient = new ActiveDirectoryClient(); // Instantiate the Graph Client here.
var adRoles = await activeDirectoryClient.DirectoryRoles.ExecuteAsync();
Is it possible, however, to get:
In this case, my definition of an admin would be users under the Company Administrator role, or those who would be able to authorize an application (via the auth request URL with format https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=xxx-xxx&resource=yyy-yyy&redirect_uri=zzz-zzz&prompt=admin_consent)
Identifying the global administratorsLog in to the public Azure portal. In the left hand side portal menu select Azure Active Directory. In the Manage section, select Roles and Administrators. In the Roles and administrators blade, scroll down and select Global administrator.
All new functionalities will only be available through the Microsoft Graph. Microsoft Graph is also more secure and resilient than Azure AD Graph. Microsoft Graph has all the capabilities that have been available in Azure AD Graph and new APIs like identity protection and authentication methods.
Sign in to the Azure portal as a Global Administrator. Browse to Azure Active Directory > Devices > Device settings. Select Manage Additional local administrators on all Azure AD joined devices. Select Add assignments then choose the other administrators you want to add and select Add.
There are a couple of ways you can do this and let's look at the REST API as a starting point.
You can get a list of groups and roles per USER using making a GET request to: https://graph.windows.net/myorganization/users/{user_id}/$links/memberOf?api-version
On success, returns a collection of links to the Group's and DirectoryRole's that this user is a member of
ref: Get a user's group and directory role memberships
To get the membership of a group you would make a GET request to: https://graph.windows.net/myorganization/groups/{object_id}/$links/members?api-version
ref: Get a group's direct members
However per the docs:
No functions or actions may be called on directory roles
ref: https://msdn.microsoft.com/en-us/Library/Azure/Ad/Graph/api/entity-and-complex-type-reference#DirectoryRoleEntity
This has to be done from the USER object. The SDK will reflect this.
IPagedCollection<IDirectoryObject> pagedCollection = retrievedUserFetcher.MemberOf.ExecuteAsync();
The GraphAPI console app has some great examples that should show you how to complete these actions: Program.cs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With