1

I want set permission file or folder to nobody can access it. how to deny all users or groups to access any file and folder of document library in share point 2010 ?

2 Answers 2

1

In case you do not have access to run powershell or a console application and the items with broken inheritance are limited, you can try the following:

  1. Navigate to the library and select "Library Permissions"
  2. Click "Show me uniqely secured items of this list"
  3. Click "Manage permissions" for each item and click the "Inherit Permissions" button on the Ribbon.

This way, all the items will eventually inherit permissions from the library, which has no assigned permissions for any user (apart from the site collection admin).

Of course it will only work for a limited amount of items with unique permissions. If you have houndreds or thousands of broken permissions (which you should not as it is a bad practice) you will have to use a script.

The same in PowerShell:

$webUrl = "http://mySite"
$web = Get-SPWeb $webUrl
$list = $web.Lists["myLibrary"]

#Using foreach is time consuming
foreach ($item in $list.items) {
    $item.ResetRoleInheritance()
}

And some C# sample:

using System;
using Microsoft.SharePoint;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         using (SPSite site = new SPSite("http://localhost/sites/sitecollection")
    {
     using (SPWeb web = site.OpenWeb("sitecollection/subsite"))
     {
        SPList list = web.Lists["someList"];
        foreach (SPListItem folder in list.Folders)
                {
                    if (folder.HasUniqueRoleAssignments)
                    {
                        folder.ResetRoleInheritance();
                    }
                }
                foreach (SPListItem item in list.Items)
                {
                    if (item.HasUniqueRoleAssignments)
                    {
                       item.ResetRoleInheritance();
                    }
        }

         }
    }
      }
   }
}
2
  • provide code in asp.net c# .i want for client object model
    – user25864
    Commented May 19, 2014 at 14:29
  • Powershell is the preferred way for this kind of administrative tasks
    – yandr
    Commented May 19, 2014 at 22:08
0

Go to library permissions -> Stop inheriting permissions -> then select all users and then click remove users permissions.

4
  • i have done it but when i select any file and select manage permission and then check permission for any user it showing allow for all permission
    – user25864
    Commented May 19, 2014 at 12:21
  • But any user would not be able to navigate to that document library except site collection admin and system account.
    – Aanchal
    Commented May 19, 2014 at 12:29
  • those file also i am able to see from different account which has no permission to access it
    – user25864
    Commented May 19, 2014 at 12:35
  • Then you have to remove the permissions programatically from files.c-sharpcorner.com/uploadfile/Ravish001/…
    – Aanchal
    Commented May 19, 2014 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.