Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a document in SharePoint. It is placed under a specific document set. I only have the full URL of the document. Now from a web service a user is requesting to update that particular document. How can I check the permission of that user on that document (Not on Document Set. Because the user may not have permission to the document set but only to the document)? From the document URL I have instantiate a SPFile object. Do I need to cast it to a ListItem and then apply DoesUserHavePermission method? I have not found any permission checking related properties in SPFile object. Please suggest.
Posted

1 solution

With your thinking you do about this problem, my advice may seem to be weird to you, but please try to think about it, as it can really help you.

Here is the thing: why do you think you should ever check up the permissions? In most of application code, such things are clearly out of the scope. First of all, you should avoid using random directories and use only those specially designed for user data reserved per account.

But main thing is completely different. Many students these days are taught defensive programming: before doing something, check up if you can do it. In many cases, this should be done, and, in many other cases, this is quite wrong, obsolete and inefficient approach. Very often, programming should be offensive: just do the operation, don't ask if you can. You can always execute code under try-catch (and most usually you should), let the exception propagate and eventually handle it. If exception was thrown due to access violation and caught, you don't have the excess. Isn't that simple?

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900