fix account listing for python3

This commit is contained in:
Markus 2019-02-11 15:53:17 +01:00
parent c1cd8bded1
commit f88da30fe6
2 changed files with 8 additions and 6 deletions

4
dss.py
View File

@ -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'])

View File

@ -1,19 +1,19 @@
{% extends "_base.html" %}
{% block content %}
<div class="page-header">
<h1>List users</h1>
<h1>List Accounts</h1>
</div>
<table class="table table-bordered table-striped">
<thead>
<tr>
<td>CN</td>
<td>DN</td>
<td>common name</td>
<td>distinguished name</td>
</tr>
</thead>
<tbody>
{% for dn, attr in users %}
{% for cn, dn in accounts %}
<tr>
<td>{{ attr['cn'][0] }}</td>
<td>{{ cn }}</td>
<td>{{ dn }}</td>
</tr>
{% endfor %}