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...
Thanks Daniel Ovaska, this fixes my issue.
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: