I want to write a little LDAP 2 CardDav Gateway, which gets a request (from a Desktop Phone/PBX) on it's LDAP side and converts it to a CardDAV request.
So for I used raw HTTP/XML requests and was able to:
- Query the base directory /kdav/addressbooks/ with
PROPFINDanddepth: 1 - for results with
<d:resourcetype><d:collection>repeat the query recursivly - for results with
<d:resourcetype><card:addressbook>add them to the addressbook list - after the recursion is done a
REPORTquery with<card:addressbook-query><card:address-data><card:prop name="TEL"><card:prop name="N"></card:address-data>over the addreesbook list
Now this gives me currently the possibility to get all contacts and create a phonebook.xml, which can be fetched by my phones.
Unfortunatly I was unable to restrict the PROPFIND to only return results of <d:resourcetype><d:collection> or <d:resourcetype><card:addressbook>. This is problematic, as I can have nested addressbooks, which return all children on PROPFIND, in the worst case this means I query an addressbook, which has no nested address books, but 500 contacts, so I get 500 results back which I completely filter out on client side.
Any ideas on how to solve that more efficient?
Also here is an example of a response I currently get, which makes me assume that the addressbooks are nested. The server is Kopano and either I'm misinterpreting nested address books or it breaks the specification.
<?xml version="1.0"?>
<d:multistatus
xmlns:d="DAV:"
xmlns:s="http://sabredav.org/ns"
xmlns:card="urn:ietf:params:xml:ns:carddav"
xmlns:cal="urn:ietf:params:xml:ns:caldav"
xmlns:cs="http://calendarserver.org/ns/">
<d:response>
<d:href>/kdav/addressbooks/public/</d:href>
<d:propstat>
<d:prop>
<d:resourcetype>
<d:collection/>
</d:resourcetype>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
<d:response>
<d:href>/kdav/addressbooks/public/sdfsf/</d:href>
<d:propstat>
<d:prop>
<d:resourcetype>
<d:collection/>
<card:addressbook/>
</d:resourcetype>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
<d:response>
<d:href>/kdav/addressbooks/public/Test/</d:href>
<d:propstat>
<d:prop>
<d:resourcetype>
<d:collection/>
<card:addressbook/>
</d:resourcetype>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
</d:multistatus>