Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Script Editor Web Part Security Trimming Fails

$
0
0

Hi all,

I am using the following code in a Script Editor Web Part. It displays the subsites in a site collection. If a user does not have permissions to one of the sites, it fails to display any of the other sites and states "Forbidden". I need to display the subsites a user has access to. Any clues? Is there some sort of explicit Security Trimming code I need to add to the Web Part?

<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script><script type="text/javascript">
    $(document).ready(function ($) {
        var basePath = "https://yourcompany.com/projects/_api/";
        $.ajax({
            url: basePath + "web/webs",
            type: "GET",
            headers: { "Accept": "application/json;odata=verbose" },
            success: function (data) {
                //script to build UI HERE
$.each(data.d.results,function(index,value){
$("#SiteList").append("<p>" + "<a href='" + value.Url + "'>" + value.Title + "</a></p>");
});
},
            error: function (data) {
                //output error HERE
 alert(data.statusText);          
 }
        });
    });</script><style>

#SiteList { 
border: 3px coral solid; 
}

#SiteList h2 {
color:#333;
margin-bottom:10px;
}

</style><div id="SiteList"><h2>Projects List</h2></div>


Personal Blog: http://thebitsthatbyte.com





Viewing all articles
Browse latest Browse all 25064

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>