.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Check User Permission on Web in SharePoint

Posted By:Jean Paul       Posted Date: March 28, 2014    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article I would like to explore multiple ways to check User Permissions on a web object in SharePoint

In this article I would like to explore multiple ways to check User Permissions on a web object.


We need to check whether a particular user have Open permission on a web object.


We can use the web.DoesUserHavePermissions() method for this purpose.


The method has 2 overloads, but we are using the second one which takes login as argument. The second argument SPBasePermissions can be used to specify type of permission.



For testing purpose create a console application, add reference to SharePoint DLLS & change following project properties:

1. Target Framework to .Net 3.5

2. Platform Target to Any CPU

Place the following code in the main method:

using (SPSite site = new SPSite("http://localhost"))


using (SPWeb web = site.OpenWeb())


bool result = web.DoesUserHavePermissions("DOM\USR", SPBasePermissions.Open);





Please use the appropriate user names in the code.


For the above site, assign a user with Read Permission. Execute code & you will get the result TRUE.

Now, remove the user from all permissions, including Authenticated users. You will get the result FALSE.

Although the above method was invoked using SPWeb object, we can invoke it from SPList, SPItem as well. In general the method is available for all SPSecurableObject type.

1. SPWeb inherits from SPSecurableObject

2. SPList inherits from SPSecurableObject

3. SPListItem inherits from SPSecurableObject




In this article we have explored how to check User Permissions on a particular web object. In real world scenario we need the method for scenarios like custom branding, custom event etc.v

 Subscribe to Articles


Further Readings:

Author: abhays         Company URL: http://www.dotnetspark.com
Posted Date: March 29, 2014

Is it working on both SP 2010 and 2013?

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend