Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesC# Create Secure Folders and Set PermissionsC# Create Secure Folders and Set Permissions
Previous
 
Next
New Post
10/26/2017 1:20 PM
 

I am building a custom module and as part of the installation I'd like to create a set of secure folders in the portal directory. I have used code from previous questions to create the folder, but then the problem arises when I try to set the permissions.

I am creating a folder like so:

var portalSettings = PortalController.Instance.GetCurrentPortalSettings(); var folderMapping = FolderMappingController.Instance.GetFolderMapping(portalSettings.PortalId, "Secure"); var folder = FolderManager.Instance.AddFolder(new FolderMappingInfo { FolderProviderType = folderMapping.FolderProviderType, FolderMappingID = folderMapping.FolderMappingID, Priority = folderMapping.Priority, PortalID = portalSettings.PortalId, }, folderPath);

To set permissions, it seems that the FolderPermissionController has been deprecated and replaced with the new FolderManager provider. However, the FolderManager provider only has a SetFolderPermission method to create new permissions and one to AddAllUserReadPermission, but not one to remove any permissions.

After I create the folder, I give registered users view permissions like so:

var permissionController = new PermissionController(); var readPermission = permissionController.GetPermissionByCodeAndKey("SYSTEM_FOLDER", "READ").Cast ().Single(); var registeredUserRole = new RoleController().GetRoleByName(folder.PortalID, "Registered Users"); var allUserRole = new RoleController().GetRoleByName(folder.PortalID, "All Users"); FolderManager.Instance.SetFolderPermission(folder, readPermission.PermissionID, registeredUserRole.RoleID);

But I can't seem to remove permissions, and the default seems to add view permissions to ALL USERS when the folder is created. So I tried something like this that didn't work:

FolderManager.Instance.SetFolderPermission(folder, -1, allUserRole.RoleID);

When I try and use the deprecated FolderPermissionController to add or remove any permissions, it doesn't make any changes.

So, in short, what interface should be used to change folder permissions and how can you remove permissions for secure and regular folders?

 
New Post
11/12/2017 2:04 AM
 
are you talking about permission for the folder of your module in /desktopmodules/ or a folder inside /portals/[n] structure?

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
11/20/2017 3:11 PM
 

 

Hi Sebastian, thanks for following up! I am trying to have the installation of the module create secure folders to store uploads. I will be creating them in the portals folder, but they could also be placed in the DesktopModule folder as well, but there likely shouldn't be a difference since the API would ideally allow you to specify the location.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesC# Create Secure Folders and Set PermissionsC# Create Secure Folders and Set Permissions


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out