core icon indicating copy to clipboard operation
core copied to clipboard

Using LDAP for users with folder sharing; ldap user gone, clients no longer work

Open frankuit opened this issue 10 years ago • 25 comments

Steps to reproduce

1.have owncloud do user authentication over LDAP 2.share a folder with other LDAP users 3.delete the user from LDAP that had shared folders with other people.

Expected behaviour

the shared folder should stop syncing or, give an error in the owncloud client other then the general error. At least an administrator should be able to see who has this problem.Also, one expects the client to keep syncing the other files from the user.

Actual behaviour

the client no longer syncs files back and forth, even from other folders then shared ones.

Server configuration

Operating system: Debian linux Jessie (latest)

Web server: Apache (debian standard, 2.4)

Database: Mysql

PHP version: php (debian standard, 5.6.17)

ownCloud version: 8.2.3-2.1 (latest release from your site)

Updated from an older ownCloud or fresh install: updated verson

Where did you install ownCloud from: debian repository from your site

Error message in syslog:

Mar 31 15:13:56 owncloud ownCloud[48603]: {files_sharing} Exception: {"Exception":"OC\User\NoUserException","Message":"username_remove_privacy is not a valid user anymore","Code":0,"Trace":"#0 /var/www/owncloud/lib/private/user/user.php(231): OCA\user_ldap\USER_LDAP->getHome('toyoakis')\n#1 /var/www/owncloud/lib/private/user.php(581): OC\User\User->getHome()\n#2 /var/www/owncloud/lib/private/files/filesystem.php(378): OC_User::getHome('username_removed_privacy')\n#3 /var/www/owncloud/apps/files_sharing/lib/cache.php(69): OC\Files\Filesystem::initMountPoints('username_removed_privacy')\n#4 /var/www/owncloud/apps/files_sharing/lib/cache.php(107): OC\Files\Cache\Shared_Cache->getSourceCache('')\n#5 /var/www/owncloud/lib/private/files/view.php(1235): OC\Files\Cache\Shared_Cache->get('')\n#6 /var/www/owncloud/lib/private/connector/sabre/serverfactory.php(119): OC\Files\View->getFileInfo('')\n#7 [internal function]: OC\Connector\Sabre\ServerFactory->OC\Connector\Sabre{closure}(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))\n#8 /var/www/owncloud/3rdparty/sabre/event/lib/EventEmitterTrait.php(105): call_user_func_array(Object(Closure), Array)\n#9 /var/www/owncloud/3rdparty/sabre/dav/lib/DAV/Server.php(456): Sabre\Event\EventEmitter->emit('beforeMethod', Array)\n#10 /var/www/owncloud/3rdparty/sabre/dav/lib/DAV/Server.php(254): Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))\n#11 /var/www/owncloud/apps/files/appinfo/remote.php(56): Sabre\DAV\Server->exec()\n#12 /var/www/owncloud/remote.php(137): require_once('/var/www/ownclo...')\n#13 {main}","File":"/var/www/owncloud/apps/user_ldap/user_ldap.php","Line":327}

sudo -u www-data php occ app:list Enabled:

  • files: 1.2.1
  • files_external: 0.3.0
  • files_sharing: 0.7.0
  • files_trashbin: 0.7.0
  • files_versions: 1.1.0
  • firstrunwizard: 1.1
  • gallery: 14.2.0
  • user_external: 0.4
  • user_ldap: 0.7.1 Disabled:
  • activity
  • appframework
  • encryption
  • external
  • files_embeddedvideo
  • files_pdfviewer
  • files_texteditor
  • files_videoviewer
  • notifications
  • provisioning_api
  • templateeditor

The content of config/config.php: cat config/config.php

