2021-08-03 03:23:02 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
2021-12-11 20:45:12 +00:00
|
|
|
import sys
|
2022-01-05 23:26:51 +00:00
|
|
|
from subprocess import run
|
2021-08-03 03:23:02 +00:00
|
|
|
|
2022-01-05 23:26:51 +00:00
|
|
|
# Delete a user
|
|
|
|
def deluser(username):
|
2021-12-11 20:45:12 +00:00
|
|
|
# Delete user
|
2022-01-05 23:26:51 +00:00
|
|
|
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"', shell=True)
|
2021-12-11 20:45:12 +00:00
|
|
|
# Cleanup
|
2022-01-05 23:26:51 +00:00
|
|
|
run('sudo rm -rf /home/' + username, shell=True)
|
|
|
|
|
|
|
|
# Running as script
|
|
|
|
if __name__ == "__main__":
|
|
|
|
deluser(sys.argv[1])
|