Get sitefinity online user roles
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
Hi sathiyaseelan,
The RomeManager has a method FindRolesForUser that you can use.
Regards,
Ivan Dimitrov
the Telerik team
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
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
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
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
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
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
Thx that work