Pretify user list

This commit is contained in:
Kloadut 2012-10-29 15:49:09 +01:00
parent 2f58ab78d1
commit a3213a4b60

View file

@ -21,7 +21,7 @@ def user_list(args, connections):
Dict Dict
""" """
yldap = connections['ldap'] yldap = connections['ldap']
user_attrs = ['uid', 'mail', 'cn'] user_attrs = ['uid', 'mail', 'cn', 'mailalias']
attrs = [] attrs = []
result_dict = {} result_dict = {}
if args['offset']: offset = int(args['offset']) if args['offset']: offset = int(args['offset'])
@ -44,8 +44,18 @@ def user_list(args, connections):
if result and len(result) > (0 + offset) and limit > 0: if result and len(result) > (0 + offset) and limit > 0:
i = 0 + offset i = 0 + offset
for entry in result[i:]: for user in result[i:]:
if i < limit: if i < limit:
entry = {
'Username': user['uid'],
'Fullname': user['cn'],
'Mail': user['mail'][0]
}
if len(user['mail']) > 1:
entry['Mail Forward'] = user['mail'][1:]
if 'mailalias' in user:
entry['Mail Aliases'] = user['mailalias']
result_dict[str(i)] = entry result_dict[str(i)] = entry
i += 1 i += 1
else: else: