Unable to retrieve contacts from a linked Exchange account

On my iPhone, in Settings, I've added my company Exchange account. Consequently, within the Contacts app, 4 new lists appear - the bottom as shown in the attached image.

There's a few thousand contacts in the Company Exchange account, so why are the count values showing as 0? If I click on the Global Address list and search, it can succfully find whatever I search for. I want to programatically retrieve the contacts within the Exchange account, in addition to those stored locally or within iCloud, however if I execute the following code, for the container of type exchange, the count of results of the call to unifiedContacts() is 0.

How can I programatically get the Exchange contacts? If the call to unifiedContacts() is resulting in 0 because the count for the lists when viewing the Contacts app is 0, then how to make it not 0 in the Contacts app (but if that were the case, how come manually searching for a contact is successful?)


 let keysToFetch = [
        CNContactFormatter.descriptorForRequiredKeys(for: .fullName),
        CNContactPhoneNumbersKey,
        CNContactEmailAddressesKey,
        CNContactThumbnailImageDataKey] as [Any]
    
    var allContainers: [CNContainer] = []
    do {
        allContainers = try CNContactStore().containers(matching: nil)
    } catch {
        print("Error fetching containers")
    }

    var results: [CNContact] = []

    for container in allContainers {
        let type = container.type
        let identifier = container.identifier
        let fetchPredicate = CNContact.predicateForContactsInContainer(withIdentifier: container.identifier)
        do {
            let containerResults = try CNContactStore().unifiedContacts(matching: fetchPredicate, keysToFetch: keysToFetch as! [CNKeyDescriptor])
            let count = containerResults.count
            results.append(contentsOf: containerResults)
        } catch {
            print("Error fetching containers")
        }
    }

Unable to retrieve contacts from a linked Exchange account
 
 
Q