I have created an account and assigned full access to it for the whole tree. When I try to use that account programmatically in a scheduled job by calling
PrincipalInfo.CurrentPrincipal = PrincipalInfo.CreatePrincipal(ConfigurationManager.AppSettings["ScheduledJob.AdminUser"]);
I get an exception
Access was denied to content X. The current user does not have sufficient rights to delete the page with id X.
while I try to call _contentRepository.MoveToWastebasket(content.ContentLink). But when I manually log in the edit mode with the same account, I have no problems with moving content to waste basket.
How should I use the account in order to be able to move content to the waste basket programmatically?
Does it work if you set Thread.CurrentPrincipal ?
It seems to be working! Thanks!
Any special permissions are required to delete media? I still get that exception when I try to move an image to the waste basket...
I was being glad too early... I am still experiencing the exception...
Moving media to the waste basket is a bit different.
_contentRepository.Delete(content.ContentLink, false, AccessLevel.NoAccess);
The same code can be used for all content types.
I see. I will try with skipping the waste basket.
It seems to be working but I'm still testing. One question though. Do I still need to set a principal if I skip moving to the waste basket?
this should help
_contentRepository.Move(existingPersonPage.ContentLink, ContentReference.WasteBasket, AccessLevel.NoAccess, AccessLevel.NoAccess);