don't stop on UserDoesntExist exception on delete

previously, if a user didn't exist in one backend, the _deleteuser
function in ldapcherry would stop on the UserDoesntExist exception,
potentially leaving the user in other backends.
Now it logs it and continues to delete the user in other backend.
This commit is contained in:
kakwa 2016-07-31 10:06:17 +02:00
parent cf97f01245
commit fec09b1543
1 changed files with 8 additions and 1 deletions

View File

@ -847,7 +847,14 @@ class LdapCherry(object):
admin = sess.get(SESSION_KEY, None)
for b in self.backends:
self.backends[b].del_user(username)
try:
self.backends[b].del_user(username)
except UserDoesntExist as e:
cherrypy.log.error(
msg="User '" + username +
"' didn't exist in backend '" + b + "'",
severity=logging.INFO
)
cherrypy.log.error(
msg="user '" + username + "' deleted from backend '" + b + "'",
severity=logging.DEBUG