SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have used following code to check if a user has "Read" Permission Levels on Root Web of a site

if (site.RootWeb.DoesUserHavePermissions(SPBasePermissions.ViewPages))
    render root web url;                            
    render public url

but it renders root web url för current user without having permissions att all. and when he clicks on the url he gets access denied .... error message.

share|improve this question
up vote 1 down vote accepted

I would try it using SPBasePermissions.Open instead of SPBasePermissions.ViewPages. If you have anonymous authentication enabled, that may be the reason for this.

Here is a description of all of the options: SPBasePermissions Enumeration

share|improve this answer
Thank you, There is no anonymous policy on Web Application level. and I have changed to SPBasePermissions.Open but still it returns true. – Medes Sep 24 '12 at 6:57
I have created a Content Database for each Site Collection. Can it be the reason that DoesUserHavePermissions returns true always? – Medes Sep 24 '12 at 7:10
I found what was the problem I had used RunWithElevatedPrivileges which used system user. I solved it like this RootWeb.DoesUserHavePermissions(currentUser.LoginName, SPBasePermissions.Open) – Medes Sep 24 '12 at 9:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.