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.

1 Answer 1


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

  • Thank you, There is no anonymous policy on Web Application level. and I have changed to SPBasePermissions.Open but still it returns true.
    – Medes
    Commented Sep 24, 2012 at 6:57
  • I have created a Content Database for each Site Collection. Can it be the reason that DoesUserHavePermissions returns true always?
    – Medes
    Commented Sep 24, 2012 at 7:10
  • 1
    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
    Commented Sep 24, 2012 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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