From: joey <> Date: Sat, 20 Nov 2004 19:06:56 +0000 (+0000) Subject: Ask for the password a second time if it was wrong, also check for a X-Git-Tag: debian_userdir-ldap_0-3-8~42 X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap.git;a=commitdiff_plain;h=d2f7f735023cf87d3510ba0e580ffded7593b3b4 Ask for the password a second time if it was wrong, also check for a wrong password. Proper error checking in place now. --- 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