Add delete_user

This commit is contained in:
PCoder 2019-02-24 17:44:48 +01:00
parent a909a9b5c5
commit 4e9493f198

View file

@ -200,6 +200,27 @@ class LdapManager:
conn.unbind() conn.unbind()
return result, entries return result, entries
def delete_user(self, uid):
"""
Deletes the user with the given uid from ldap
:param uid: str representing the user
:return: True if the delete was successful False otherwise
"""
conn = self.get_admin_conn()
try:
return_val = conn.delete(
("uid={uid}," + settings.LDAP_CUSTOMER_DN).format(uid=uid),
)
msg = "success"
except Exception as ex:
msg = str(ex)
logger.error("Exception: " + msg)
return_val = False
finally:
conn.unbind()
return return_val, msg
def _set_max_uid(self, max_uid): def _set_max_uid(self, max_uid):
""" """
a utility function to save max_uid value to a file a utility function to save max_uid value to a file