How to correctly use okta-sdk-dotnet ListUserGroups method?

https://developer.okta.com/okta-sdk-dotnet/latest/api/Okta.Sdk.IUsersClient.html#Okta_Sdk_IUsersClient_ListUserGroups_System_String_System_String_System_Nullable_System_Int32__

This link takes you to the Okta SDK IUsersClient method ListUserGroups. I have a user ID that I am passing into the method but I’m not sure what to do with what is being returned. Example:

ICollectionClient<IGroup> oktaGroups = client.Users.ListUserGroups(oktaUserId);

What do I do with oktaGroups after the method runs in order to get the names of the groups?

Hi @npaulson

You can use something like the following to list the group names.

var grps = client.Users.ListUserGroups("00uozbgc03wzqoaXp2p6").ToEnumerable();


foreach(var grp in grps)
{
	Console.WriteLine(grp.Profile.Name);
}

Thanks for that, I haven’t used ToEnumerable before so I wasn’t sure what to do with it.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.