in Projects

Item Level Permission for Document Libraries – Release v1.0.0.0

 

[There is currently some problem with CodePlex and I am not able to upload my files or source code in my CodePlex project. This project will be eventually moved to CodePlex soon.]

This project is now available at CodePlex – http://ilp.codeplex.com 

——————————————————————————————–

——————————————————————————————–

ILP enables item-level permission for document libraries and also allows users to select a set of default permissions that can be applied to the new items and existing items in the document library.

Installation

Execute the install.bat to install. You will be prompted for two Urls – Web Application Url and Web Url.

ILP for Document Libraries will be activated in the Web Url you specify above. So in my above example screenshot, the ILP will be available for the root web / in the http:/sample web application.

How to activate for any other web?

Go to the Site Settings for your web and click on Site Features.


Activate the ILP:Item level permission library settings feature

ilp_feature_activate

Once activated, ILP will be available to that web.

To uninstall, execute the un-install.bat script.

Usage

You can locate the Item-level permissions for the document library in the document library’s Settings Page under the Permissions and Management tab

ilp_settings

Click on the Item-level permissions for this document library to open the item-level permissions page

ilp_documents_settings_page

You can now specify your options

  • Require new items to inherit parent permissions?
    • Choosing Yes will enable item-level permission for this document library
    • Choosing No will disable item-level permission for this document library.
  • Default Permission Levels
    • Any additional permissions you might like to give to the new items
    • Choose a Permission Level and then select the groups. Groups == SharePoint Groups.
    • If left empty, nothing happens.
  • Permissions to existing items
    • This helps to update the existing items in the list.
    • If ILP is enabled
      • Choosing Yes will set ILP for existing items in the document library, inherit parent permissions and also apply any default permission levels (chosen in Step 2, if any).
      • Choosing No will not modify existing items in the document library.
    • If ILP is not enabled
      • Choosing Yes will disable ILP for existing items in the document library and copies the parent permissions back.
      • Choosing No will not modify existing items in the document library.

 

 

 

 

Developers, Developers, Developers – ILP API

If you are a devleoper and want to consume the ILP API, you can do so.

Download the latest ilp_api_{version}.zip. Unzip and add reference to the the Chaks.SharePoint.Docs.ILP.dll in your project

You can now use the Extension method EnableItemLevelPermissions on the SPList object.

Below is the declaration of the EnableItemLevelPermissions method:

ilp_enableitemlevelpermissions

It accepts ItemLevelPermissionSettings as the only parameter

ilp_itemlevelpermissionsettings

  • EnableItemLevelPermissions
    • Specify whether to enable ILP or not
  • DefaultGroups
    • List of default SharePoint groups you want to apply to the items
  • DefaultPermissionLevel
    • The default permission level you want to apply to the items
  • ApplyToExistingItems
    • Specify whether to apply the changes to the existing items or not

You can safely ignore EventReceiverAssembly and EventReceiverClass as it is internally used by the ILP to hook to the proper event receiver. From next release onwards, developers will be able to hook up to their own event receivers using these two peoperties.

Using the API

Below are some code samples on using the API

 

 

using Chaks.SharePoint.Docs.ILP;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite spSite = new SPSite("http://sample"))
            {
                using (SPWeb spWeb = spSite.RootWeb)
                {
                    SPList imagesList = spWeb.Lists["Site Collection Images"];

                    List<SPGroup> spGroups = new List<SPGroup>();
                    spGroups.Add(spWeb.SiteGroups[1]);
                    spGroups.Add(spWeb.SiteGroups[2]);

                    ItemLevelPermissionSettings settings = new ItemLevelPermissionSettings
                                                               {
                                                                   EnableItemLevelPermissions = true,
                                                                   DefaultPermissionLevel = spWeb.RoleDefinitions["Full Control"],
                                                                   DefaultGroups = spGroups,
                                                                   ApplyToExistingItems = true
                                                               };

                    imagesList.EnableItemLevelPermissions(settings);

                    Console.WriteLine("Permissions applied....Press any key to continue");
                }
            }

            Console.ReadKey();
        }
    }
}

You can pass null if you dont intend to apply any default permission level and default groups

ItemLevelPermissionSettings settings = new ItemLevelPermissionSettings
{
     EnableItemLevelPermissions = true,
     DefaultPermissionLevel = null;
     DefaultGroups = null;
     ApplyToExistingItems = true
};

Note

Even though ILP for Document Libraries is meant only for Document Libraries (as the same suggests), using the API, you can also apply it to a SharePoint List.Please note that, it does not override the SharePoint out of the box Permissions settings and thus if you have already set up unique permissions for a SharePoint list, they will also be applied along with the ILP settings.

Downloads

Write a Comment

Comment


three × = 15

  1. Thanks for taking the time to develop this. I ran into an issue though. Once installed and activated, I click on "Item-level permission settings for this document library" in doc library settings, it displays "Error, file not found".

    After when I uninstall it, it says "failed to find the XML file at the location ’12templatefeatureILP …feature.xml"

    Any thoughts or help to get this working?

  2. Hi,
    please could you provide a short description, how your implementation is working? What is the main idea behind that mechanism?
    That saves the community time to go through the code.

    Thanks