I have created a dynamic type module using the module builder and set the security permissions (from backend) to view that type as "Administrators only". The purpose is to restrict the content viewable on the frontend to specific users.
To further secure the content, I am customizing the search results to return only those items which the user has permission to view. I am basing my custom module on this extension of the searchresults module: http://www.sitefinity.com/blogs/veselin-vasilev-blog/2013/03/18/trim-the-search-results-based-on-permissions-roles.
I would like to do the same but for dynamic module content items (i.e. the module I created in module builder) - how do I do that?
I don't care about individual items; what I would like to secure the entire type by checking if the current user has permissions to view that specific dynamic type (i.e. check permissions for current user for type "Telerik.Sitefinity.DynamicTypes.Model.X").
Thanks for your input/help.
hasAccess = CheckForPermissionsForUser(
var manager = ModuleBuilderManager.GetManager();
Type contentType = TypeResolutionService.ResolveType(
var item = manager.Provider.GetDynamicModuleTypes()
.Where(t => t.TypeName == contentType.Name && t.TypeNamespace == contentType.Namespace).Single();
UserManager usersManager = UserManager.GetManager();
Guid users =
Guid usersManager.GetUser(userName).Id ;
Your answer was great except for the line
as it always returned 'false'; I think the SetName ("General") was not correct for module builder types, or at least, in my case it was not. Instead, I changed it to:
which gave me what I wanted.
Thanks for your help!
Ok, think I figured it out. The problem is the Guid parameter. If that is supplied, then the code checks if their is a permission assigned DIRECTLY to that user. If it sent as null then the code checks the roles for the permission and user. WTF?
so, this worked for me
item.IsGranted(SecurityConstants.Sets.General.SetName, (Guid) null, "View");