Search code examples
dynamics-crmcrmdynamics-crm-onlinedynamics-crm-2013

How to Get Security Roles of Another User in CRM 2013 Using Javascript


Getting current (logged) user security roles from the context is trivial:

Xrm.Page.context.getUserRoles()

But I can't find an answer how to get the roles for another user by Id or Name? (Different from the user who is logged on currently)


Solution

  • You can use odata to get roles assigned to user:

    http://<server>/<org>/xrmservices/2011/OrganizationData.svc/SystemUserRolesSet?$filter=SystemUserId eq guid'<user guid>'
    

    in similar way you possibly want to check for roles assigned to teams that user belongs to