Question

In javascript, I'm trying to get a list of all the groups to which a user belongs.

For the current user I can use SPServices + GetGroupCollectionFromUser. But for other users I would need the login name, which I don't have. I need to query by user name.

Is there an alternative to GetGroupCollectionFromUser that takes a user name? Or some other way to do this?

It doesn't have to be through SPServices, using the REST API is also fine.

Thanks!

Was it helpful?

Solution

If the REST API is acceptable, you can get the groups for a user by using their user name using the following query:

https://server/sites/site/_api/web/siteusers?$filter=Title eq 'The User Name'&$select=Title,Id,Groups/Title,Groups/Id&$expand=Groups

Obviously you can choose to return more information about the user or the groups by including more fields in the $select.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top