'removed', 'passwordsalt' => 'reomved', 'trusted_domains' => array ( 0 => 'removed', ), 'datadirectory' => '/owncloud/owncloud', 'dbtype' => 'mysql', 'version' => '8.2.3.2', 'dbname' => 'owncloud', 'dbhost' => 'hostname', 'dbtableprefix' => 'oc_', 'dbuser' => 'username', 'dbpassword' => 'password', 'installed' => true, 'ldapIgnoreNamingRules' => false, 'trashbin_retention_obligation' => '30, auto', 'log_authfailip' => true, 'loglevel' => '2', 'default_language' => 'en', 'log_type' => 'syslog', 'logfile' => '', 'forcessl' => true, 'memcache.local' => '\OC\Memcache\APC', 'maxZipInputSize' => 838860800, 'allowZipDownload' => true, 'mail_smtpmode' => 'smtp', 'mail_smtphost' => 'removed', 'mail_smtpport' => '25', 'theme' => '', 'overwrite.cli.url' => '/owncloud', 'maintenance' => false, 'mail_from_address' => 'owncloud', 'mail_domain' => 'removed', 'secret' => 'removed', ); **Are you using encryption:** yes/no Not using encryption **Are you using an external user-backend, if yes which one:** LDAP/ActiveDirectory/Webdav/... #### LDAP configuration (delete this part if not used) sudo -u www-data php occ ldap:show-config +-------------------------------+---------------------------------------------+ | Configuration | | +-------------------------------+---------------------------------------------+ | hasMemberOfFilterSupport | | | hasPagedResultSupport | | | homeFolderNamingRule | attr:cn | | lastJpegPhotoLookup | 0 | | ldapAgentName | | | ldapAgentPassword | **\* | | ldapAttributesForGroupSearch | | | ldapAttributesForUserSearch | | | ldapBackupHost | removed | | ldapBackupPort | 389 | | ldapBase | o=removed | | ldapBaseGroups | o=removed | | ldapBaseUsers | ou=removed | | ldapCacheTTL | 600 | | ldapConfigurationActive | 1 | | ldapEmailAttribute | mail | | ldapExperiencedAdmin | 0 | | ldapExpertUUIDGroupAttr | | | ldapExpertUUIDUserAttr | cn | | ldapExpertUsernameAttr | cn | | ldapGroupDisplayName | cn | | ldapGroupFilter | (&(|(objectclass=posixGroup))(|(cn=Users))) | | ldapGroupFilterGroups | Users | | ldapGroupFilterMode | 0 | | ldapGroupFilterObjectclass | posixGroup | | ldapGroupMemberAssocAttr | uniqueMember | | ldapHost | removed | | ldapIgnoreNamingRules | | | ldapLoginFilter | (&(|(objectclass=Person))(|(cn=%uid))) | | ldapLoginFilterAttributes | cn | | ldapLoginFilterEmail | 0 | | ldapLoginFilterMode | 0 | | ldapLoginFilterUsername | 0 | | ldapNestedGroups | 0 | | ldapOverrideMainServer | 0 | | ldapPagingSize | 500 | | ldapPort | 389 | | ldapQuotaAttribute | | | ldapQuotaDefault | | | ldapTLS | 1 | | ldapUserDisplayName | fullname | | ldapUserDisplayName2 | | | ldapUserFilter | (|(objectclass=Person)) | | ldapUserFilterGroups | | | ldapUserFilterMode | 0 | | ldapUserFilterObjectclass | Person | | ldapUuidGroupAttribute | auto | | ldapUuidUserAttribute | auto | | turnOffCertCheck | 0 | | useMemberOfToDetectMembership | 1 | +-------------------------------+---------------------------------------------+ How should i proceed ? Thanks, Frank

frankuit avatar Mar 31 '16 13:03 frankuit

I have the same situation, but with ownCloud version 9.0.0.19.

Btw, the problem got more serious with OC9. A user, which has a shared folder from a deleted ldap user can no longer access his own data (any data, the message is "This directory is unavailable, please check the logs or contact the administrator"). However, there is already a patch, #23039.

Anyway, I don't have a real solution for you, just a workaround: Delete the shares of the deleted ldap users in SQL directly.

Connect: mysql owncloud

Show ownCloud shares of user 'deletedldapuser': SELECT * FROM oc_share WHERE uid_owner='deletedldapuser';

Delete ownCloud shares of user 'deletedldapuser': DELETE FROM oc_share WHERE uid_owner='deletedldapuser';

TomGem avatar Apr 01 '16 10:04 TomGem

@owncloud/ldap What do you think?

LukasReschke avatar Apr 01 '16 10:04 LukasReschke

not LDAP's biz. Sharing should know what to do when a sharer went over board.

summoning @owncloud/sharing

blizzz avatar Apr 01 '16 10:04 blizzz

For reference, for cleaning up after deleted LDAP users please read https://doc.owncloud.org/server/9.0/admin_manual/configuration_user/user_auth_ldap_cleanup.html

blizzz avatar Apr 01 '16 10:04 blizzz

Oh, I missed this one.

So all you have to do is occ ldap:show-remnants and occ user:delete deletedldapuser from time to time, e.g. cron.

Thanks!

TomGem avatar Apr 01 '16 11:04 TomGem

first i used the mysql delete method, and that fixed the problem, but this second suggestion is perfect.

Thanks, my issue is resolved. Regards, Frank Uittenbosch

frankuit avatar Apr 01 '16 11:04 frankuit

