Access Permissions

Use the SettingsPermissions.AccessRules collection property to define access permissions for folders and files. Access rules are applied in the order they are defined in the collection. A rule with a higher index in the collection has a higher priority and can override the effect of a preceding rule.

The AccessRules collection allows items of the following types:

Use a folder access rule object's FileManagerFolderAccessRule.Path property to specify a path to a folder to which the rule is applied.

A file access rule object's FileManagerFileAccessRule.PathPattern property specifies a pattern that can match multiple file paths. This pattern can contain a wildcard character (*) that denotes any sequence of characters.

<dx:BootstrapFileManager runat="server" Height="480px">
    <SettingsFileList>
        <ThumbnailsViewSettings ThumbnailWidth="48" ThumbnailHeight="48" />
    </SettingsFileList>
    <SettingsAdaptivity Enabled="true" CollapseFolderContainerAtWindowInnerWidth="991" />
    <SettingsToolbar ShowPath="false" />
    <SettingsBreadcrumbs Visible="true" />
    <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 PathPattern="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">
    <SettingsFileList>
        <ThumbnailsViewSettings ThumbnailWidth="48" ThumbnailHeight="48" />
    </SettingsFileList>
    <SettingsAdaptivity Enabled="true" CollapseFolderContainerAtWindowInnerWidth="991" />
    <SettingsBreadcrumbs Visible="true" />
    <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 PathPattern="*.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" />
            <dx:FileManagerFolderAccessRule Path="Music" Role="MediaModerator" Upload="Allow" />
            <dx:FileManagerFolderAccessRule Path="Video" Role="MediaModerator" EditContents="Allow" />
            <dx:FileManagerFolderAccessRule Path="Video" Role="MediaModerator" Upload="Allow" />
            <dx:FileManagerFolderAccessRule Role="Administrator" Edit="Allow" />
            <dx:FileManagerFolderAccessRule Role="Administrator" 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