forked from moepman/bk-dss
Rename function list to list_users.
The function list shadowed the built-in type list leading to weird TypeError exceptions in the user creation. While at it list the users cn before the dn to improve readability.
This commit is contained in:
parent
5aabd7ed6d
commit
46e560cef9
6
index.py
6
index.py
@ -91,7 +91,7 @@ def create():
|
|||||||
user_dn = app.config.get('USER_DN').format(**d)
|
user_dn = app.config.get('USER_DN').format(**d)
|
||||||
attrs = {}
|
attrs = {}
|
||||||
for k,v in app.config.get('USER_ATTRS').iteritems():
|
for k,v in app.config.get('USER_ATTRS').iteritems():
|
||||||
if type(v) == str:
|
if isinstance(v, str):
|
||||||
attrs[k] = v.format(**d)
|
attrs[k] = v.format(**d)
|
||||||
elif isinstance(v, list):
|
elif isinstance(v, list):
|
||||||
attrs[k] = []
|
attrs[k] = []
|
||||||
@ -142,13 +142,13 @@ def edit():
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/list')
|
@app.route('/list')
|
||||||
def list():
|
def list_users():
|
||||||
if not isLoggedin():
|
if not isLoggedin():
|
||||||
return render_template('error.html', message="You are not logged in. Please log in first.", nav=buildNav())
|
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 = 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'))
|
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)', [''])
|
sr = l.search_s(app.config.get('LDAP_BASE'), ldap.SCOPE_SUBTREE, '(objectClass=posixAccount)', ['cn'])
|
||||||
return render_template('list.html', users=sr, nav=buildNav())
|
return render_template('list.html', users=sr, nav=buildNav())
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,11 +5,17 @@
|
|||||||
</div>
|
</div>
|
||||||
<table class="table table-bordered table-striped">
|
<table class="table table-bordered table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr><td>DN</td></tr>
|
<tr>
|
||||||
|
<td>CN</td>
|
||||||
|
<td>DN</td>
|
||||||
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for dn, _ in users %}
|
{% for dn, attr in users %}
|
||||||
<tr><td>{{ dn }}</td></tr>
|
<tr>
|
||||||
|
<td>{{ attr['cn'][0] }}</td>
|
||||||
|
<td>{{ dn }}</td>
|
||||||
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
Reference in New Issue
Block a user