Tab

FileManagerAccessRuleBase.Role Property

Gets or sets a security role that is assigned the current rule.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v21.1.dll

Declaration

[DefaultValue("")]
public string Role { get; set; }

Property Value

Type Default Description
String

String.Empty

A String value specifying a role name.

Remarks

ASPxFileManager allows you to define access permissions for folders and files using a set of file/folder access rules (FileManagerSettingsPermissions.AccessRules). An access rule specifies a path to which it is applied and lists permissions (allowed or denied actions) associated with this rule. To associate an access rule with a security role, assign the role’s name to the rule’s Role property.

Any created role can be enforced on the ASPxFileManager 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.

NOTE

If the Role property value is empty, the access rule is applied to all roles.

Concept

Example

Web Forms (declaratively):

<dx:ASPxFileManager ID="ASPxFileManager1" runat="server">    
    <SettingsPermissions>
        <AccessRules>
            <dx:FileManagerFileAccessRule Edit="Deny" Browse="Allow" Path="*.docx" />
            <dx:FileManagerFolderAccessRule Role="Administrator"  EditContents="Allow" Browse="Allow" Path="Documents" />
        </AccessRules>
    </SettingsPermissions>
</dx:ASPxFileManager>

Web Forms (in code):

ASPxFileManager fm = new ASPxFileManager();
...
FileManagerFileAccessRule fileRule = new FileManagerFileAccessRule();
fileRule.Path = "*.docx";
fileRule.Edit = Rights.Allow;
fileRule.Download = Rights.Allow;

FileManagerFolderAccessRule folderRule= new FileManagerFolderAccessRule();
folderRule.Role = "Administrator";
folderRule.EditContents = Rights.Allow;
folderRule.Browse = Rights.Allow;

FileManager.SettingsPermissions.AccessRules.Add(fileRule);
FileManager.SettingsPermissions.AccessRules.Add(folderRule);
...

MVC:

@Html.DevExpress().FileManager( settings => {
    settings.Name = "fileManager";

    FileManagerFileAccessRule fileRule = new FileManagerFileAccessRule();
    fileRule.Path = "*.docx";
    fileRule.Edit = Rights.Allow;
    fileRule.Download = Rights.Allow;

    FileManagerFolderAccessRule folderRule= new FileManagerFolderAccessRule();
    folderRule.Role = "Administrator";
    folderRule.EditContents = Rights.Allow;
    folderRule.Browse = Rights.Allow;

    FileManager.SettingsPermissions.AccessRules.Add(fileRule);
    FileManager.SettingsPermissions.AccessRules.Add(folderRule);
    ...
}).BindToFolder(Model).GetHtml()

Online Demo

Example

<dx:ASPxRadioButtonList ID="rblRole" runat="server" AutoPostBack="true" SelectedIndex="0"  OnValueChanged="rblRole_ValueChanged">
        <Items>
            <dx:ListEditItem Text="Default User" Value="" Selected="True" />
            <dx:ListEditItem Text="Document Manager" Value="DocumentManager" />
            <dx:ListEditItem Text="Media Moderator" Value="MediaModerator" />
            <dx:ListEditItem Text="Administrator" Value="Administrator" />
        </Items>
</dx:ASPxRadioButtonList>

<dx:ASPxFileManager ID="FileManager" runat="server" ...>

     ...

     <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="Music" Role="MediaModerator" EditContents="Allow" />
               <dx:FileManagerFolderAccessRule Path="Video" Role="MediaModerator" EditContents="Allow" />
               <dx:FileManagerFolderAccessRule Path="" Role="MediaModerator" Upload="Deny" />

               <dx:FileManagerFolderAccessRule Role="Administrator" Edit="Allow" Browse="Allow" />
          </AccessRules>
     </SettingsPermissions>
</dx:ASPxFileManager>
protected void rblRole_ValueChanged(object sender, EventArgs e) {
     FileManager.SettingsPermissions.Role = (string)rblRole.Value;
}
See Also