this script will do it in a cronjob: (remove the echo after you've verified that it works!!)

#!/bin/bash cd /var/www/owncloud sudo -u www-data php occ ldap:show-remnants for i in sudo -u www-data php occ ldap:show-remnants|grep -v ownCloud|awk {'print $2'};do echo sudo -u www-data php occ user:delete $i done

For the future, is it perhaps better that this becomes built-in to the system so that we don't have to make these "dirty" scripts ?

Thanks, Frank

frankuit avatar Apr 01 '16 12:04 frankuit

@frankuit The reason it's not built in is that it's not always desirable to delete a users home directory immediately after they're removed from the directory. You may want to keep the directory and wait for requests from other users for shared content that's no longer shared and wasn't handed over properly.

I have recently seen the same problem on 8.2.3. @blizzz is right though. This isn't an ldap problem. The sharing and sync system should be able to elegantly handle the situation where a backend can't find a user any longer and treat that row in the share table as though it wasn't there rather than just stop.

My current solution is to delete and row in the share table that's owned by or shared to a user that is flagged as deleted by the user_ldap app. Eg (assuming your table prefix is oc):

SELECT 
   *
FROM
   oc_share
WHERE
   share_with IN (SELECT 
           userid
       FROM
           oc_preferences
       WHERE
           appid = 'user_ldap'
               AND configkey = 'isDeleted'
               AND configvalue = '1')
       or uid_owner IN (SELECT 
           userid
       FROM
           oc_preferences
       WHERE
           appid = 'user_ldap'
               AND configkey = 'isDeleted'
               AND configvalue = '1');

Then delete what you find if you're happy with it.

Then delete the actual user when you no longer think there'll be a need to recover any data from their directory.

scolebrook avatar Apr 01 '16 13:04 scolebrook

The problem is sometimes ldap servers have hickups... and when they have hickups we don't just want to delete all the user data.

rullzer avatar Apr 02 '16 07:04 rullzer

@rullzer i understand, but then you'd expect the client to keep working instead of stopping all sync activities until the user is manually deleted. Agreed ?

Regards, Frank Uittenbosch

frankuit avatar Apr 02 '16 08:04 frankuit

From what I understand, the user goes into a "zombie/disabled" state in OC in which the user cannot sync any more. @blizzz can you clarify ?

PVince81 avatar Apr 21 '16 09:04 PVince81

@PVince81 huh? If the user gone from LDAP, he is gone. Nothing with disabled. But since the record is not there, you cannot do anything with that user. The data on ownCloud is they are removed via occ user:delete <USERNAME>. List of deleted LDAP users is shown by ldap:show-remnants also via occ.

blizzz avatar Apr 21 '16 13:04 blizzz

@cdamken reminds me of similar discussions about remnants causing trouble

PVince81 avatar Jan 27 '17 14:01 PVince81

@davitol is this reproducible ?

PVince81 avatar Jan 27 '17 14:01 PVince81

Is this still happening with 8.2.10, 9.1.4 ? From what I remember a few safeties have been added in the LDAP code to avoid such issues.

PVince81 avatar Apr 06 '17 17:04 PVince81

closing due to lack of feedback

PVince81 avatar May 15 '17 15:05 PVince81

I've got the same issue in 8.2.11. If a user 'leaves' the company and went on the oC remnants list, other users that have shares from him are 'blocked'. This seems to be happen because of a very bad performance in backend. Sometimes (if the server load is low enough) the sync or browser interface will work for one or two times. Very annoying behavior. I would expect that the share recipients can work with the data normally until the remnant is deleted by an administrator.

Please reopen this ticket.

kiu-ball avatar Jun 06 '17 13:06 kiu-ball

Maybe this issue additionally leads to a severely higher DB load.

kiu-ball avatar Jun 08 '17 09:06 kiu-ball

The issue is solved for me! (thnx for your tip @butonic)

In my case the getHome() method in apps/user/ldap/user_ldap.php calls userExistsOnLDAP() in the same class for every share with an remnant. the userExistsOnLDAP() method in turn calls getUserDnByUuid() in apps/user_ldap/lib/access.php. This method tries to guess the LDAP UUID attribute again and again without saving the result... To solve this behavior you just have to set the LDAP config for ldapExpertUUIDUserAttr and ldapExpertUUIDGroupAttr manually to your UUID Attribute. After this the performance is quite good and the problem went away.

kiu-ball avatar Jun 16 '17 09:06 kiu-ball

I've used occ ldap:show-remnants and occ user:delete deletedldapuser to remove old ldap users over the last year, it was working fine.

Now, with 9.1.6, this has stopped working. When I try to delete the users from occ ldap:show-remnants I get this error message.

occ user:delete olduser
                                     
  [OC\User\NoUserException]          
  olduser is not a valid user anymore 

But according to https://doc.owncloud.org/server/9.1/admin_manual/configuration_user/user_auth_ldap_cleanup.html this should still work, or have I missed something again? :)

TomGem avatar Jun 29 '17 10:06 TomGem