1
0
mirror of https://github.com/moepman/bk-dss synced 2024-11-17 18:29:16 +01:00

Implement user listing.

This commit is contained in:
Markus 2016-03-22 01:06:25 +01:00
parent dc2afe0e2a
commit 89a8cecb2a
2 changed files with 28 additions and 0 deletions

View File

@ -55,6 +55,7 @@ def buildNav():
if isLoggedin():
nav.append('edit')
if isAdmin():
nav.append('list')
nav.append('create')
nav.append('logout')
else:
@ -140,6 +141,17 @@ def edit():
return render_template('edit.html', form=form, nav=buildNav())
@app.route('/list')
def list():
if not isLoggedin():
return render_template('error.html', message="You are not logged in. Please log in first.", nav=buildNav())
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)', [''])
return render_template('list.html', users=sr, nav=buildNav())
@app.route('/login', methods=['GET', 'POST'])
def login():
form = LoginForm()

16
templates/list.html Normal file
View File

@ -0,0 +1,16 @@
{% extends "_base.html" %}
{% block content %}
<div class="page-header">
<h1>List users</h1>
</div>
<table class="table table-bordered table-striped">
<thead>
<tr><td>DN</td></tr>
</thead>
<tbody>
{% for dn, _ in users %}
<tr><td>{{ dn }}</td></tr>
{% endfor %}
</tbody>
</table>
{% endblock %}