ContactsManager not working as expected

While trying to implement my own ExternalAddressBook, I’m stumbling to understand how stuff should work.

To understand a plugged-in addressbook, I installed and configured ldap_contacts_backend, but this doesn’t work either as expected; no contacts from LDAP showing up. Actually, even the system contacts are missing (although enabled in settings/groupware).

From the official documentation here, I understand that a backend must `IManager:register()` a callable at boot time for later registration, which is what ldap_contact_backend does in Application.php. DAV does so as well, so after startup there are two callables present in ContactsManager::addressBookLoaders[].

When using the contacts app, I’d expect the calllables to register their addressbooks eventually, but `loadAddressBooks()` is never called with Mail and Contacts apps.

After a lot of trying, I finally succeeded triggering `loadAddressBooks()`, by hitting the Universal Search button. Now I can see that `ContactsManager::search($pattern=””)` collects a total of 48 contacts from the system addressbook, the LDAP addressbook and a manual one. typing the search field doesn’t trigger any more searches, still no card results are displayed in the Universal Search box; only file results.

Versions are latest: PHP8.4, NC32.0.5, Contacts 8.3.2, ldap_contacts_backend 1.1.12, no errors in nextcloud.log.

What am I missing?
Regards, Andreas

Ideally, you have a public test code that we can look at (or even install on a dev environment)?

A quick glance on the server code shows that you should look for getUserAddressBooks() which in turn is triggered in the contacts app. But I have never used that API, so this is just static code analysis.

Actually, I falsely assumed that registering with the core ContactsManager would do the job for DAV, but that was wrong.

Investigating the code at DAV/PluginManager, it has to be configured correctly to be available for DAV.

While there’s “types: dav” configured in ldap_contacts_backend, the sabre plugins are not:

OCA\LDAPContactsBackend\Service\AddressBookProvider

After adding this snippet to info.xml, the LDAP addressbook showed in Contacts as expected, and was also discoverable by a CardDAV client.

Would you mind filing a basic PR or at least a clearly formulated issue) against the LDAP extension to help them fix this issue on their side? Ideally, post a link here.

Thank you very much!

I’m getting the impression it’s intentionally; supporting ContactsMenu only, because many CardDAV features fail:

  • While the CardDAV client discovers the addressbook, it doesn’t sync any cards.
  • Trying to hide the addressbook in Contacts/Settings results in “This addressbook is immutable”.

So apparently ldap_contacts_backend is for contacts only, not CardDAV.