PHP-SharePoint-Lists-API libCurl在NTLM身份验证中出现411错误

时间:2014-04-12 17:57:23

标签: php sharepoint curl libcurl

我正在使用带有NTLM身份验证的Git PHP-SharePoint-Lists-API库。它通过lib cURL发送POST请求(我正在使用lib cURL 7.35.0运行Windows PHP 5.5.11)。

问题是cURL生成的NTLM身份验证响应不包含Content-Length标头,而SharePoint 2013似乎不喜欢这样。它返回HTTP 411错误,缺少内容长度

我在multiple位置找到了对此问题的讨论,但没有实际解决方案。谢谢你的任何想法。

来自SoapClientAuth.php

的cURL
$ch = curl_init($location);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_FAILONERROR, FALSE);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERPWD, $this->Username . ':' . $this->Password);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_CERTINFO, TRUE);
if ($DEBUGGING) {
  curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888');
}

$response = curl_exec($ch);

第一次请求

POST http://sp2013server.com/marketing/_vti_bin/Lists.asmx HTTP/1.1
Host: sp2013server.arx.com
Accept: */*
Connection: Keep-Alive
User-Agent: PHP-SOAP
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/GetListCollection"
Content-Length: 251
Expect: 100-continue
Connection: Keep-Alive

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas... blah

第一反应

HTTP/1.1 401 Unauthorized
Cache-Control: private
Content-Length: 16
Content-Type: text/plain; charset=windows-1255
SPRequestGuid: 5b93869c-5b72-8091-555a-8d0d25f77b1e
request-id: 5b93869c-5b72-8091-555a-8d0d25f77b1e
X-FRAME-OPTIONS: SAMEORIGIN
SPRequestDuration: 8
SPIisLatency: 6
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
WWW-Authenticate: NTLM
X-Content-Type-Options: nosniff
X-MS-InvokeApp: 1; RequireReadOnly
MicrosoftSharePointTeamServices: 15.0.0.4420
Date: Sat, 12 Apr 2014 17:42:49 GMT
Proxy-Support: Session-Based-Authentication

401 UNAUTHORIZED

第二次请求(由CURL生成,而非客户来电)

POST http://sp2013server.arx.com/marketing/_vti_bin/Lists.asmx HTTP/1.1
Authorization: NTLM TlRMxxxxxxxxxxx==
Host: sp2013server.arx.com
Accept: */*
Connection: Keep-Alive
User-Agent: PHP-SOAP
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://schemas.microsoft.com/sharepoint/soap/GetListCollection"
Expect: 100-continue
Connection: Keep-Alive

第二次回复

HTTP/1.1 411 Length Required
Content-Type: text/html; charset=us-ascii
Server: Microsoft-HTTPAPI/2.0
Date: Sat, 12 Apr 2014 17:42:50 GMT
Connection: close
Content-Length: 344

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Length Required</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Length Required</h2>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
</BODY></HTML>

1 个答案:

答案 0 :(得分:1)

Re:关于github的讨论https://github.com/thybag/PHP-SharePoint-Lists-API/issues/58

我已将此问题的建议可能修复程序添加到库的开发分支(https://github.com/thybag/PHP-SharePoint-Lists-API/tree/develop)。如果能解决这个问题,你能告诉我吗?