Ericsson / exchangecalendar

Exchange 2007/2010/2013 Calendar, Tasks, Contacts and GAL Provider.
GNU General Public License v3.0
925 stars 112 forks source link

contacts : can't get more than 1000 contacts from address book #398

Closed Trim closed 8 years ago

Trim commented 8 years ago

Hello,

Recently I've discovered that exchangecalendar cant' get all contacts from my company shared address book. The address book contains around 1600 vcards and, after end of the synchronisation, Thunderbird shows me only 1k contacts.

I've looked the code of components/erSyncContactsFolder.js and I've found an error in these lines:

if (lastItemInRange == "false") {
    this.execute(syncState);
    return;
}
else {
    if (this.mCbOk) {
        this.mCbOk(this, this.creations, this.updates, this.deletions, syncState);
    }
    this.isRunning = false;
}

For me, the call of the callback function seems wrong for me, because in file interfaces/exchangeAddressBook/exchangeAbFolderDirectory/exchangeAbFolderDirectory.js the signature of the function callback function is:

contactsFoundOk: function _contactsFoundOk(erFindContactsRequest, aContacts, aDistLists)

So I've fixed that code with this ugly temporary hack:

    if (this.mCbOk) {
        this.mCbOk(this, [this.creations.contacts, this.updates.contacts, this.deletions.contacts]
                 [this.creations.distlists, this.updates.distlists, this.deletions.distlists]);
    }

I got 2 more contacts synchronised and 2 more distribution lists, but it miss still 600 contacts.

First I thought that the synchronisation between exchangecalendar and the exchange 2013 server was in error. So I've used Firefox to do a remote debug with the developer tools and I had these results:

Network tab

I've checked the POST requests with a "200" response and they seem to correctly retrieve all contacts from the exchange server according to the Microsoft documentation : the first request is done without SyncState tag and then each request have the updated value for SyncState upto the 5th one which have the value of IncludesLastItemInRange to true in the response.

The following requests are to get details on some contacts and on the two distribution lists available with the address book.

Although, looking for contacts in the exchangecalendar log, I have only one logged server response and it seems that it received only 1000 contacts.

I'll try to investigate more tomorrow. For now, it seems that the code of components/erSyncContactsFolder.js does correctly all requests on the exchange server, but everything isn't called back to the callback of the exchangeAbFolderDirectory.js code. Maybe my ugly hack wasn't suffisant, or we reached the limits of javascript array size (some mega bits according to the network graph).

I think a possible solution is to rewrite interaction between the two piece of codes to give back results after each request instead of waiting to have all contacts. If I've read correctly the corresponding code of the Calendar part, it seems to work like that.

Maybe such solution could improve a bit the situation of bugs : #376 and #375 about freezes.

See you, Adrien

bavincen commented 8 years ago

Can you create a patch please

On Thu, Jan 7, 2016, 02:39 Adrien Dorsaz notifications@github.com wrote:

Hello,

Recently I've discovered that exchangecalendar cant' get all contacts from my company shared address book The address book contains around 1600 vcards and, after end of the synchronisation, Thunderbird shows me only 1k contacts

I've looked the code of components/erSyncContactsFolderjs and I've found an error in these lines https://githubcom/Ericsson/exchangecalendar/blob/master/components/erSyncContactsFolderjs#L175-L184 :

if (lastItemInRange == "false") { thisexecute(syncState); return; }else { if (thismCbOk) { thismCbOk(this, thiscreations, thisupdates, thisdeletions, syncState); } thisisRunning = false; }

For me, the call of the callback function seems wrong for me, because in file interfaces/exchangeAddressBook/exchangeAbFolderDirectory/exchangeAbFolderDirectoryjs the signature of the function callback function https://githubcom/Ericsson/exchangecalendar/blob/master/interfaces/exchangeAddressBook/exchangeAbFolderDirectory/exchangeAbFolderDirectoryjs#L1299 is:

contactsFoundOk: function _contactsFoundOk(erFindContactsRequest, aContacts, aDistLists)

So I've fixed that code with this ugly temporary hack:

if (thismCbOk) {
    thismCbOk(this, [thiscreationscontacts, thisupdatescontacts, thisdeletionscontacts]
             [thiscreationsdistlists, thisupdatesdistlists, thisdeletionsdistlists]);
}

I got 2 more contacts synchronised and 2 more distribution lists, but it miss still 600 contacts

First I thought that the synchronisation between exchangecalendar and the exchange 2013 server was in error So I've used Firefox to do a remote debug https://developermozillaorg/en-US/docs/Tools/Remote_Debugging/Thunderbird with the developer tools and I had these results:

[image: Network tab] https://camo.githubusercontent.com/d78bfeec31d81fa5a83428bac865df4cf79db928/68747470733a2f2f636c6f756461646f7273617a63682f696e6465787068702f732f636e53304e744c4b653268613963522f646f776e6c6f6164

I've checked the POST requests with a "200" response and they seem to correctly retrieve all contacts from the exchange server according to the Microsoft documentation https://msdnmicrosoftcom/en-us/library/office/aa563967%28v=exchg150%29aspx : the first request is done without SyncState tag and then each request have the updated value for SyncState upto the 5th one which have the value of IncludesLastItemInRange to true in the response

The following requests are to get details on some contacts and on the two distribution lists available with the address book

Although, looking for contacts in the exchangecalendar log, I have only one logged server response and it seems that it received only 1000 contacts

I'll try to investigate more tomorrow For now, it seems that the code of components/erSyncContactsFolderjs does correctly all requests on the exchange server, but everything isn't called back to the callback of the exchangeAbFolderDirectoryjs code Maybe my ugly hack wasn't suffisant, or we reached the limits of javascript array size (some mega bits according to the network graph)

I think a possible solution is to rewrite interaction between the two piece of codes to give back results after each request instead of waiting to have all contacts If I've read correctly the corresponding code of the Calendar part, it seems to work like that

Maybe such solution could improve a bit the situation of bugs : #376 https://github.com/Ericsson/exchangecalendar/issues/376 and #375 https://github.com/Ericsson/exchangecalendar/issues/375 about freezes

See you, Adrien

— Reply to this email directly or view it on GitHub https://github.com/Ericsson/exchangecalendar/issues/398.

Trim commented 8 years ago

I've just seen that I didn't check the right callback definition, sorry for this useless big report. I'm checking error on the good callback function and I'll give you feedback.

Trim commented 8 years ago

I've found the issue: the code of components/erFindContacts.js isn't complete: it does only one request to the exchange server, even if the response indicates that it misses some items.

I'm trying to make a code according to Microsoft example.

bavincen commented 8 years ago

Thanks for patch