Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Security permissions

  Asked By: Elton    Date: Nov 19    Category: Sharepoint    Views: 1159

We are using below code to get the documents in a specific folder. Code works OK
for 2 doclibs (it returns the documents based on security permissions of the
documents), however with one of our doclibs, it returns all of the documents
regardless of their security permissions. Doclib contains more than 1000
documents with major versioning enabled.

private SPListItemCollection getListItemsInDocLib(string listName, string


SPWeb web = SPContext.Current.Web;

SPList listBD = web.Lists[listName];

SPDocumentLibrary doclib = (SPDocumentLibrary)listBD;

SPView viewBD = listBD.Views[viewName];

SPFolder folder = null;

foreach (SPListItem item in listBD.Folders)


if (Yil.Equals("2009"))


folder = item.Folder;




SPListItemCollection listCollection = null;

if (folder != null)

listCollection = doclib.GetItemsInFolder(viewBD, folder);

return listCollection;


doclib.GetItemsInFolder(viewBD, folder) or doclib.GetItems(viewBD) returns the
same result.

Have you ever experienced something like this?



4 Answers Found

Answer #1    Answered By: Phenil Poriya     Answered On: Nov 19

Are the permissions  applied directly to the documents  or to the folders? I've
seen random issues with permissions when applied to folders not being suitably
applied to documents in the folders.

Answer #2    Answered By: Dante Parsons     Answered On: Nov 19

permissions are applied on item  (document basis), when the user clicks on the
link of a document without permissions  on he gets a access denied.

Answer #3    Answered By: Luke Davis     Answered On: Nov 19

If the permissions  are applied at the document level than the user shouldn't
even be able to see a link to the document to click on. Something is not right
with permissions in your environment. Users evidently have View permission
without having open permission.

Were permissions applied in the user interface or programmatically?

Answer #4    Answered By: Daniella Landry     Answered On: Nov 19

Sorry, when users browse to the doclib, they see only the documents  they have
permission to view. We use a custom control -with the partial code  below- to get
the documents that the user have permission. That code block returns  all items
regardless of permissions.

Permissions are applied programatically, and when we click manage permissions,
we can see that it is applied successfully (we use the same permission control
code through the farm and that caused no problem yet). There are other doclibs
in the same site collection without any permission problem.

Didn't find what you were looking for? Find more on Security permissions Or get search suggestion and latest updates.