Content Editor webpart accessing a restricted csv file

Syed Muazzam Ahmed 96 Reputation points
2021-06-18T14:41:41.75+00:00

Hello,

I have content editor web part accessing a csv file to display selective data from it and the csv file is in a document library of the same site collection. I am restricting permissions to this library. If user has a permission to the document library and access the content editor web part page then he can see the functionality. If user has no permission on the library and access content editor web part then he gets no data in CEWP. I want CEWP to access data from the csv file even if the user does not have permission to the documents library.

Can anyone please help me how I can do it.

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

Answer accepted by question author
  1. Syed Muazzam Ahmed 96 Reputation points
    2021-06-30T14:11:08.833+00:00

    Adding the workarounds I found for people who might land here.

    I found 2 work arounds and I am using both of them for different sets of users.

    1) First workaround is setting 'Restricted Read' as permission level of the User. With this users cannot access documents library but the CEWP easily reads the files within it and renders on site page when those users open it. The issue with this solution is it stops the user from accessing other files too which I want them to be able to open.

    2) The second solution is adding a script snippet in my MasterPage which redirects the user to home page of the SharePoint Site if the User tries to access specific files. The Code reads permission level of the user, and then matches the current URL of the page to the URL of the document I want to restrict. It redirects the user to homepage site if the URL is that of the document.

    Hope what I wrote is intelligible 😅


1 additional answer

Sort by: Most helpful
  1. CaseyYang-MSFT 10,466 Reputation points
    2021-06-21T09:12:45.76+00:00

    Hi @SyedMuazzamAhmed-0521

    Per my test, when users don’t have permission to the documents library, they don’t have permission to read the data about csv file in the document library. And there is no other workaround to solve this problem.


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    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.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.