OCC Problem with Ldap

Hello i have a owncloud server Version 9.1.5 (stable), based on ubuntu.
It works fine and i authenticate the users via LDAP attached to a windows active directory and everything works fine.
I need to delete the files older than 7 days, i know there is not such a feature so i created the following script:

!/bin/bash

Erase files older than 7 day in my data directory and mantain folders:

/usr/bin/find /owncloud/owncloud/data/*/files/ -mtime +7 -exec rm {} \;

rescan filesystem:

/usr/bin/sudo -u www-data php /owncloud/owncloud/occ files:scan "--all"

Steps to reproduce

1.Run the command : /usr/bin/sudo -u www-data php /owncloud/owncloud/occ files:scan "--all"

Expected behaviour

Tell us what should happen
As from doumentation it is supposed to rescan all the file user and update the db removing the deleted files.

Actual behaviour

Tell us what happens instead
Actually when i run it :
/usr/bin/sudo -u www-data php /owncloud/owncloud/occ files:scan "--all"

[OC\ServerNotAvailableException]
Connection to LDAP server could not be established

files:scan [--output [OUTPUT]] [-p|--path PATH] [-q|--quiet] [-v|vv|vvv|--verbose] [--all] [--unscanned] [--] []...

Server configuration

Operating system:Ubuntu 14.04.5 LTS

Web server:Apache/2.4.7 (Ubuntu) PHP/5.5.9-1ubuntu4.21 OpenSSL/1.0.1f

Database:mysql

PHP version:

ownCloud version: (see ownCloud admin page)9.1.5

Updated from an older ownCloud or fresh install:fresh install

Nobody could help with this?

Domenico

Probably the connection to the LDAP server is lost during the file scan.

I'd recommend you to access through the webdav interface even though the process will likely be more expensive and time consuming, but it will be cleaner. Removing the files directly from the data folder isn't supported (do it at your own risk), and the files:scan is intended to be a fixer for some issues but it wasn't planned to be executed on purpose like that.

In any case, the files:scan support an user_id to be passed as parameter to scan only that user's folder. The simple fix is to get a list of user_ids you want to scan and go one by one instead of scanning all at once.