Search code examples
c#sitefinity

Sitefinity Retrieve All User and Roles from Database


I know that we can retrieve list of user by using Sitefinity's UserManager class as explained in this documentation. However, i'm in a dire need to retrieve list of all user and roles using plain SQL which so far i had no success - my superior did not want to use a dummy page to list all user and roles. The only relation i can find is the ownership of a page and it's permission - that end up to roles. But i can't find a direct link from user to roles.

Anyway, i'm using Sitefinity 7.3, please give some insight..


Solution

  • Something like this should do the trick:

    select user_name, r.nme as Role, *
    from sf_users as u
    join sf_user_link as ul
    on u.id = ul.user_id
    join sf_roles as r
    on r.id = ul.role_id
    order by u.user_name