Domanda

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!

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top