2022-01-06 00:34:40 +00:00
|
|
|
#!/usr/bin/python
|
2021-08-03 03:23:02 +00:00
|
|
|
|
2022-06-26 00:13:57 +00:00
|
|
|
# A wrapper script over ldapdelete
|
|
|
|
|
2022-06-25 23:08:57 +00:00
|
|
|
from subprocess import run
|
2022-06-26 00:23:12 +00:00
|
|
|
from sys import argv
|
2022-06-25 23:08:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
def deluser(username):
|
|
|
|
"""Delete a user"""
|
|
|
|
|
|
|
|
# Delete from LDAP server
|
2023-06-14 18:56:53 +00:00
|
|
|
run(['ldapdelete', '-y', '/etc/ldappass', '-D', 'cn=Manager,dc=exozy,dc=me',
|
2022-06-26 00:13:57 +00:00
|
|
|
'uid=' + username + ',ou=People,dc=exozy,dc=me', 'cn=' + username + ',ou=Group,dc=exozy,dc=me'])
|
2022-06-25 23:08:57 +00:00
|
|
|
|
|
|
|
# Cleanup
|
|
|
|
run(['sudo', 'rm', '-rf', '/home/' + username])
|
2021-08-03 03:23:02 +00:00
|
|
|
|
2022-01-06 00:34:40 +00:00
|
|
|
|
2022-01-25 02:15:49 +00:00
|
|
|
deluser(argv[1])
|