I'm creating a news item through the api and in the same process assign view permission only to certain roles.
I've managed to break the inheritance and assign the correct view permission but I'm unable to remove the permission for "Everyone" through the api...
It seems that if I use:
var everyonePermission = newsManager.GetPermission(SecurityConstants.Sets.General.SetName, newsItem.Id,
It returns null. So if I then create the permission for everyone and ungrant access to view the item it throws and exception saying that it can't create a duplicate key in the sf_permissions index which means that this permission must already exist.
I've tried this at various points in the lifecycle of creating the news item, before and after publishing it, using the master item. All to no avail.
So my question is: how do you possibly remove the Everyone view permission?