November Happy Hour will be moved to Thursday December 5th.

Search for Users who have access to a specific page

Vote:
 

Hi,

 Given a page reference, what would be the best way to search for users who have access to that page?

 Many thanks

 Matt

#27912
Feb 12, 2009 16:40
Vote:
 
Something like this might work, havent tested it thoroughly though:

EPiServer.Security.

AccessLevel requestedLevel = AccessLevel.Publish; 

PageData pd = DataFactory.Instance.GetPage(PageReference.StartPage);

HashSet<string> users = new HashSet<string>();

 

foreach( string key in pd.ACL.Keys )

{

AccessControlEntry ace = pd.ACL[key];

if(0 == (ace.Access & requestedLevel))

continue;

 

if(ace.EntityType==SecurityEntityType.Role)

{

foreach(string user in Roles.GetUsersInRole(ace.Name))

users.Add(user);

}

else users.Add(ace.Name);

}

/johan
#27913
Feb 12, 2009 17:28
Vote:
 

It would, except I'm reusing the Workrooms demo template which assigns access right for a user directly on the page (ie it's not based on a role)

Many thanks

Matt

#27914
Feb 12, 2009 18:10
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.