1

I am trying to retrieve a list of contacts (in .vcf format) from the Sogo groupware system, using CardDav. I have used my code with other systems successfully, but Sogo does not work as I expect. I have the URL set to:

https://<server>/SOGo/dav/<user>/Contacts/personal/

The user id and password are supplied to libcurl. The command is REPORT with the following xml:

<?xml version="1.0" encoding="utf-8" ?>
<card:addressbook-query d="DAV:"xmlns:card="urn:ietf:params:xml:ns:carddav">
<d:prop>
<d:getetag />
<card:address-data>
</card:address-data>
</d:prop>
<card:filter>
<card:prop-filter name="FN">
</card:prop-filter>
</card:filter>
</card:addressbook-query>

With other systems, this query will produce a file containing multiple vcard entries, which is what I want. With Sogo, all I get is this:

<?xml version="1.0" encoding="utf-8"?>
<D:multistatus xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:carddav">
</D:multistatus>

I have noticed that the PROPFIND command to the above URL will give me a very large file, containing multiple URLs, one for each contact entry. Those do in fact work, but it will be much slower having to execute possibly thousands of GETs to retrieve them one by one. Does anyone have an idea about what is wrong with my address book query?

Related question: I want to do basically the same thing with the calendar (slightly different xml input) and have the same problem. However there is a workaround, in that I can execute a GET to this URL:

https://<server>/SOGo/dav/<user>/Calendar/personal.ics

and I get the entire .ics file that I want. However there does not seem to be an equivalent URL I can use for contacts - am I wrong?

Jeff McKay
  • 295
  • 1
  • 3
  • 11

2 Answers2

1

The CardDAV implementation of the Inverse SOGo looks a bit - lets say 'simple' - to me:

https://github.com/inverse-inc/sogo/blob/907c30061f413fe2d250cddf348db6b4fc26b143/SoObjects/Contacts/SOGoFolder%2BCardDAV.m

Though it seems like it should return all cards if the query is too complex (by no filters provided they mean no filters we can handle ...):

// If no filters are provided, we return everything.

But then this change was implemented only a few months ago, maybe your SOGo installation doesn't have it yet?:

https://github.com/inverse-inc/sogo/commit/907c30061f413fe2d250cddf348db6b4fc26b143

2.3.3 (2015-mm-dd)
...
- we now return all cards when we receive an empty addressbook-query REPORT
...

Summary: This specific query should probably work in a current SOGo (>=2.3.3?), though the implementation is still quite a bit far from the RFC ;->


*Having said that*: It depends a bit on your type of client, but what you do is pretty uncommon (using an `addressbook-query` to fetch all cards). That query only really makes sense with Web clients that have no local storage. A regular sync client usually uses a WebDAV `sync-report` to keep a list of etags/URLs and then a WebDAV `multiget` REPORT to fetch changed items.

I have noticed that the PROPFIND command to the above URL will give me a very large file, containing multiple URLs, one for each contact entry. Those do in fact work, but it will be much slower having to execute possibly thousands of GETs to retrieve them one by one

You can use the PROPFIND to grab all URLs, and then instead of individual GETs, one or a batch of multiget REPORTs as mentioned above. I say 'a batch', because fetching all vCards in a single HTTP requests will often put a lot of load/memory pressure on non-streaming servers (many are, not sure about SOGo - could be streaming).

As mentioned above, a PROPFIND is still not recommended. Rather use a sync-report to fetch only the URLs which have changed (the first response will be large, but then only diffs are transmitted).

Related question: I want to do basically the same thing with the calendar (slightly different xml input) and have the same problem.

You need to provide the XML. Though the same thing as above applies. A calendar-query is not usually used to fetch all events. Use a sync-report in combination with a multiget.

I don't think there is a GET defined on contact folders in SOGo, and I think this is pretty uncommon for CardDAV servers in general (different to CalDAV ones).

Community
  • 1
  • 1
hnh
  • 13,957
  • 6
  • 30
  • 40
  • Thanks for your comments. My application is migration, a one time thing, but perhaps sync-report is a good idea, if indeed the first call gives me everything. – Jeff McKay Jan 25 '16 at 18:04
0

The Sogo groupware system is not a standards compliant CardDAV server. You can, however, connect to the CardDAV address book with a WebDAV client and open it as a folder. The folder contains files that are individual vCards (even though they may not have the vcf extension) and the files can be downloaded and then imported in to another address book.

FoxDev
  • 1