英文:
Microsoft Graph Get list of groups with display name
问题
I need to return DisplayName as well as the id, how do I do this? 我需要同时返回DisplayName和ID,我该怎么做?
英文:
I am trying to get the group membership of a service principal using client credential flow. I have the following code:
var graphServiceClient = new Microsoft.Graph.GraphServiceClient(new Microsoft.Graph.DelegateAuthenticationProvider(async (requestMessage) =>
{
var authResult = await _confidentialClientApp.AcquireTokenForClient(new string[] { "https://graph.microsoft.com/.default" }).ExecuteAsync();
requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", authResult.AccessToken);
}));
var groupMembership = await graphServiceClient.ServicePrincipals[userData.UniqueId].MemberOf.Request().GetAsync();
This returns:
groupMembership.CurrentPage[0].Id but none of the other properties are filled including the one I am interested in groupMembership.CurrentPage[0].DisplayName
I need to return DisplayName as well as the id, how do I do this?
答案1
得分: 0
解决方法是给应用程序注册授予Group.Read.All权限,然后显示名称将填充在groupMembership中。
英文:
It turns out the solution was to give the app registration the permission of Group.Read.All and then display name was populated in groupMembership
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论