From OC 8.2 Upgrade to OC 10 results in losing file shares

Actually there seem to be 2 issues that I see so far
1. We lose the existing file shares
2. Could not share files with users over LDAP at all. This is the error

sharing failed could not find user@example.org maybe the server is currently unreachable

Up until upgrade to OC 9.1 things seem to be fine.
After upgrade to OC 10, the existing LDAP app did not work so I had to install a new app
https://marketplace.owncloud.com/apps/user_ldap

After installing the app, there were errors in enabling it so I ran

sudo -u www-data php occ upgrade

This got the app enabled.
My guess is this is why we lost the shares.
Also maybe something is wrong with the app itself, its not able to reach the LDAP server etc.

Steps to reproduce

From OC 8.2
1. upgrade to OC 9.0
2. upgrade to OC 9.1
3. upgrade to OC 10.0.2

Expected behaviour

Successful upgrade to OC 10.0.2

Actual behaviour

Files shares are lost

Server configuration

Operating system:
Ubuntu 14.04 LTS

Web server:
Apache 2.4.7

Database:
MySQL 5.5

PHP version:
It was 5.5 until OC 9.1
I upgraded to PHP 5.6 before upgrading to OC 10

I removed old php first
apt-get purge php*

This installed new one as such

sudo apt-get install python-software-properties
sudo apt-get update
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6 php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml \
php5.6-apcu php5.6-zip php5.6-gd php5.6-curl
a2dismod php5
a2enmod php5.6

ownCloud version: (see ownCloud admin page)
10.0.2

Updated from an older ownCloud or fresh install:
Upgrade

Where did you install ownCloud from:
From official repos (OC 10 repo below)
https://download.owncloud.org/download/repositories/10.0/owncloud/

Signing status (ownCloud 9.0 and above):

Login as admin user into your ownCloud and access 
http://example.com/index.php/settings/integrity/failed 
paste the results into https://gist.github.com/ and puth the link here.

In my case the page is
https://example.com/owncloud/index.php/settings/integrity/failed

The page says
No errors have been found.

The content of config/config.php:

{
    "system": {
        "instanceid": "ocolokkavppu",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "example.org"
        ],
        "datadirectory": "\/srv\/owncloud\/data",
        "overwrite.cli.url": "http:\/\/example.org\/owncloud",
        "dbtype": "mysql",
        "version": "10.0.2.1",
        "dbname": "owncloud",
        "dbhost": "localhost",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "logtimezone": "UTC",
        "installed": true,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "ldapIgnoreNamingRules": false,
        "mail_smtpmode": "smtp",
        "mail_smtphost": "127.0.0.1",
        "mail_from_address": "fileserver-dont-reply",
        "mail_domain": "example.org",
        "loglevel": 2,
        "lost_password_link": "https:\/\/example.org\/lam\/templates\/selfService\/selfServiceSP.php?scope=user&name=default&page=passwordSelfReset",
        "mail_smtpport": "25",
        "theme": "",
        "maintenance": false,
        "updatechecker": false
    }
}

List of activated apps:

If you have access to your command line run e.g.:
sudo -u www-data php occ app:list
from within your ownCloud installation folder.

Enabled:
  - dav: 0.2.9
  - federatedfilesharing: 0.3.0
  - files: 1.5.1
  - files_external: 0.7.0
  - files_sharing: 0.10.0
  - files_trashbin: 0.9.0
  - files_versions: 1.3.0
  - firstrunwizard: 1.1
  - market: 0.2.1
  - notifications: 0.3.0
  - provisioning_api: 0.5.0
  - templateeditor: 0.1
  - user_external: 0.4
  - user_ldap: 0.9.1
Disabled:
  - comments
  - configreport
  - encryption
  - external
  - federation
  - files_antivirus
  - files_videoplayer
  - systemtags
  - theme-example
  - updatenotification

Are you using external storage, if yes which one: local/smb/sftp/...
local

Are you using encryption: yes/no
no

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
LDAP

LDAP configuration (delete this part if not used)

With access to your command line run e.g.:
sudo -u www-data php occ ldap:show-config
from within your ownCloud installation folder

Without access to your command line download the data/owncloud.db to your local
computer or access your SQL server remotely and run the select query:
SELECT * FROM `oc_appconfig` WHERE `appid` = 'user_ldap';

Eventually replace sensitive data as the name/IP-address of your LDAP server or groups.

