London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
AI OnAI Off
London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
Solved it. I used the wrong SecuritySaveType on line 13. Should have been _securityRepository.Save(contentReference, folderSecurity, SecuritySaveType.Replace);
its working only for groups, not for individual user, any idea why its not working for users?
folderSecurity.AddEntry(new AccessControlEntry("daniel.ovaska", AccessLevel.Read, SecurityEntityType.User));
Need to change the type of SecurityEntityType above...
Is there a way to programmatically restrict access to a assets folder?
I have tried the following code, which didn't affect the access rights:
var folder = _repository.GetDefault<ContentFolder>(SiteDefinition.Current.GlobalAssetsRoot); folder.Name = "Restricted folder"; var contentReference = _repository.Save(folder, SaveAction.Publish, AccessLevel.NoAccess); var folderSecurity = _securityRepository.Get(contentReference).CreateWritableClone() as IContentSecurityDescriptor; if (folderSecurity != null) { if (folderSecurity.IsInherited) folderSecurity.ToLocal(); var webadminAccess = folderSecurity.Entries.SingleOrDefault(e => e.Name == "WebAdmins"); if (webadminAccess != null) folderSecurity.RemoveEntry(webadminAccess); folderSecurity.AddEntry(new AccessControlEntry("WebAdmins", AccessLevel.Read)); _securityRepository.Save(contentReference, folderSecurity, SecuritySaveType.ReplaceChildPermissions); }