Generate random password for each user

This commit is contained in:
Anthony Wang 2021-08-20 17:01:29 -05:00
parent 7e7b031cea
commit 5df268645e
Signed by: a
GPG key ID: BC96B00AEC5F2D76

View file

@ -10,6 +10,10 @@ lastname = input('Enter last name: ')
email = input('Enter email: ')
uid = input('Enter UID: ')
# Password
password = os.popen('tr -dc A-Za-z0-9 </dev/urandom | head -c 16; echo ""').read()
hashedpassword = os.popen('slappasswd -s ' + password).read()
print('Password:', password)
# Construct LDIF
ldif = '''dn: uid={username},ou=People,dc=exozy,dc=me
@ -23,7 +27,7 @@ uid: {username}
cn: {firstname} {lastname}
sn: {lastname}
givenName: {firstname}
userPassword: {SSHA}bz40SXh6L4eoUwmDDGySG5xLLW8oQPwA
userPassword: {hashedpassword}
mail: {email}
loginShell: /bin/fish
uidNumber: {uid}
@ -38,7 +42,8 @@ gidNumber: {uid}'''.format(username=username,
firstname=firstname,
lastname=lastname,
email=email,
uid=uid)
uid=uid,
hashedpassword=hashedpassword)
# Write to file and get confirmation