Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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;                            
 }
 else
 {
    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
add comment

1 Answer 1

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
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 Sep 24 '12 at 9:58
add comment

Your Answer

 
discard

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.