+-------------------------------+-----------------------------------------------------------+
| Configuration                 |                                                           |
+-------------------------------+-----------------------------------------------------------+
| hasMemberOfFilterSupport      | 1                                                         |
| hasPagedResultSupport         |                                                           |
| homeFolderNamingRule          |                                                           |
| lastJpegPhotoLookup           | 0                                                         |
| ldapAgentName                 | cn=ldapbind,dc=example,dc=org                              |
| ldapAgentPassword             | ***                                                       |
| ldapAttributesForGroupSearch  |                                                           |
| ldapAttributesForUserSearch   |                                                           |
| ldapBackupHost                |                                                           |
| ldapBackupPort                |                                                           |
| ldapBase                      | dc=example,dc=org                                          |
| ldapBaseGroups                | ou=groups,dc=example,dc=org                                |
| ldapBaseUsers                 | ou=staff,ou=accounts,dc=example,dc=org                     |
| ldapCacheTTL                  | 600                                                       |
| ldapConfigurationActive       | 1                                                         |
| ldapDynamicGroupMemberURL     |                                                           |
| ldapEmailAttribute            | mail                                                      |
| ldapExperiencedAdmin          | 0                                                         |
| ldapExpertUUIDGroupAttr       | cn                                                        |
| ldapExpertUUIDUserAttr        | uid                                                       |
| ldapExpertUsernameAttr        |                                                           |
| ldapGroupDisplayName          | cn                                                        |
| ldapGroupFilter               | (&(|(objectclass=groupOfUniqueNames)))                    |
| ldapGroupFilterGroups         |                                                           |
| ldapGroupFilterMode           | 1                                                         |
| ldapGroupFilterObjectclass    | groupOfUniqueNames                                        |
| ldapGroupMemberAssocAttr      | uniqueMember                                              |
| ldapHost                      | ldaps://login.example.org/                                 |
| ldapIgnoreNamingRules         |                                                           |
| ldapLoginFilter               | (&(&(|(objectclass=organizationalPerson)))(|(mail=%uid))) |
| ldapLoginFilterAttributes     | mail                                                      |
| ldapLoginFilterEmail          | 0                                                         |
| ldapLoginFilterMode           | 0                                                         |
| ldapLoginFilterUsername       | 0                                                         |
| ldapNestedGroups              | 1                                                         |
| ldapOverrideMainServer        |                                                           |
| ldapPagingSize                | 500                                                       |
| ldapPort                      | 636                                                       |
| ldapQuotaAttribute            |                                                           |
| ldapQuotaDefault              |                                                           |
| ldapTLS                       | 0                                                         |
| ldapUserDisplayName           | displayname                                               |
| ldapUserDisplayName2          |                                                           |
| ldapUserFilter                | (&(|(objectclass=organizationalPerson)))                  |
| ldapUserFilterGroups          |                                                           |
| ldapUserFilterMode            | 0                                                         |
| ldapUserFilterObjectclass     | organizationalPerson                                      |
| ldapUuidGroupAttribute        | auto                                                      |
| ldapUuidUserAttribute         | auto                                                      |
| turnOffCertCheck              | 0                                                         |
| useMemberOfToDetectMembership | 0                                                         |
+-------------------------------+-----------------------------------------------------------+

Client configuration

Browser:
Chrome

Operating system:
Windows 10

Logs

Web server error log

[Mon Aug 14 06:39:28.704912 2017] [mpm_prefork:notice] [pid 1575] AH00163: Apache/2.4.7 (Ubuntu) OpenSSL/1.0.1f configured -- resuming normal operations
[Mon Aug 14 06:39:28.704926 2017] [core:notice] [pid 1575] AH00094: Command line: '/usr/sbin/apache2'
[Mon Aug 14 06:39:28.807832 2017] [mpm_prefork:notice] [pid 1575] AH00171: Graceful restart requested, doing restart
[Mon Aug 14 06:39:28.910278 2017] [mpm_prefork:notice] [pid 1575] AH00163: Apache/2.4.7 (Ubuntu) OpenSSL/1.0.1f configured -- resuming normal operations
[Mon Aug 14 06:39:28.910291 2017] [core:notice] [pid 1575] AH00094: Command line: '/usr/sbin/apache2'
[Mon Aug 14 13:32:58.926815 2017] [:error] [pid 31372] [client 50.85.47.12:63656] script '/var/www/index.php' not found or unable to stat

ownCloud log (data/owncloud.log)

POST","url":"\/owncloud\/ocs\/v2.php\/apps\/files_sharing\/api\/v1\/shares?format=json","message":"Failed to notify remote server of federated share, removing share (Sharing testfile.txt failed, could not find user@example.org, maybe the server is currently unreachable.)"}

Where is the owncloud log stored?

#### Browser log

Insert your browser log here, this could for example include:

a) The javascript console log
b) The network log
c) ...
`

I just found out that part of the problem is solved if that user logged in at least once then users can be pre populated when trying to find user to share file with.
However, this data should have been kept from 9.1 to 10 upgrade.
And this doesn't solve the problem that pre-existing shares are lost.

I am doing some more testing.
After some crazy google searches I came across this

sudo -u www-data php occ user:sync "OCA\User_LDAP\User_Proxy"

It may resolve the issue. I am doing further testing.