How to see Shared with persons in document library using c#.

Bharathi Paulraj 21 Reputation points
2022-11-08T15:39:03.26+00:00

I have one page in sharepoint site.in that page 15 document library links or there.Onclick of one link i can see that document library.I have 5 departments(for ex.A,B,C,D,E)in my company.In some document they everyone is having permission.In some document library some people are not having permission.Like that some people are not having permission in folder also.i want to check in A department is having permission in which document libraries and what are the folders.like that B,C,D,E.

I have Created 5 lists (A,B,C,D,E).In A list that department people names are there.like that their department names are there in everylist.I have created 5 buttons(A,B,C,D,E).Onclick of A i want to see the page of the document library link(what are the document libraries A department people are having permission that document library link should come in that page.on click of one document library what are the folders are shared with A department people that folders only should come.Atleast one person is having permission in one folder also that folder should come.No one is having permission in any folder from A department that folder should not come.I am having permission in every document library and every folder.in my id i have to check what are the document libraries and folders are shared for their department. am using c#.

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,685 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. RaytheonXie_MSFT 31,681 Reputation points Microsoft Vendor
    2022-11-09T06:14:16.557+00:00

    Hi @Bharathi Paulraj
    Per my test, I will recommend you to use CSOM to get folder permissions. Please refer to following code

    var list = clientContext.Web.Lists.GetByTitle("TestLibrary");  
    var items = list.GetItems(CamlQuery.CreateAllFoldersQuery());  
    clientContext.Load(items, icol => icol.Include(i => i.RoleAssignments.Include(ra => ra.Member), i => i.DisplayName));  
    clientContext.ExecuteQuery();  
    foreach (var item in items)  
    {  
        Console.WriteLine("{0} folder permissions", item.DisplayName);  
        foreach (var assignment in item.RoleAssignments)  
        {  
            Console.WriteLine(assignment.Member.Title);  
        }  
    }  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



  2. Bharathi Paulraj 21 Reputation points
    2022-11-13T16:13:52.037+00:00

    Thank you so much for your reply