How do I figure out the role(s) of a user in a site using the webservices API? All I have to go on is the username and domain.
I've found that the PermissionsService.Permissions.GetPermissionCollection(url,"Web") will return a collection of permitted users and groups with their permissions masks but I still need to figure out if the user is in any of the groups and then convert the permissions masks into a roles collection.
I feel like there's a better way to do this and I'm just missing it.
In this blog post I use the UserGroup web service to list the SharePoint groups a user belongs to: http://www.theblackknightsings.com/ListAllSharePointGroupsAUserBelongsTo.aspx
Try using the GetRoleCollectionFromUser method from the UserGroup web service, It'll give you the list of the roles to which the user belongs in your site.
Just call it passing as a parameter your domain\userName.
Find its definition here: http://msdn.microsoft.com/en-us/library/ms772680.aspx
The returned xml will be something like the following, then you just get the info you need.
I've solved something similar - my method checks if user is assigned a specific role. Here's the algorithm first:
And the code:
Method parameter userLoginName should be in a form domain\username, e.g. SHAREPOINT\Boris. I hope I helped. Cheers