Best practice to set up folder permissions

Hi team,

Currently, I have almost 12,000 folders and different roles and I need to set up permissions, how is the best practice to do that? I created an object:

List rules = new List();

and I add all the folders with each permission depending on the role but when I assign it:

accessDetails.AccessRules = rules;

Take a lot of time to load the file manager.


This is the code that I am using:

AccessDetails accessDetails = new AccessDetails();

List<AccessRule> rules = new List<AccessRule>();

  foreach (var item in listFolder)

                {

                    foreach (var item2 in roles)

                    {

                        foreach (var item3 in folderPermissions)

                        {

                            pathFolder = string.Format(@"\{0}\{1}", item, item3.TBL_FOLDERS.FODER_NAME);

                            rules.Add(new AccessRule

                            {

                                Path = pathFolder,

                                Role = item2.Name,

                                Read = item3.READ,

                                Write = item3.WRITE,

                                Copy = item3.COPY,

                                Upload = item3.UPLOAD,

                                Download = item3.DOWNLOAD,

                                IsFile = false

                            });

                        }


                    }

                }

            accessDetails.AccessRules = rules;

            accessDetails.Role = "Admin";

            return accessDetails;

Thanks,


1 Reply

SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team January 12, 2022 01:39 PM UTC

Hi Daniel, 
 
Greetings from Syncfusion support. 
 
In FileManager component, we have provided access control support. Using this functionality support, you can manage access to your file system based on the user role. 
Refer the following link to know about access control support in File Manager. 
 
For your reference, we have prepared access control sample for FileManager component.  
 
You can set the rules for FileManager component using SetRules method. Refer the below code snippet.  
  
public DefaultController(IHostingEnvironment hostingEnvironment)  
        {  
            this.basePath = hostingEnvironment.ContentRootPath;  
            this.operation = new PhysicalFileProvider();  
            this.operation.RootFolder(this.basePath + "\\" + this.root);  
            // Set Rules for FileManager component.  
            this.operation.SetRules(GetRules());  
        }  
  
Refer the below code snippet to prevent the access from particular folder.  
 
  public AccessDetails GetRules()  
        {  
            AccessDetails accessDetails = new AccessDetails();  
  
            List<AccessRule> folderRule = new List<AccessRule> {  
                // For Default User           
                new AccessRule { Path = "/Downloads", Role = "Document Manager", Read = Permission.Deny, Write = Permission.Deny, Copy = Permission.Allow, WriteContents = Permission.Allow, Upload = Permission.Allow, Download = Permission.Deny },  
            };  
            accessDetails.AccessRules = folderRule;  
            accessDetails.Role = "Document Manager";  
            return accessDetails;  
        }  
 
Refer the below sample below.  
 
 
Refer the below similar forum link. 
Please, get back to us if you need any further assistance. 
 
Regards, 
Shameer Ali Baig S. 
 


Loader.
Up arrow icon