diff --git a/dss.py b/dss.py index 92428b8..ae66fd1 100755 --- a/dss.py +++ b/dss.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# -*- coding: utf-8 -*- import uuid @@ -168,7 +169,8 @@ def list_users(): l = ldap.initialize(app.config.get('LDAP_URI', 'ldaps://127.0.0.1')) l.simple_bind_s(rdb.hget(session['uuid'], 'user'), rdb.hget(session['uuid'], 'pswd')) sr = l.search_s(app.config.get('LDAP_BASE'), ldap.SCOPE_SUBTREE, '(objectClass=posixAccount)', ['cn']) - return render_template('list.html', users=sr, nav=build_nav()) + accounts = [(attr['cn'][0].decode(errors='ignore'), dn) for dn, attr in sr] + return render_template('list.html', accounts=accounts, nav=build_nav()) @app.route('/login', methods=['GET', 'POST']) diff --git a/templates/list.html b/templates/list.html index 1568386..f5c93b3 100644 --- a/templates/list.html +++ b/templates/list.html @@ -1,19 +1,19 @@ {% extends "_base.html" %} {% block content %} - - + + - {% for dn, attr in users %} + {% for cn, dn in accounts %} - + {% endfor %}
CNDNcommon namedistinguished name
{{ attr['cn'][0] }}{{ cn }} {{ dn }}