Get sitefinity online user roles

Posted by Community Admin on 03-Aug-2018 10:57

Get sitefinity online user roles

All Replies

Posted by Community Admin on 24-May-2011 00:00

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

Posted by Community Admin on 24-May-2011 00:00

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

Posted by Community Admin on 24-May-2011 00:00

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

Posted by Community Admin on 24-May-2011 00:00

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

Posted by Community Admin on 25-May-2011 00:00

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

Posted by Community Admin on 25-May-2011 00:00

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

Posted by Community Admin on 29-Jul-2011 00:00

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

Posted by Community Admin on 02-Aug-2011 00:00

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

Posted by Community Admin on 10-Aug-2011 00:00

Thx that work

This thread is closed