locked
Get list of users belonging to a security role - CRM 2011 RRS feed

  • Question

  • Hi

    How can I retrieve the users belonging to a security role in a plugin. Googling didn't help much. Thanks

    Thursday, January 26, 2012 12:58 AM

Answers

  • There are 2 poosible approaches:

    1. Use a FetchExpression, where the entity you retrieve is the systemuserroles entity. This can be filtered by roleid, and could return the systemuserid for each user in the role
    2. Use a QueryExpression. You can't use a QueryExpression directly on the systemuserroles entity, but you could write a QueryExpression on the systemuser entity, and have a LinkEntity to the systemuserroles entity

    Although the folowing was written for CRM, it shows the data structures involved - http://msdn.microsoft.com/en-us/library/cc151188.aspx 


    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk
    Thursday, January 26, 2012 6:11 AM
    Moderator

All replies

  • There are 2 poosible approaches:

    1. Use a FetchExpression, where the entity you retrieve is the systemuserroles entity. This can be filtered by roleid, and could return the systemuserid for each user in the role
    2. Use a QueryExpression. You can't use a QueryExpression directly on the systemuserroles entity, but you could write a QueryExpression on the systemuser entity, and have a LinkEntity to the systemuserroles entity

    Although the folowing was written for CRM, it shows the data structures involved - http://msdn.microsoft.com/en-us/library/cc151188.aspx 


    Microsoft CRM MVP - http://mscrmuk.blogspot.com  http://www.excitation.co.uk
    Thursday, January 26, 2012 6:11 AM
    Moderator
  • Thanks David. I'll google for the second approach.
    Thursday, January 26, 2012 10:21 PM
  • Hi,

    You can use query expression like below:

    Here, You can put the condition to fetch the users which are belogns to the security group!

    • Proposed as answer by RajivCRM Thursday, October 25, 2012 1:16 PM
    Monday, October 22, 2012 11:37 AM