scripts/moduser

26 lines
588 B
Python
Executable file

#!/usr/bin/python
# A wrapper script over ldapvi
# Requires http://www.lichteblau.com/ldapvi/
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 == 'Manager':
run(['ldapvi', '-w', open('/etc/ldappass', 'r').read(),
'--user', 'cn=Manager,dc=exozy,dc=me'])
else:
dn = 'uid=' + username + ',ou=People,dc=exozy,dc=me'
run(['ldapvi', '--user', dn, '--base', dn])
moduser(argv[1])