0 like 0 dislike
1 view
in Linux by Seyyah (2.9k points)
nextcloud'da ldap kullanıldığı durumda, active directory'den silinen bir kullanıcının bütün verilerini nasıl temizlerim?

1 Answer

0 like 0 dislike
by Seyyah (2.9k points)
#/bin/bash
mysqlUser="kullaniciadi"
mysqlPW="parola"
mysqlDB="veritabaniadi"
mysqlHost="hostname"
ncData="nextcloudverilerininklasoru"
mysqlCMD="mysql -h $mysqlHost -u $mysqlUser --password=$mysqlPW $mysqlDB -N -e "

# get list if deleted users and remove their resp. homefolders
echo "Now scanning for deleted LDAP user accounts.."
for i in `$mysqlCMD "select userid from oc_preferences where configKey='isDeleted' AND configValue=1;"`; do
        echo "Removing user home: $i"
                rm -rf $ncData/$i
                done
# removing orphaned storages from oc_storages:
echo "Now removing orphaned user storages from oc_storages..."
`$mysqlCMD "delete from oc_storages where id in (select concat('home::',userid) from oc_preferences where configKey='isDeleted' AND configValue=1);"`
#renoving orphaned mounts from oc_mounts:
echo "Now removing orphaned mounts from oc_mounts..."
`$mysqlCMD "delete from oc_mounts where id in (select concat('home::',userid) from oc_preferences where configKey='isDeleted' AND configValue=1);"`
#renoving deleted users from oc_ldap_user_mapping:
echo "Now removing deleted users from oc_ldap_user_mapping..."
`$mysqlCMD "delete from oc_ldap_user_mapping where owncloud_name in (select userid from oc_preferences where configKey='isDeleted' AND configValue=1);"`
#renoving deleted users from oc_accounts:
echo "Now removing deleted users from oc_accounts..."
`$mysqlCMD "delete from oc_accounts where uid in (select userid from oc_preferences where configKey='isDeleted' AND configValue=1);"`
# finally remove deleted users from oc_preferences (must be the last action)
 echo "Now removing deleted users from oc_preferences..."
`$mysqlCMD "CREATE TEMPORARY TABLE IF NOT EXISTS oc_preferences_tmp AS (select userid from oc_preferences where configKey='isDeleted' AND configValue=1); delete from oc_preferences where userid in (select userid from oc_preferences_tmp)$
...