From f88da30fe6810d431393ddaa603b620a3813c47e Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Mon, 11 Feb 2019 15:53:17 +0100 Subject: [PATCH] fix account listing for python3 --- dss.py | 4 +++- templates/list.html | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) 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 }}