Authentication Issue with jQuery and SharePoint Web Service

I call the SharePoint web service (Webs.asmx) using jQuery to get a list of all the sub sites:

$(document).ready(function() {
        var hrefParts = window.location.href.split('/');
        var wsURL = "";
        for (i = 0; i < (hrefParts.length - 2); i++) {
            if (i > 0)
                wsURL += "/";
            wsURL += hrefParts[i];
        }
        wsURL += "/_vti_bin/Webs.asmx";
        var soapEnv =
            "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
                <soapenv:Body> \
                    <GetAllSubWebCollection xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                    </GetAllSubWebCollection > \
                </soapenv:Body> \
            </soapenv:Envelope>";

        $.ajax({
            url: wsURL,     
            beforeSend: function  (xhr) {  
 xhr.setRequestHeader("SOAPAction",  "http://schemas.microsoft.com/sharepoint/soap/GetAllSubWebCollection");
},
            type: "POST",
            dataType: "xml",
            data: soapEnv,
            complete: processResult,
            error:function(xhr,err){ 
    alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status); 
    alert("responseText: "+xhr.responseText); 
},
            contentType: "text/xml; charset=\"utf-8\""
        });

    });

    function processResult(xData, status) {
        ...
    }

However, I always get a login issue due to a beforeSend call. If I comment on this, I get a "Access Denied" error from SharePoint. I have "Full Access" to the site and all child servers. Calling another web service (for example, calling GetListCollection from the list .asmx) succeeded.

What could be the problem?

+3
source share
1 answer

This operation requires site administrator access, even full control is not enough.

, , GetWebCollection -, webservice.

+3

Source: https://habr.com/ru/post/1731148/


All Articles