Access Permissions

Use the SettingsPermissions.AccessRules collection property to define access permissions for folders and files. A rule’s priority is determined by its index within the collection.

The AccessRules collection allows items of the following types:

Use an access rule object’s FileManagerAccessRuleBase.Path property to specify a file system path to which the rule is applied. To specify the permissions associated with the rule, use the following properties:

<dx:BootstrapFileManager runat="server" Height="480px">
    <Settings RootFolder="~/Content/FileManager/Files" ThumbnailFolder="~/Content/FileManager/Thumbnails" />
    <SettingsEditing AllowCreate="true" AllowDelete="true" AllowMove="true" AllowCopy="true" AllowRename="true"
        AllowDownload="true" TemporaryFolder="~/Content/FileManager/Temp" />
    <SettingsPermissions>
        <AccessRules>
            <dx:FileManagerFolderAccessRule Path="" Edit="Deny" />
            <dx:FileManagerFolderAccessRule Path="Images" EditContents="Allow" />
            <dx:FileManagerFileAccessRule Path="System\PasswordList.txt" Download="Deny" />
        </AccessRules>
    </SettingsPermissions>
</dx:BootstrapFileManager>

Roles

You can associate an access rule with a security role using the FileManagerAccessRuleBase.Role property. Any created role can be enforced on the control via its FileManagerSettingsPermissions.Role property. After that, the file manager will display the folder and files and provide access permissions to them, based on the assigned role.

In this demo, you can select one of the security roles from the control toolbar’s BootstrapFileManagerToolbarCustomDropDownButton item's drop-down menu (custom toolbar items are described in greater detail in the Custom Toolbar demo). The file and folder permissions granted to each role are listed below:

  • Default User - A user is allowed to browse folder content. All file/folder modifications or file uploads are prohibited. The System folder is hidden in a folder tree.
  • Document Manager - A user is allowed to browse folder content and perform file/folder operations (including file uploads) within the Documents folder only. All file/folder modifications or file uploads within other folders are prohibited. The System folder is hidden in a folder tree.
  • Media Moderator - A user is allowed to browse folder content and perform file/folder operations (including file uploads) within the Music and Video folders only. All file/folder modifications or file uploads within other folders are prohibited. The System folder is hidden in a folder tree.
  • Administrator - A user is allowed to browse folder content and perform file(except XML documents)/folder operations (including file uploads). The System folder is shown in a folder tree. This folder is also fully accessible for all file/folder modifications or file uploads.
<dx:BootstrapFileManager runat="server" ID="FileManagerRoles" Height="500px" OnCustomCallback="FileManagerRoles_CustomCallback">
    <Settings RootFolder="~/Content/FileManager/Files" ThumbnailFolder="~/Content/FileManager/Thumbnails" />
    <SettingsEditing AllowCreate="true" AllowDelete="true" AllowMove="true" AllowRename="true" />
    <ClientSideEvents CustomCommand="onCustomCommand" />
    <SettingsPermissions>
        <AccessRules>
            <dx:FileManagerFolderAccessRule Path="" Edit="Deny" />
            <dx:FileManagerFileAccessRule Path="*.xml" Edit="Deny" />
            <dx:FileManagerFolderAccessRule Path="System" Browse="Deny" />
            <dx:FileManagerFolderAccessRule Path="Documents" Role="DocumentManager" EditContents="Allow" />
            <dx:FileManagerFolderAccessRule Path="" Role="MediaModerator" Upload="Deny" />
            <dx:FileManagerFolderAccessRule Path="Music" Role="MediaModerator" EditContents="Allow" Upload="Allow" />
            <dx:FileManagerFolderAccessRule Path="Video" Role="MediaModerator" EditContents="Allow" Upload="Allow" />
            <dx:FileManagerFolderAccessRule Role="Administrator" Edit="Allow" Browse="Allow" />
        </AccessRules>
    </SettingsPermissions>
    <SettingsToolbar ShowPath="false">
        <Items>
            <dx:BootstrapFileManagerToolbarCustomDropDownButton IconCssClass="fa fa-user" Tooltip="Role">
                <Items>
                    <dx:BootstrapFileManagerToolbarCustomButton GroupName="Roles" Text="Default User" CommandName="DefaultUser" />
                    <dx:BootstrapFileManagerToolbarCustomButton GroupName="Roles" Text="Document Manager" CommandName="DocumentManager" />
                    <dx:BootstrapFileManagerToolbarCustomButton GroupName="Roles" Text="Media Moderator" CommandName="MediaModerator" />
                    <dx:BootstrapFileManagerToolbarCustomButton GroupName="Roles" Text="Administrator" CommandName="Administrator" />
                </Items>
            </dx:BootstrapFileManagerToolbarCustomDropDownButton>
            <dx:BootstrapFileManagerToolbarCreateButton />
            <dx:BootstrapFileManagerToolbarRenameButton />
            <dx:BootstrapFileManagerToolbarMoveButton />
            <dx:BootstrapFileManagerToolbarCopyButton />
            <dx:BootstrapFileManagerToolbarDeleteButton />
            <dx:BootstrapFileManagerToolbarRefreshButton />
        </Items>
    </SettingsToolbar>
</dx:BootstrapFileManager>
string Role {
    get {
        var currentValue = Convert.ToString(Session["FileManagerRole"]);
        return string.IsNullOrEmpty(currentValue) ? "DefaultUser" : currentValue; }
    set {
        FileManagerRoles.SettingsPermissions.Role = value;
        Session["FileManagerRole"] = value;
    }
}
protected void Page_Load(object sender, EventArgs e) {
    if(IsCallback)
        System.Threading.Thread.Sleep(1000);
    FileManagerRoles.SettingsPermissions.Role = Role;
    var rolesItem = FileManagerRoles.SettingsToolbar.Items[0] as BootstrapFileManagerToolbarCustomDropDownButton;
    (rolesItem.Items.FindByCommandName(Role) as BootstrapFileManagerToolbarCustomButton).Checked = true;
}
protected void FileManagerRoles_CustomCallback(object sender, DevExpress.Web.CallbackEventArgsBase e) {
    Role = e.Parameter.ToString();
}
function onCustomCommand(s, e) {
    if(e.commandName && e.commandName.length)
        s.PerformCallback(e.commandName);
}
Screen Size
Color Themes
Demo QR Code