Reputation: 7340
I want to use Sitecore security to make access to certain documents on a site require registration/login. However the client would like to show links to these documents to anonymous users as a way to let them know that if they register/login then they will get access to these protected documents.
Is there some simple way to do this in Sitecore? The only thing I can think of off the top of my head is to use some sort of Security Disabler to get the list of documents and display the links on the page.
Upvotes: 2
Views: 264
Reputation: 150
You could use the SecurityDisabler:
using (new SecurityDisabler())
{
//code to get links
}
Upvotes: 0
Reputation: 4456
As Thomas Therkildsen suggests, you can use the Security Disabler, although Sitecore's preferred method is to use a user switcher.
using (new Sitecore.Security.Accounts.UserSwitcher(userWithMoreRights))
{
// ...
}
SecurityDisabler
basically gives the code the right to do anything it wants, whereas UserSwitcher
is more restrictive.
See the Security API cookbook for more information.
Upvotes: 1