Link to home
Start Free TrialLog in
Avatar of Himanshu Barot
Himanshu Barot

asked on

Hooking into SharePoint server-side

Please note I am talking of injecting my code into SharePoint server-side (via a package / add-in etc) as opposed to using Microsoft.SharePoint.dll or web-services to access SharePoint.

So my problem is this, I need to customise how Document Libraries work, including custom permission management. I have been browsing through Microsoft.SharePoint.dll analysing the internals of its working. Here are my observations:

SPDocumentLibrary provides the core logic of managing a document library. However, its not a WebPart in itself.
The actual web part rendering for a Document Library probably is handled by ListViewWebPart or a derived class.
There's actually a SPPictureLibrary class which makes me assume it might be possible to inherit SPDocumentLibrary class to provide custom behaviour on a Document library.
WebPartAdder.SiteWebPartGalleryProvider in some way is connecting SPDocumentLibrary to its WebPart inside Microsoft.SharePoint.WebPartPages.WebPartAdder.AddSources method.
Now all this is client-side, none of this happens on SharePoint server itself (afaik). However I see overridable methods on SPSecurableObject that SPDocumentLibrary/SPList override, specifically:

CheckPermissions
GetUserEffectivePermissionInfo
GetUserEffectivePermissions
EffectiveBasePermissions, etc.
What I really want to do is be able to override CheckPermissions / EffectiveBasePermissions on a SPDocumentLibrary inside SharePoint server to inject my custom logic.

I would now divert my research to SharePoint server side dlls and understanding them. But I would love to get some expert opinion on whether this is feasible at all / pointed in the right direction. Microsoft's hallmark (especially considering ASP.NET 2.0 / ASP.NET MVC as a benchmark) is extensibility / provider framework. They provide excellent providers for "things" out of the box but you can create your classes by inheriting/implementing something to replace default providers. So:

1.)  Can I inject into SharePoint server-side. My ideal solution would be to create a SPDocumentLibrary derived class (server-side), and inject it in so that anytime a Document library is instantiated, my class object is created (instead of SPDocumentLibrary, assuming that's the class server-side too. I still need to "reflect" SharePoint server-side classes).

2.)  If 1) is a nopes, can I create a custom WebPart to use a SharePoint Document Library in a way where it gives a native Document Library feel, but still allow me to use a SPDocumentLibrary derived class when that web part is accessed (please again note, all my discussion is around SharePoint server-side, i.e. my code executing inside SharePoint's address space/w3wp process).

3.)  Why do we have logic in SPSite.EffectiveBasePermissions at all. I mean its supposed to be CSOM, and it should simply be responsible for serialization/deserialization of what is returned by/sent to server. However, I see elaborate logic in this overridden property revolving around permission deducing.

4.)  If both 1) and 2) is a no-op (literally :)), do I have any option manipulating SharePoint effective permissions while operating in SharePoint's address space before SharePoint takes any action based on those permissions.

I know its been a long question, but hopefully I am doing my research well.
Avatar of Himanshu Barot
Himanshu Barot

ASKER

SharePoint uses an "inclusive" permissions system. This means that the permissions are normally "additive". If a member belongs to two membergroups, and at least one of them is allowed to do something, then that member will be allowed to do that, even if the other membergroup is not allowed to do that thing.
https://wiki.simplemachines.org/smf/Disallow_and_Deny_-_What%27s_the_difference_when_it_comes_down_to_permissions

But I want to acchive something like this in SharePoint, A Deny Permission.

Please let me know for any query regarding the same.

https://social.msdn.microsoft.com/Forums/en-US/eea1b8f5-d22c-4748-8fc9-c5a2099d3f6f/hooking-into-sharepoint-serverside?forum=sharepointdevelopment&prof=required
ASKER CERTIFIED SOLUTION
Avatar of Walter Curtis
Walter Curtis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Information is accurate and should be seriously considered.