Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to list directory role members via SDK #2243

Open
Semptra opened this issue Dec 6, 2023 · 3 comments
Open

Add ability to list directory role members via SDK #2243

Semptra opened this issue Dec 6, 2023 · 3 comments

Comments

@Semptra
Copy link

Semptra commented Dec 6, 2023

Based on the Directory role - List members article, there is a possibility to query directory role members using roleTemplateId:

GET https://graph.microsoft.com/v1.0/directoryRoles(roleTemplateId='43a63cc2-582b-4d81-a79d-1591f91d5558')/members

However, Graph SDK only allows querying directory role members using the role id, not role template id:

var result = await graphClient.DirectoryRoles["{directoryRole-id}"].Members.GetAsync();

I suggest adding a feature to the SDK to allow getting the directory role members using the role template id.

@andrueastman
Copy link
Member

Thanks for raising this @Semptra

At the moment, you should be able to list the directory roles using the alternate key as below. You can then use the expand query parameter to get the members.

var directoryRole = await graphClient.DirectoryRolesWithRoleTemplateId("roleTemplateId").GetAsync( 
    requestConfig => requestConfig.QueryParameters.Expand = new []{"members"});
var membersList = directoryRole.Members;

We will need to investigate the adding of the navigation paths when alternate key to be tracked via microsoft/OpenAPI.NET.OData#459

@Semptra
Copy link
Author

Semptra commented Dec 6, 2023

Is it true that those 2 queries are identical?

  • /directoryRoles(roleTemplateId='{roleTemplateId}')?$expand=members
  • /directoryRoles(roleTemplateId='{roleTemplateId}')/members

Does the pagination work for the first request? I assume there might be some limitations with the approach that you've described, but thanks anyway.

@andrueastman
Copy link
Member

The alternative here would be to use the withUrl method on the members reqest builder as the first option would not support paging but return the result as a propert of the DirectoryRole response

var result = await graphClient.DirectoryRoles["{directoryRole-id}"].Members.WithUrl("https://graph.microsoft.com/v1.0/directoryRoles(roleTemplateId='43a63cc2-582b-4d81-a79d-1591f91d5558')/members").GetAsync();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants