Commit 420d3f30 authored by Andrea Veri's avatar Andrea Veri

Do not build the dictionary by using zip but parse the results directly from search_s

parent 3a907c87
......@@ -41,13 +41,10 @@ def _get_attributes_from_ldap(userid, attr):
filter = ldap.filter.filter_format('(uid=%s)', (userid, ))
results = l.search_s(LDAP_USER_BASE, ldap.SCOPE_SUBTREE, filter, ('uid', attr, ))
for entry in results:
username = entry[1]['uid']
attribute = entry[1][attr]
userslist = dict(zip(username, attribute))
return userslist
if len(results) > 0:
return results[0][1][attr][0]
else:
return None
def gen_passwd(length=12, chars=string.letters + string.digits):
......@@ -99,7 +96,7 @@ def update_password(userid):
l.modify_s('uid=%s,cn=users,cn=accounts,dc=gnome,dc=org' % userid, replace_password)
send_password_to_user(getattr_name[userid], getattr_mail[userid], newpassword['userPassword'])
send_password_to_user(getattr_name, getattr_mail, newpassword['userPassword'])
def send_password_to_user(name, email, password):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment