From 89a8cecb2a99cc9089191caed76820f5c933a560 Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Tue, 22 Mar 2016 01:06:25 +0100 Subject: [PATCH] Implement user listing. --- index.py | 12 ++++++++++++ templates/list.html | 16 ++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 templates/list.html diff --git a/index.py b/index.py index 6a68f6c..4f1445c 100755 --- a/index.py +++ b/index.py @@ -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() diff --git a/templates/list.html b/templates/list.html new file mode 100644 index 0000000..52a1c49 --- /dev/null +++ b/templates/list.html @@ -0,0 +1,16 @@ +{% extends "_base.html" %} +{% block content %} + + + + + + + {% for dn, _ in users %} + + {% endfor %} + +
DN
{{ dn }}
+{% endblock %}