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 want add file and folder in tree view control for specific user if he has permission to access that file and folder. I want to get permission of file or folder to check current user can access that file or folder in share point client object model.

share|improve this question

1 Answer 1

To check permissions to a list or library:

list.DoesUserHavePermissions(user, SPBasePermissions.AddListItems);

To check a list item its the same

item.DoesUserHavePermissions(user, SPBasePermissions.AddListItems)

To check a folder you do the check in the list item object of the folder:

folder.Item.DoesUserHavePermissions(user, SPBasePermissions.AddListItems)

Replace .AddListItems with .Open if you just want to check if they have read rights.

If you want to get the current user before elevating you code and iterating through content then the command is:

SPUser user = SPContext.Current.Web.CurrentUser;
share|improve this answer

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.