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 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 ?

share|improve this question

2 Answers 2

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();
                    }
        }

         }
    }
      }
   }
}
share|improve this answer
    
provide code in asp.net c# .i want for client object model –  user25864 May 19 at 14:29
    
Powershell is the preferred way for this kind of administrative tasks –  yandr May 19 at 22:08

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

share|improve this answer
    
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 May 19 at 12:21
    
But any user would not be able to navigate to that document library except site collection admin and system account. –  Aanchal May 19 at 12:29
    
those file also i am able to see from different account which has no permission to access it –  user25864 May 19 at 12:35
    
Then you have to remove the permissions programatically from files.c-sharpcorner.com/uploadfile/Ravish001/… –  Aanchal May 19 at 12:39

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.