28 lines
625 B
Python
Executable file
28 lines
625 B
Python
Executable file
#!/usr/bin/python
|
|
|
|
# A wrapper script over ldapvi
|
|
# Requires http://www.lichteblau.com/ldapvi/
|
|
|
|
from getpass import getuser
|
|
from os import environ
|
|
from subprocess import run
|
|
from sys import argv
|
|
|
|
|
|
def moduser(username):
|
|
"""Modify an existing user"""
|
|
|
|
if 'EDITOR' not in environ:
|
|
environ['EDITOR'] = 'micro'
|
|
|
|
if username == 'root':
|
|
run(['ldapvi', '-y', '/etc/ldappass', '-D', 'cn=Manager,dc=exozy,dc=me'])
|
|
else:
|
|
dn = 'uid=' + username + ',ou=People,dc=exozy,dc=me'
|
|
run(['ldapvi', '-D', dn, '--base', dn])
|
|
|
|
if len(argv) > 1:
|
|
moduser(argv[1])
|
|
else:
|
|
moduser(getuser())
|