17 lines
597 B
Python
17 lines
597 B
Python
|
from subprocess import run
|
||
|
|
||
|
|
||
|
def deluser(username, ldap_pass=None):
|
||
|
"""Delete a user"""
|
||
|
|
||
|
# Delete from LDAP server
|
||
|
if ldap_pass is None:
|
||
|
run(['ldapdelete', '-W', '-D', 'cn=Manager,dc=exozy,dc=me', 'uid=' + username +
|
||
|
',ou=People,dc=exozy,dc=me', 'cn=' + username + ',ou=Group,dc=exozy,dc=me'])
|
||
|
else:
|
||
|
run(['ldapdelete', '-w', ldap_pass, '-D', 'cn=Manager,dc=exozy,dc=me', 'uid=' + username +
|
||
|
',ou=People,dc=exozy,dc=me', 'cn=' + username + ',ou=Group,dc=exozy,dc=me'])
|
||
|
|
||
|
# Cleanup
|
||
|
run(['sudo', 'rm', '-rf', '/home/' + username])
|