【问题标题】:Authentication problem with JQuery and SharePoint Web ServiceJQuery 和 SharePoint Web 服务的身份验证问题
【发布时间】:2010-02-03 06:46:43
【问题描述】:

我正在使用 JQuery 调用 SharePoint Web 服务 (Webs.asmx) 以获取所有子网站的列表:

$(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) {
        ...
    }

但是,由于 beforeSend 调用,我总是遇到登录问题。如果我将其注释掉,我会从 SharePoint 收到“拒绝访问”错误页面。 我对该站点和所有子站点具有“完全控制”权限。调用不同的 Web 服务(例如从 lists.asmx 调用 GetListCollection)成功。

这可能是什么问题?

【问题讨论】:

  • 一些问题:保存 javascript 的页面在哪里?在某处的文档库中?登录问题是 401 Unauthorized 错误吗?
  • 它在“页面”库中。现在问题已解决,如下面的答案所述。

标签: jquery sharepoint authentication web-services


【解决方案1】:

此操作需要网站集管理员访问权限,即使完全控制也不够。

您可能需要通过 GetWebCollection 进行迭代,或者创建一个以提升的权限运行并返回 Web 服务响应的代理页面。

【讨论】:

    猜你喜欢
    • 2012-02-28
    • 1970-01-01
    • 2016-06-10
    • 1970-01-01
    • 2015-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-20
    相关资源
    最近更新 更多