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
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,
|
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());
} |
|
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;
} |