More in this section

Forums / General Discussions / Get sitefinity online user roles

Get sitefinity online user roles

9 posts, 0 answered
  1. sathiyaseelan
    sathiyaseelan avatar
    82 posts
    Registered:
    26 Aug 2008
    24 May 2011
    Link to this post
    Hi,

    I am using sitefinity 4. I have a custom control which needs to get the logged sitefinity user's role. for example if the role of the logged user is only "Editor" then I need to give permission to back end modules/pages otherwise I need to throw an alert message like "No permission to access this module/Page".

    How to get role of a online user who is logged to sitefinity??

    Thanks,
    sathya

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 May 2011
    Link to this post
    Hi sathiyaseelan,

    The RomeManager has a method FindRolesForUser that you can use.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. sathiyaseelan
    sathiyaseelan avatar
    82 posts
    Registered:
    26 Aug 2008
    24 May 2011
    Link to this post
    Hi,
        RoleManager has the method "GetRolesForUser" which gets the user id as parameter. Now how to get the user id of the logged user.

    Pls suggest..

    Thanks,
    sathya
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    24 May 2011
    Link to this post
    Hi sathiyaseelan,

    The Telerik.Sitefinity.Security.Model.User has a property IsLoggedIn that shows whether the user is online or not. You can get the currently logged in users by using

    UserActivityManager.GetManager().UserActivities().Where(ua =>
                                                                                        ua.IsLoggedIn == true &&
                                                                                        ua.IsBackendUser == false &&
                                                                                        ua.LastActivityDate > ExpiredSessionsLastLoginDate).ToList();

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. sathiyaseelan
    sathiyaseelan avatar
    82 posts
    Registered:
    26 Aug 2008
    25 May 2011
    Link to this post
    Hi,

    I am getting "UserActivityManager" does not exists in the current context. Am I missing any namespace. I included Telerik.Sitefinity.Security.Model; also still I am getting this error.

    Thanks,
    sathya
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    25 May 2011
    Link to this post
    Hi sathiyaseelan,

    It turned out that the class is internal and you cannot uses it.
    You can use GetLoggedInBackendUsers() method of SecurityManager that returns IList<User> from where you can get ProviderUserKey. SecurityManager has a method GetCurrentUserId() that returns directly the Id of the current logged in user.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Rafael
    Rafael avatar
    19 posts
    Registered:
    29 Jul 2011
    29 Jul 2011
    Link to this post
    My problem it's a little bit the same but i want use the method GetRoleForUser and i can't get the role. Please if someone know wich is the issue let me know
  8. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    02 Aug 2011
    Link to this post
    Hi Rafael,

    GetRolesForUser method returns all roles to which the user is assigned. If you want to get the user roles please check the video I created for you but please provide more information about the desired implementation.

    Greetings,
    Victor Velev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Rafael
    Rafael avatar
    19 posts
    Registered:
    29 Jul 2011
    10 Aug 2011
    Link to this post
    Thx that work
9 posts, 0 answered