Caldav 服务器以 403 应答

Caldav server answers with 403

我正在尝试使用 PHP 客户端连接到 Caldav 服务器。我找到了这个客户端库 http://repo.or.cz/w/davical.git/blob/HEAD:/inc/caldav-client.php,我正在尝试按照此处交换的示例 domain/username/password。

$cal = new CalDAVClient( "http://192.168.10.11/caldav/users/domain.com/user-name/", "user-name", "password" );
$options = $cal->DoOptionsRequest();
if ( isset($options["PROPFIND"]) ) {
    // Fetch some information about the events in that calendar
    $cal->SetDepth(1);
    $folder_xml = $cal->DoXMLRequest("PROPFIND", '<?xml version="1.0" encoding="utf-8" ?><propfind xmlns="DAV:"><prop><getcontentlength/><getcontenttype/><resourcetype/><getetag/></prop></propfind>' );
}
var_dump($folder_xml);exit;

这已经给了我一些 403 Forbidden 回复:

string(1928) "HTTP/1.1 207 Multi status
Connection: Close
Content-Type: text/xml; charset="utf-8"
Date: Fri, 2 Oct 2015 07:02:28 GMT
DAV: 1, access-control, calendar-access, calendar-schedule, calendar-proxy, calendar-availability, calendarserver-private-events, calendar-auto-schedule, calendarserver-principal-property-search, calendarserver-sharing, calendarserver-sharing-no-scheduling, addressbook, calendar-default-alarms
Server: Kerio Connect 8.5.1
Transfer-Encoding: chunked
X-UA-Compatible: IE=edge

584
<?xml version="1.0" encoding="UTF-8"?><a:multistatus xmlns:a="DAV:" xmlns:c="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" xmlns:b="xml:"><a:response><a:href>/caldav/users/domain.com/user-name/</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:resourcetype><a:collection/><a:principal/></a:resourcetype></a:prop></a:propstat><a:propstat><a:status>HTTP/1.1 403 Forbidden</a:status><a:prop><a:getcontentlength/><a:getcontenttype/><a:getetag/></a:prop></a:propstat></a:response><a:response xmlns:d="http://calendarserver.org/ns/"><a:href>/caldav/users/domain.com/user-name/calendar-proxy-write/</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:resourcetype><a:collection/><a:principal/><d:calendar-proxy-write/></a:resourcetype></a:prop></a:propstat><a:propstat><a:status>HTTP/1.1 403 Forbidden</a:status><a:prop><a:getcontentlength/><a:getcontenttype/><a:getetag/></a:prop></a:propstat></a:response><a:response xmlns:e="http://calendarserver.org/ns/"><a:href>/caldav/users/domain.com/user-name/calendar-proxy-read/</a:href><a:propstat><a:status>HTTP/1.1 200 OK</a:status><a:prop><a:resourcetype><a:collection/><a:principal/><e:calendar-proxy-read/></a:resourcetype></a:prop></a:propstat><a:propstat><a:status>HTTP/1.1 403 Forbidden</a:status><a:prop><a:getcontentlength/><a:getcontenttype/><a:getetag/></a:prop></a:propstat></a:response></a:multistatus>
0

"

知道在哪里可以修复被禁止的错误吗?我不知道为什么我没有得到任何东西。

编辑: 我终于找到了一些时间来进一步研究这个问题,但只找到了一些日志,还没有解决方案。还不知道哪里出了问题,但这是我在日志中发现的

[07/Dec/2015 15:29:51][21240] {https} Task 202600 handler BEGIN
[07/Dec/2015 15:29:51][21240] {https} Task 202600 handler starting
[07/Dec/2015 15:29:51][21240] {https} HTTPS connection from 192.168.10.91:59937 started
[07/Dec/2015 15:29:51][21240] {https} PROPFIND request for URI /caldav/users/mydomain.com/myuser/
[07/Dec/2015 15:29:51][21240] {https} User-Agent header: DAViCalClient
[07/Dec/2015 15:29:51][21240] {webdav} PROPFIND /caldav/users/mydomain.com/myuser/ received from remote host='192.168.10.91', user-agent='DAViCalClient'
[07/Dec/2015 15:29:51][21240] {webdav} PropertyRequestReader: found property "getcontentlength" from namespace "DAV:"
[07/Dec/2015 15:29:51][21240] {webdav} PropertyRequestReader: found property "getcontenttype" from namespace "DAV:"
[07/Dec/2015 15:29:51][21240] {webdav} PropertyRequestReader: found property "resourcetype" from namespace "DAV:"
[07/Dec/2015 15:29:51][21240] {webdav} PropertyRequestReader: found property "getetag" from namespace "DAV:"
[07/Dec/2015 15:29:51][21240] {webdav} (B)PROPFIND: User myuser@mydomain.com is listing properties of principal: myuser<_at_>mydomain.com
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getcontentlength" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getcontenttype" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getetag" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} (B)PROPFIND: User myuser@mydomain.com is listing properties of principal: myuser<_at_>mydomain.com
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getcontentlength" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getcontenttype" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getetag" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} (B)PROPFIND: User myuser@mydomain.com is listing properties of principal: myuser<_at_>mydomain.com
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getcontentlength" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getcontenttype" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {webdav} User: myuser<_at_>mydomain.com refers to an unsupported property: "getetag" of resource: "" using handler: "PrincipalHandler"
[07/Dec/2015 15:29:51][21240] {https} Response: HTTP/1.1 207 Multi status
[07/Dec/2015 15:29:51][21240] {https} Request finished in 0.00 s, received 373 bytes, sent 1916 bytes
[07/Dec/2015 15:29:51][21240] {https} Task 202600 handler END

问题是您将请求发送到用户主路径,而不是日历集合或日历主页。

属性 DAV:getcontentlength, DAV:getcontenttype and DAV:getetag don't need to be defined for resources that don't support the GET request. As you can see in the response, the property DAV:resourcetype 实际上有一个值表示它是 DAV:collectionDAV:principal

我认为 Kerio 的开发人员决定 return 403 而不是这些属性的 404,因为这些属性不存在不仅因为它们尚未设置,而且因为它们不适用于资源因此。

要查找您用户的日历,您需要先找到日历主页。用户的日历位于他的 calendar-home.

下方

要找到 calendar-home,只需在同一路径上为 属性 CALDAV:calendar-home-set 执行 PROPFIND。这将 return 用户拥有的所有 calendar-home(通常只有一个)。