Index: modules/univention/s4connector/__init__.py =================================================================== --- modules/univention/s4connector/__init__.py (Revision 48942) +++ modules/univention/s4connector/__init__.py (Arbeitskopie) @@ -63,12 +63,27 @@ if type(mlValue) == type([]): return [make_lower(x) for x in mlValue] return mlValue - + +password_charsets = [ + 'abcdefghijklmnopqrstuvwxyz', + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', + '0123456789', + '^!\$%&/()=?{[]}+~#-_.:,;<>|\\', + ] + +def generate_strong_password(length=20): + pwd = [] + charset = random.choice(password_charsets) + while len(pwd) < length: + pwd.append(random.choice(charset)) + charset = random.choice(list(set(password_charsets) - set([charset]))) + return "".join(pwd) + def set_ucs_passwd_user(s4connector, key, ucs_object): ''' set random password to fulfill required values ''' - ucs_object['password'] = str(int(random.random()*100000000))*8 # at least 8 characters + ucs_object['password'] = generate_strong_password() def check_ucs_lastname_user(s4connector, key, ucs_object): '''