nickornotto
nickornotto

Reputation: 2156

Get roles of page with role based protection

What's the current alternative to umbraco.cms.businesslogic.web.Access.GetAccessingMembershipRoles? Because umbraco 7.6 highlights it as obsolete and tells to use IPublicAccessService

I was unable to find out how to use it though, all I got to was

IContent content = GetById(id);
Attempt<PublicAccessEntry> access = _publicAccessService.IsProtected(content);

which doesn't have any information about the current page roles.

Upvotes: 1

Views: 546

Answers (1)

Nurhak Kaya
Nurhak Kaya

Reputation: 1781

This is how you do it;

IContent content = GetById(id);
var publicAccessService = ApplicationContext.Current.Services.PublicAccessService;
var entryForContent = publicAccessService.GetEntryForContent(content);

You will see that entryForContent result has got Rules and this is what you need. See details below;

enter image description here

enter image description here

Upvotes: 5

Related Questions