简体   繁体   中英

Load SharePoint List data on a page without having permission on a list using Javascript REST Api

Here in this javascript i loaded all the items id of SharePoint list "XYZ" in a dropdown box. I have removed User "Manoj" from list permission but it has permission on a page where i put this javascript using content editor. Now when i access this page using Site Administrator then i can see the list items id in drop down but when i move on next user "Manoj" who does not have permission on List but have on page than it's give me message like "Access denied. You do not have permission to perform this action or access this resource."

So my question is can we load data of list in a Web-Part page in which user don't have permission in list but have full permission on a page? i am asking this question because i don't give user to permission to see the list and perform operation if user want to add or edit data only by using web part page.

If not then is there any other way like: Using javascript change the user on Page load.

Below is javascript rest api that i used

<script type="text/javascript">
$( window ).load(function() {
DisplayItem();
});
function DisplayItem(){

 var requestUri = 'http://abc/pharma/Zdus/RnD/_api/Web/Lists/getByTitle(\'XYZ\')/items'
 var requestHeaders = {
 'accept': 'application/json;odata=verbose'
 }; 
 $.ajax({
 url: requestUri, 
 dataType: "json", 
 type: 'GET',
 headers: requestHeaders,
success: function(json) {
var len= (json.d.results.length);
var x=document.getElementById("myList");
for (var i=0;i<len;i++)
{
var nid=(json.d.results[i].ID);
x.options[x.options.length] = new Option(nid, nid);
}
}, 
 error: function(error){
 alert(error.responseText);
 }
 });
}
</Script>
<div>
<label>Total Items</label>
       <select id="myList" >
        <option value=''></option>
</select>

Any help highly appreciated. Not: This working fine with Site Admin and the Users who has list permission

You can load or get data from Sharepoint if user does not have permission on that list.

To fetch the data from Sharepoint Atleast read permission is required. You can give only read permission to the user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM