oC server upgrade problem

We're currently running oC version 7.0.2.1, which connects to five different Active Directory domains for user authentication. I'm trying to upgrade it to the lastest version by going thru each major release but bumped into problems.
As the first step, I did a manual upgrade using occ to upgrade the server to 7.0.15. The upgrade went smoothly and quickly without any issues.
But then when I tried to upgrade it from 7.0.15 to 8.0.16, the upgrade appears to take forever - not sure if it's gone into a loop. Below is the output from occ:

Set log level to debug - current level: 'Debug'
Turned on maintenance mode
Checked database schema update
Checked database schema update for apps
Updated database
Disabled incompatible app: documents
Updated <filespdfviewer> to 0.7.1_
Updated <userldap> to 0.5.2_
Updated to 1.2.2
Updated <filessharing> to 0.6.2_
Updated to 0.6.1
Repair warning: Could not repair legacy storage local::/var/www/owncloud/data/65967CC3-F86E-4E6D-8988-C3ECCBDE33B2/ automatically.

And below is the last few lines from the owncloud.log file:

{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 210","level":1,"time":"2017-04-19T03:54:48+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:54:50+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 240","level":1,"time":"2017-04-19T03:54:50+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:54:52+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 270","level":1,"time":"2017-04-19T03:54:52+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:54:54+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 300","level":1,"time":"2017-04-19T03:54:54+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:54:56+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 330","level":1,"time":"2017-04-19T03:54:56+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:54:57+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 360","level":1,"time":"2017-04-19T03:54:57+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:54:59+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 390","level":1,"time":"2017-04-19T03:54:59+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:01+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 420","level":1,"time":"2017-04-19T03:55:01+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:02+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 450","level":1,"time":"2017-04-19T03:55:02+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:04+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 480","level":1,"time":"2017-04-19T03:55:04+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:06+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 510","level":1,"time":"2017-04-19T03:55:06+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:08+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 540","level":1,"time":"2017-04-19T03:55:08+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:09+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 570","level":1,"time":"2017-04-19T03:55:09+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:11+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 600","level":1,"time":"2017-04-19T03:55:11+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:13+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 630","level":1,"time":"2017-04-19T03:55:13+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:15+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 660","level":1,"time":"2017-04-19T03:55:15+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:16+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 690","level":1,"time":"2017-04-19T03:55:16+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:18+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 720","level":1,"time":"2017-04-19T03:55:18+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:20+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 750","level":1,"time":"2017-04-19T03:55:20+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"Paged search was not available","level":1,"time":"2017-04-19T03:55:22+00:00","method":"--","url":"--"}_
{"reqId":"d9ff4ed1c6ce70d27ba829da9d7ff1b7","remoteAddr":"","app":"userldap","message":"No paged search for us, Cpt., Limit 30 Offset 780","level":1,"time":"2017-04-19T03:55:22+00:00","method":"--","url":"--"}_

The upgrade process went on for hours and never seem to be able to complete.
Wondering if anyone has any suggestion?
I wonder if the upgrade was trying to check each user. I did a 'select' on the oc_ldap_user_mapping table
and found it has 29668 entries! I don't know why it has this many entries as there is definitely
not that many users who have logged onto oC, even tho there could be a large number of users in all the
Active Directory domains combined.
Any help would be much appreciated.

Yes, it will go through all potential users, this is actually only fixed just now in 9.1.5 after some customers hit those issues. With this many users maybe a subscription might be a good idea? Please contact sales@onwcloud.com for a quote. In any case it might make more sense to setup a new ownCloud with the newest version or right away with 10.0 in a few weeks and loose some shares, etc.

@PVince81 Posted a few hints on the steps needed how to fix this in your database at a mailinglist thread a few weeks ago:

https://mailman.owncloud.org/pipermail/user/2017-March/002793.html

If I build a new server and migrate the users across, is there a way I can get the last login times of the users without using the web front-end as it takes forever to display the users?