Skip to content

Instantly share code, notes, and snippets.

@maisarissi
Last active December 7, 2023 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maisarissi/f9a6825cd51abc5128049af1b4a805fb to your computer and use it in GitHub Desktop.
Save maisarissi/f9a6825cd51abc5128049af1b4a805fb to your computer and use it in GitHub Desktop.
msgraph-dotnet-v5-ga-odata-cast
//Fetching the members of a group who are of the type User
var usersInGroup = await graphServiceClient
    .Groups["group-id"]
    .Members
    .GraphUser //cast to User
    .GetAsync();
List<User> userList = usersInGroup.Value;
//Similarly, members of the group of type ServicePrincipal
var servicePrincipalsInGroup = await graphServiceClient
    .Groups["group-id"]
    .Members
    .GraphServicePrincipal //cast to ServicePrincipal
    .GetAsync();
List<ServicePrincipal> servicePrincipalList = servicePrincipalsInGroup.Value;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment