From d2f7f735023cf87d3510ba0e580ffded7593b3b4 Mon Sep 17 00:00:00 2001 From: joey <> Date: Sat, 20 Nov 2004 19:06:56 +0000 Subject: [PATCH] Ask for the password a second time if it was wrong, also check for a wrong password. Proper error checking in place now. --- ud-useradd | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/ud-useradd b/ud-useradd index 009bdd3..9489755 100755 --- a/ud-useradd +++ b/ud-useradd @@ -40,12 +40,21 @@ for (switch, val) in options: userdir_gpg.GPGKeyRings = OldGPGKeyRings; print "Accessing LDAP directory as '" + AdminUser + "'"; -Password = getpass(AdminUser + "'s password: "); +while (1): + Password = getpass(AdminUser + "'s password: "); + + if len(Password) == 0: + sys.exit(0) + + l = ldap.open(LDAPServer); + UserDn = "uid=" + AdminUser + "," + BaseDn; -# Connect to the ldap server -l = ldap.open(LDAPServer); -UserDn = "uid=" + AdminUser + "," + BaseDn; -l.simple_bind_s(UserDn,Password); + # Connect to the ldap server + try: + l.simple_bind_s(UserDn,Password); + except ldap.INVALID_CREDENTIALS: + continue + break # Locate the key of the user we are adding GPGBasicOptions[0] = "--batch" # Permit loading of the config file -- 2.20.1